babylonjs-toolkit 9.34.1 → 9.34.100

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.
package/lib/index.d.ts CHANGED
@@ -7,7 +7,7 @@ declare namespace TOOLKIT {
7
7
  * @class SceneManager - All rights reserved (c) 2024 Mackey Kinard
8
8
  */
9
9
  class SceneManager {
10
- /** Gets the toolkit framework version string (9.34.1 - R1) */
10
+ /** Gets the toolkit framework version string (9.34.100 - R1) */
11
11
  static get Version(): string;
12
12
  /** Gets the toolkit framework copyright notice */
13
13
  static get Copyright(): string;
@@ -200,6 +200,8 @@ declare namespace TOOLKIT {
200
200
  /** Hidden layer mask value (Unity Layer 28 - Value: 268435456) */
201
201
  static readonly HiddenLayerMask: number;
202
202
  private static _HideLoadingScreen;
203
+ /** The fade a HideLoadingScreen call asked for while its scene is revealed first. */
204
+ private static _FadeLoadingScreen;
203
205
  static CVTOOLS_NAME: string;
204
206
  static CVTOOLS_MESH: string;
205
207
  static CVTOOLS_HAND: string;
@@ -283,15 +285,19 @@ declare namespace TOOLKIT {
283
285
  */
284
286
  static LoadRuntimeAssets(assetsManager: BABYLON.AssetsManager, requiredFilenames: string[], readyHandler: () => void, maxTimeout?: number, debugMode?: boolean): Promise<void>;
285
287
  /**
286
- * Shows the default loading screen panel
288
+ * Shows the default loading screen panel, with the splash stages on it (LoadingScreenStages). It counts as the page's splash,
289
+ * so the reveal waits for it. On a page that painted its own cover (engine.html) the stages go on that cover instead.
287
290
  * @param engine The engine instance.
288
291
  * @param hideLoadingUIWithEngine hide the loading screen with engine.hideLoadingUI. When set to false, you must manually hide the loading screen using TOOLKIT.SceneManager.HideLoadingScreen when the scene is ready. Default true.
289
- * @param defaultLoadingUIMarginTop The top margin of the loading text. Default 150px.
292
+ * @param defaultLoadingUIMarginTop The top margin of the loading stages (status line and bar). Default 150px.
290
293
  */
291
294
  static ShowLoadingScreen(engine: BABYLON.Engine | BABYLON.WebGPUEngine | BABYLON.AbstractEngine, hideLoadingUIWithEngine?: boolean, defaultLoadingUIMarginTop?: string): void;
292
295
  /**
293
- * Hides the default loading screen panel
296
+ * Hides the default loading screen panel. While the stages are on it and the engine's last scene is not revealed yet, the screen
297
+ * ends like every splash: this returns at once, PREWARM runs behind the screen (HideSplashScreen), it shows Ready, the
298
+ * reveal is recorded, and then it fades.
294
299
  * @param engine The engine instance.
300
+ * @param fade Fade the screen out. Default true.
295
301
  */
296
302
  static HideLoadingScreen(engine: BABYLON.Engine | BABYLON.WebGPUEngine | BABYLON.AbstractEngine, fade?: boolean): void;
297
303
  /** Force the engine loading screen to be hidden (Triple Check Loading Screen Hidden) */
@@ -371,7 +377,8 @@ declare namespace TOOLKIT {
371
377
  /**
372
378
  * True while the page's splash screen is up: shown and not yet fading out (both kinds fade by setting an inline opacity of 0).
373
379
  * The React splash is `#xbabylonjsSplashScreen` (its inner `#xbabylonjsLoadingDiv` never fades itself, so only the outer one
374
- * counts); the exported engine.html loader is `#xbabylonjsLoadingDiv` alone.
380
+ * counts); the exported engine.html loader is `#xbabylonjsLoadingDiv` alone. Without either, the built-in loading screen counts
381
+ * (ShowLoadingScreen, LoadingScreenStages).
375
382
  * @returns False when there is no document or no splash element.
376
383
  */
377
384
  static IsSplashScreenShowing(): boolean;
@@ -2728,7 +2735,7 @@ declare namespace TOOLKIT {
2728
2735
  * @param projectScriptBundleUrl specified project script bundle. Default (default.playground.js).
2729
2736
  * @param showDefaultLoadingScreen show the default loading screen. Default false.
2730
2737
  * @param hideLoadingUIWithEngine hide the loading screen with engine.hideLoadingUI. When set to false, you must manually hide the loading screen using TOOLKIT.SceneManager.HideLoadingScreen when the scene is ready. Default true.
2731
- * @param defaultLoadingUIMarginTop The top margin of the loading text. Default 150px.
2738
+ * @param defaultLoadingUIMarginTop The top margin of the loading stages (status line and bar). Default 150px.
2732
2739
  * @param trackDevicePixelRatio re-apply the hardware scaling level (1 / window.devicePixelRatio) and resize the engine whenever the device pixel ratio changes (a window moved between displays, browser zoom). Default true when hardwareScalingLevel is not set, false when it is.
2733
2740
  */
2734
2741
  interface IRuntimeOptions {
@@ -4311,7 +4318,8 @@ declare namespace TOOLKIT {
4311
4318
  * and `distances[N-1]` doubles as the cull threshold. Unchanged HYBRID strategy: every level one mesh =>
4312
4319
  * native `master.addLODLevel(distances[i-1], mesh)` plus a final `addLODLevel(cull, null)` band (an
4313
4320
  * InstancedMesh master keeps the legacy dispose of its unused detail levels); any level with >1 mesh =>
4314
- * the scene's shared switcher (`_setupLevelOfDetailSwitcher`).
4321
+ * the scene's shared switcher (`_setupLevelOfDetailSwitcher`), as has a level authored away from LOD0, because
4322
+ * Babylon draws a native level with its master's matrix (`UnityLodGroups.RequiresSwitcher`).
4315
4323
  * - `coverages` only (every headless export - there is no scene-view camera to turn heights into
4316
4324
  * distances, F-M.57): Unity's own rule, `UnityLodAndLights.SelectCoverageLevel` on the screen-relative
4317
4325
  * height `worldSize * lodBias / (2 * tan(vfov / 2) * distance)` of the group, through the same switcher.
@@ -6229,7 +6237,12 @@ declare namespace TOOLKIT {
6229
6237
  static RegisterShaders(): void;
6230
6238
  /** The head-of-chain pass that writes min(c, MaxRadiance) and replaces NaN with 0 (WGSL on WebGPU). */
6231
6239
  static CreateSanitizePass(scene: BABYLON.Scene, camera: BABYLON.Camera, textureType: number): BABYLON.PostProcess;
6232
- private static SceneMetadata;
6240
+ /**
6241
+ * The scene's exported toolkit metadata.
6242
+ * @param scene The scene.
6243
+ * @returns The metadata, or null.
6244
+ */
6245
+ static SceneMetadata(scene: BABYLON.Scene): any;
6233
6246
  private static State;
6234
6247
  private static ApplyBinding;
6235
6248
  }
@@ -6447,6 +6460,14 @@ declare namespace TOOLKIT {
6447
6460
  * @param light A Babylon light (reads `diffuse` and `metadata.toolkit.colorTemperature`), or null.
6448
6461
  */
6449
6462
  static UnityLinearLightColor(light: any): BABYLON.Color3;
6463
+ /**
6464
+ * Gives a toolkit light the colour Unity lights with in a Linear project (`UnityLinearLightColor`) and marks it, so every later
6465
+ * conversion returns it unchanged. An HDRP parity export and a Gamma project keep the exported colour.
6466
+ * @param light A Babylon light built from an export, with `metadata.toolkit`.
6467
+ * @param scene The scene, whose toolkit metadata names the colour space.
6468
+ * @returns True when the colour was converted.
6469
+ */
6470
+ static LinearizeLightColor(light: BABYLON.Light, scene: BABYLON.Scene): boolean;
6450
6471
  /** Keys already warned about, so a per-parse or per-frame code path reports each problem once. */
6451
6472
  private static Warned;
6452
6473
  /**
@@ -6726,6 +6747,17 @@ declare namespace TOOLKIT {
6726
6747
  * not a clamp, brings it to the display.
6727
6748
  */
6728
6749
  static SpecularEnvironmentLevel(reflection: number, units: string, levelMax: number): number;
6750
+ /**
6751
+ * The scale for Unity's ambient probe on a scene environment. A physical environment's level is its sky's normalisation (the sky's
6752
+ * mean luminance), and PBR multiplies the locked SH by that level too, so the probe must carry its inverse or the ambient drops by
6753
+ * the sky's mean. A parity scene does this while it binds the SH, and a relative environment keeps its level. Pure.
6754
+ * @param ambientIntensity The scene's ambient intensity.
6755
+ * @param environmentLevel The environment texture's level, or null when the export has no environment file.
6756
+ * @param units The normalised `environment.units`.
6757
+ * @param isParity True on an HDRP parity scene.
6758
+ * @returns The scale for `generateSphericalHarmonics`.
6759
+ */
6760
+ static EnvironmentAmbientScale(ambientIntensity: number, environmentLevel: number, units: string, isParity: boolean): number;
6729
6761
  /**
6730
6762
  * Warns once when an export marks its sky as baked but carries no environment block (hdrp-sky D19) - the
6731
6763
  * silent failure this feature closed. Returns true when it warned. The skybox fallback still runs.
@@ -6835,7 +6867,7 @@ declare namespace TOOLKIT {
6835
6867
  /** Set once the invisible-light skip is installed, so it is never wrapped twice. */
6836
6868
  _tkSkipInvisible?: boolean;
6837
6869
  /**
6838
- * True while PREWARM's WebGPU pipeline stage draws this map with all its casters (SceneShaderWarmup.DrawPunctualShadowMapsFully):
6870
+ * True while PREWARM's WebGPU pipeline stage draws this map with all its casters (SceneShaderWarmup.DrawShadowMapsFully):
6839
6871
  * the invisible-light skip is bypassed, so a light out of view at the reveal still builds its caster pipelines.
6840
6872
  */
6841
6873
  _tkPrewarmDrawAll?: boolean;
@@ -7072,6 +7104,138 @@ declare namespace TOOLKIT {
7072
7104
  private static ForgetScene;
7073
7105
  }
7074
7106
  }
7107
+ declare namespace TOOLKIT {
7108
+ /** The stage elements on one cover (Babylon clones its loading screen div per canvas or engine view). */
7109
+ interface ILoadingScreenStageView {
7110
+ /** The loading screen div they sit on. */
7111
+ screen: HTMLElement;
7112
+ /** The status line and bar, under the spinner. */
7113
+ stage: HTMLElement;
7114
+ /** The status line. */
7115
+ status: HTMLElement;
7116
+ /** The detail line, bottom right. */
7117
+ details: HTMLElement;
7118
+ /** The bar's fill. */
7119
+ fill: HTMLElement;
7120
+ /** The fill's sliding animation until the first real progress, null when it does not slide. */
7121
+ slide: ReturnType<HTMLElement["animate"]>;
7122
+ }
7123
+ /**
7124
+ * The toolkit's default splash: the status line, bar and detail line, fed by SceneManager.OnLoaderStatusObservable, on a cover of
7125
+ * logo and spinner that is up before the toolkit loads. Two covers carry it. The built-in loading screen
7126
+ * (SceneManager.ShowLoadingScreen, the Playground's showDefaultLoadingScreen) is Babylon's default screen: it counts as the page's
7127
+ * splash (SceneManager.IsSplashScreenShowing), so the reveal waits for it, and SceneManager.HideLoadingScreen ends it through the same
7128
+ * last stages as every splash: PREWARM, Ready, the reveal, the fade. engine.html paints its own cover inline, so the player sees it
7129
+ * while the scripts download, and turns the same showDefaultLoadingScreen flag on: ShowLoadingScreen finds that cover and the stages
7130
+ * take it over. React splash screens and a custom BABYLON.ILoadingScreen are left alone.
7131
+ */
7132
+ class LoadingScreenStages {
7133
+ /** The status line until the first report. */
7134
+ static START_TEXT: string;
7135
+ /** The bar's color. */
7136
+ static BAR_COLOR: string;
7137
+ /** Duration of one slide of the bar before its first real progress, in milliseconds. */
7138
+ static SLIDE_DURATION_MS: number;
7139
+ /** One element per loading screen div while the screen is up. */
7140
+ private static Views;
7141
+ /** The OnLoaderStatusObservable observer while the screen is up. */
7142
+ private static Observer;
7143
+ /** SceneManager.HostDefersSceneStatus before the screen took the status line. */
7144
+ private static PreviousHostDefers;
7145
+ /** The loading state of the bar's last value. */
7146
+ private static BarState;
7147
+ /** The bar's value (0-1), null before the first real progress. */
7148
+ private static BarProgress;
7149
+ /**
7150
+ * Puts the stages on a displayed loading screen and follows the loader status until the screen fades.
7151
+ * @param loadingScreen - The engine's loading screen.
7152
+ * @param marginTop - The stage's distance below the middle of the screen.
7153
+ */
7154
+ static Attach(loadingScreen: any, marginTop: string): void;
7155
+ /**
7156
+ * The cover a page painted before the toolkit loaded (engine.html's #xbabylonjsLoadingDiv). A React splash has its own div of that
7157
+ * name inside #xbabylonjsSplashScreen, and that one is not a cover: React splash screens render their own stages.
7158
+ * @returns The cover, or null when the page has none.
7159
+ */
7160
+ static FindPageCover(): HTMLElement;
7161
+ /**
7162
+ * Puts the stages on a cover the page painted itself (engine.html), which the player has been looking at since the page opened.
7163
+ * @param screen - The cover.
7164
+ * @param marginTop - The stage's distance below the middle of the screen.
7165
+ */
7166
+ static AttachScreen(screen: HTMLElement, marginTop: string): void;
7167
+ /**
7168
+ * Starts the stages on the given covers.
7169
+ * @param covers - One div per canvas or engine view.
7170
+ * @param marginTop - The stage's distance below the middle of the screen.
7171
+ */
7172
+ private static Begin;
7173
+ /**
7174
+ * True while the screen is up and not fading (its hide sets an inline opacity of 0).
7175
+ * @returns False when no screen was attached or it has gone.
7176
+ */
7177
+ static IsShowing(): boolean;
7178
+ /**
7179
+ * The scene that still has to be revealed before the screen can hide.
7180
+ * @param engine - The engine hiding its loading screen.
7181
+ * @returns The engine's last scene, or null when the screen can hide now.
7182
+ */
7183
+ static SceneToReveal(engine: BABYLON.AbstractEngine): BABYLON.Scene;
7184
+ /**
7185
+ * Fades out a cover the page painted itself (AttachScreen) and removes it once it has faded.
7186
+ * @param screen - The cover.
7187
+ */
7188
+ static FadeScreen(screen: HTMLElement): void;
7189
+ /**
7190
+ * The loading state of the bar's last value: from 1 on the toolkit owns the bar, so a page stops posting its own download percent.
7191
+ * @returns The state, -1 before the toolkit's first report.
7192
+ */
7193
+ static GetBarState(): number;
7194
+ /**
7195
+ * Shows one status update on the stages: null fields stay as they are, and the bar only moves forward within one loading state
7196
+ * (the download, state -1, follows the file progress as is). This is what the loader status does, and what a page posts for work
7197
+ * of its own before the scene loads (engine.html: the content download).
7198
+ * @param status - The status line.
7199
+ * @param details - The detail line.
7200
+ * @param progress - The bar, 0-1.
7201
+ * @param state - The loading state.
7202
+ */
7203
+ static ShowStatus(status: string, details: string, progress: number, state: number): void;
7204
+ /** Stops following the loader status. The stage stays on the screen, so it fades with it. */
7205
+ static Detach(removeStages?: boolean): void;
7206
+ /**
7207
+ * Builds the stage elements on one cover.
7208
+ * @param screen - The cover.
7209
+ * @param marginTop - The stage's distance below the middle of the screen.
7210
+ * @returns The view.
7211
+ */
7212
+ private static CreateView;
7213
+ /**
7214
+ * Slides the bar's fill until the first real progress (a full, faint bar for a player who asked for less motion).
7215
+ * @param fill - The fill.
7216
+ * @returns The animation, or null when it does not slide.
7217
+ */
7218
+ private static StartSlide;
7219
+ /**
7220
+ * Follows the loader status until the screen has faded.
7221
+ * @param update - The update.
7222
+ */
7223
+ private static OnLoaderStatus;
7224
+ /**
7225
+ * The bar's value after an update.
7226
+ * @param progress - The update's progress.
7227
+ * @param state - The update's loading state.
7228
+ * @returns The value, or null when the update has no progress.
7229
+ */
7230
+ private static NextBarProgress;
7231
+ /**
7232
+ * Turns an all-capitals line into sentence case (mixed-case text is shown as it is).
7233
+ * @param text - The line.
7234
+ * @returns The text to show.
7235
+ */
7236
+ private static ToSentenceCase;
7237
+ }
7238
+ }
7075
7239
  declare namespace TOOLKIT {
7076
7240
  /**
7077
7241
  * Keeps every material's fragment shader inside the device's texture and sampler limits, on WebGPU and WebGL2, for every
@@ -7496,6 +7660,21 @@ declare namespace TOOLKIT {
7496
7660
  static ShadowMapsRendered(scene: BABYLON.Scene, camera: BABYLON.Camera): boolean;
7497
7661
  /** T12.5: fill the targets by copying the main pass's colour target before its transparents (URP's CopyColorPass). False = re-render the opaque scene (the T12.4 path). */
7498
7662
  static UseCopy: boolean;
7663
+ /** `BABYLON.ConversionMode.None`. */
7664
+ private static readonly COPY_PLAIN;
7665
+ /** `BABYLON.ConversionMode.ToLinearSpace`. */
7666
+ private static readonly COPY_TO_LINEAR;
7667
+ /**
7668
+ * The conversion the copy needs so the target stays linear, as Unity's opaque texture is. A camera without HDR leaves image
7669
+ * processing to the materials (Babylon's LDR chain), so the colour target the copy reads holds display-encoded colour; a graph
7670
+ * that took that for linear reads Scene Color about three times too bright in the shadows. Pure.
7671
+ * @param imageProcessing The scene's image processing configuration, or null.
7672
+ * @returns The conversion mode to pass to `CopyTextureToTexture.copy`.
7673
+ */
7674
+ static CopyConversionFor(imageProcessing: {
7675
+ isEnabled: boolean;
7676
+ applyByPostProcess: boolean;
7677
+ }): number;
7499
7678
  /** Whether a rendering group's transparent queue holds a sub-mesh drawn with one of `materials` (the copy's trigger). Pure. */
7500
7679
  static QueueSamples(subMeshes: any, materials: any): boolean;
7501
7680
  /**
@@ -7509,6 +7688,41 @@ declare namespace TOOLKIT {
7509
7688
  private static CopyNow;
7510
7689
  }
7511
7690
  }
7691
+ declare namespace TOOLKIT {
7692
+ /** The `metadata.urp` scene block (DR-4.6). Its sky and fog keep the `hdrp` block shapes, which the sky code reads untyped. */
7693
+ interface IUrpSceneBlock {
7694
+ version: number;
7695
+ sky?: any;
7696
+ fog?: any;
7697
+ clouds?: any;
7698
+ }
7699
+ /**
7700
+ * One place that answers "which physical sky block does this export carry", so the sky and fog code stays free of pipeline
7701
+ * checks. An HDRP parity export reads `metadata.hdrp`, and a URP export reads `metadata.urp`.
7702
+ */
7703
+ class PhysicalSkyBlock {
7704
+ /** Lowest `urp` block version this runtime reads. */
7705
+ static readonly UrpBlockVersion: number;
7706
+ /**
7707
+ * The scene's `urp` block.
7708
+ * @param metadata - Scene metadata, which is untyped across the toolkit.
7709
+ * @returns The block, or null when the export has none.
7710
+ */
7711
+ static UrpBlock(metadata: any): TOOLKIT.IUrpSceneBlock;
7712
+ /**
7713
+ * The physical sky block of an export.
7714
+ * @param metadata - Scene metadata.
7715
+ * @returns `hdrp.sky` on an HDRP parity export, `urp.sky` on a URP export, otherwise null.
7716
+ */
7717
+ static SkyOf(metadata: any): any;
7718
+ /**
7719
+ * The fog block read by the physical sky's fog pass.
7720
+ * @param metadata - Scene metadata.
7721
+ * @returns `hdrp.fog` on an HDRP parity export, `urp.fog` on a URP export, otherwise null.
7722
+ */
7723
+ static FogOf(metadata: any): any;
7724
+ }
7725
+ }
7512
7726
  /** Babylon Toolkit Namespace */
7513
7727
  declare namespace TOOLKIT {
7514
7728
  /**
@@ -8549,6 +8763,13 @@ declare namespace TOOLKIT {
8549
8763
  * uniform and non-uniform; a game registers its pooled copies).
8550
8764
  */
8551
8765
  static WarmScaleVariantsOnReveal: boolean;
8766
+ /**
8767
+ * False leaves the levels of a native LOD group (Babylon `addLODLevel`) to the camera's distance during the WebGPU pipeline stage: a
8768
+ * level no warm camera selected at the reveal (a stump's LOD1 on a hillside the opening view sees only at LOD0 or culled) then built
8769
+ * its GPU pipeline the first time the game's camera came into its band. True (default) has every frame of the stage select the next
8770
+ * level of every native LOD group in turn (CycleNativeLodLevels), in the main pass and in every shadow map.
8771
+ */
8772
+ static WarmNativeLodLevelsOnReveal: boolean;
8552
8773
  /**
8553
8774
  * Optional units (hidden meshes, render passes) are given up this long (ms) after every required unit is ready and no unit
8554
8775
  * has become ready since, once each was checked: the grace restarts whenever a unit becomes ready, so a queue still finishing
@@ -9405,21 +9626,33 @@ declare namespace TOOLKIT {
9405
9626
  */
9406
9627
  private static RestoreShadowCasterLists;
9407
9628
  /**
9408
- * Makes every point and spot shadow map gated by LightingConversions.SkipInvisiblePunctualShadowMap draw all its casters during
9409
- * the pipeline stage. The gate skips a map whose light is out of view, so on WebGPU a light the camera cannot see at the reveal
9410
- * built no caster pipelines and they compiled the first time it came into view (a late compile mid-race). Each gated map gets
9411
- * `_tkPrewarmDrawAll` (the gate then asks Babylon only), its caster culling list is set aside (Babylon draws the whole
9412
- * renderList), and it renders again on the next frame. Directional maps are left alone. RestorePunctualShadowMaps undoes it.
9629
+ * Makes every shadow map that culls its casters, or whose render is skipped, draw all its casters during the pipeline stage:
9630
+ * - a point or spot map gated by LightingConversions.SkipInvisiblePunctualShadowMap is skipped while its light is out of view, so
9631
+ * on WebGPU a light the camera cannot see at the reveal built no caster pipelines and they compiled the first time it came into
9632
+ * view (a late compile mid-race); it gets `_tkPrewarmDrawAll` (the gate then asks Babylon only);
9633
+ * - a map with one of the toolkit's caster culling lists (HasCasterCullingList: the Unity culling, or the terrain's) drops every
9634
+ * caster outside its pass, so a directional cascade drew only the casters near the opening view and a prop the camera reached
9635
+ * later built its shadow pipeline then (a late pipeline after a camera cut).
9636
+ * Each such map has its caster culling list set aside (Babylon draws the whole renderList) and renders again on the next frame.
9637
+ * RestoreFullShadowMaps undoes it.
9413
9638
  * @param scene - The scene being prewarmed.
9414
- * @returns What was changed, for RestorePunctualShadowMaps.
9639
+ * @returns What was changed, for RestoreFullShadowMaps.
9640
+ */
9641
+ private static DrawShadowMapsFully;
9642
+ /**
9643
+ * True when the shadow map's custom render list is one of the toolkit's caster cullings: LightingConversions.ApplyUnityCasterCulling
9644
+ * marks its function `tkCasterCulling`, and TerrainBuilder.InstallCasterCulling, which wraps it on a scene with terrain, marks
9645
+ * its own `tkTerrainCulling`.
9646
+ * @param shadowMap - The shadow map.
9647
+ * @returns True for a caster-culled map.
9415
9648
  */
9416
- private static DrawPunctualShadowMapsFully;
9649
+ static HasCasterCullingList(shadowMap: BABYLON.RenderTargetTexture): boolean;
9417
9650
  /**
9418
- * Puts back what DrawPunctualShadowMapsFully changed: the draw-all flag is cleared and each map gets its caster culling list
9419
- * back, unless something else installed a list meanwhile.
9420
- * @param draws - What DrawPunctualShadowMapsFully changed.
9651
+ * Puts back what DrawShadowMapsFully changed: the draw-all flag is cleared and each map gets its caster culling list back, unless
9652
+ * something else installed a list meanwhile.
9653
+ * @param draws - What DrawShadowMapsFully changed.
9421
9654
  */
9422
- private static RestorePunctualShadowMaps;
9655
+ private static RestoreFullShadowMaps;
9423
9656
  /** Frames each material of a material variant is drawn for in a row by the pipeline stage (AlternateMaterialVariants). */
9424
9657
  private static readonly MATERIAL_VARIANT_FRAMES;
9425
9658
  /** Per scene: meshes that also draw with another material during play (WarmMaterialVariant). */
@@ -9563,6 +9796,28 @@ declare namespace TOOLKIT {
9563
9796
  * @param draw - What AlternateScaleVariants changed (null: nothing).
9564
9797
  */
9565
9798
  private static RestoreScaleVariants;
9799
+ /**
9800
+ * The meshes a native LOD master can draw (Babylon `addLODLevel`): the master itself, then each level's mesh in order. The cull
9801
+ * band's null level and a mesh listed twice are left out.
9802
+ * @param mesh - Any mesh.
9803
+ * @returns The sequence, or an empty array when the mesh has no LOD levels.
9804
+ */
9805
+ static NativeLodSequence(mesh: BABYLON.AbstractMesh): BABYLON.AbstractMesh[];
9806
+ /**
9807
+ * Makes the frames of the reveal-time pipeline stage select every native LOD level in turn: frame n draws level n modulo the
9808
+ * group's level count for every native LOD master, through `scene.customLODSelector`, which Babylon asks for the main pass and for
9809
+ * every render target (shadow maps included). Without it a level drew only where a warm camera's distance selected it, so a LOD1
9810
+ * the opening view never reached built its GPU pipeline after the reveal. Meshes without levels keep the scene's own selection.
9811
+ * @param scene - The scene being prewarmed.
9812
+ * @returns What to undo (RestoreNativeLodLevels), or null when the scene has no native LOD group or WarmNativeLodLevelsOnReveal is false.
9813
+ */
9814
+ static CycleNativeLodLevels(scene: BABYLON.Scene): TOOLKIT.INativeLodCycle;
9815
+ /**
9816
+ * Ends CycleNativeLodLevels: the scene's own LOD selector is given back, unless something else replaced the cycle's meanwhile.
9817
+ * @param scene - The scene being prewarmed.
9818
+ * @param cycle - What CycleNativeLodLevels changed (null: nothing).
9819
+ */
9820
+ static RestoreNativeLodLevels(scene: BABYLON.Scene, cycle: TOOLKIT.INativeLodCycle): void;
9566
9821
  /**
9567
9822
  * Forces (or stops forcing) each mesh's other scaling state. While forced, the mesh's own `_updateNonUniformScalingState` property
9568
9823
  * keeps the other state through the frame's world-matrix updates (and the state is set at once for a mesh whose matrix is not
@@ -9657,6 +9912,7 @@ declare namespace TOOLKIT {
9657
9912
  * @param deadline - SceneShaderWarmup.NowMs() after which the stage stops waiting.
9658
9913
  * @param phases - The camera phases, in order; null draws the game's own camera(s).
9659
9914
  * @param onProgress - Called after each frame with the compiled and requested pipeline counts.
9915
+ * @param settleFrames - Consecutive quiet frames that end a phase (a LOD cycle needs one full cycle; default PIPELINE_SETTLE_FRAMES).
9660
9916
  * @returns Resolves true when the deadline passed before every phase was quiet.
9661
9917
  */
9662
9918
  private static WaitForPipelinesPerCamera;
@@ -9673,8 +9929,9 @@ declare namespace TOOLKIT {
9673
9929
  */
9674
9930
  private static RunCameraPhasesAsync;
9675
9931
  /**
9676
- * Renders frames (the render loop keeps running) until the scene's draws request no new pipeline for PIPELINE_SETTLE_FRAMES
9677
- * frames and none is still compiling, or the deadline passes. Reports `onProgress(compiled, requested)` after each frame.
9932
+ * Renders frames (the render loop keeps running) until the scene's draws request no new pipeline for `settleFrames` consecutive
9933
+ * frames (default PIPELINE_SETTLE_FRAMES) and none is still compiling, or the deadline passes. Reports `onProgress(compiled,
9934
+ * requested)` after each frame.
9678
9935
  */
9679
9936
  private static WaitForPipelines;
9680
9937
  /**
@@ -10392,6 +10649,21 @@ declare namespace TOOLKIT {
10392
10649
  /** The frame observer that switches the variant. */
10393
10650
  frameObserver: BABYLON.Observer<BABYLON.Scene>;
10394
10651
  }
10652
+ /** @hidden The native LOD selection the reveal-time pipeline stage forces in turn (CycleNativeLodLevels). */
10653
+ interface INativeLodCycle {
10654
+ /** Each native LOD master and the meshes it can draw, master first (NativeLodSequence). */
10655
+ sequences: Map<BABYLON.AbstractMesh, BABYLON.AbstractMesh[]>;
10656
+ /** The longest sequence: the frames one full cycle takes. */
10657
+ length: number;
10658
+ /** Frames drawn since the cycle began; frame n selects level n modulo a sequence's length. */
10659
+ frameIndex: number;
10660
+ /** The scene's own LOD selector, given back by RestoreNativeLodLevels (null when it had none). */
10661
+ previousSelector: (mesh: BABYLON.AbstractMesh, camera: BABYLON.Camera) => BABYLON.Nullable<BABYLON.AbstractMesh>;
10662
+ /** The selector the cycle installed. */
10663
+ selector: (mesh: BABYLON.AbstractMesh, camera: BABYLON.Camera) => BABYLON.Nullable<BABYLON.AbstractMesh>;
10664
+ /** The frame observer that advances frameIndex. */
10665
+ frameObserver: BABYLON.Observer<BABYLON.Scene>;
10666
+ }
10395
10667
  /** @hidden A hidden particle emitter the particle stage lets draw (ShowHiddenEmittersForDraws). */
10396
10668
  interface IHiddenEmitterDraw {
10397
10669
  /** The emitter node. */
@@ -10452,6 +10724,13 @@ declare namespace TOOLKIT {
10452
10724
  }
10453
10725
  /** @hidden A render target's custom render list (RenderTargetTexture.getCustomRenderList). */
10454
10726
  type CustomRenderListFunction = (layerOrFace: number, renderList: readonly BABYLON.AbstractMesh[], renderListLength: number) => BABYLON.AbstractMesh[];
10727
+ /** @hidden The marks the toolkit's caster culling lists carry on their function (SceneShaderWarmup.HasCasterCullingList). */
10728
+ interface ICasterCullingListMarks {
10729
+ /** Set by LightingConversions.ApplyUnityCasterCulling. */
10730
+ tkCasterCulling?: boolean;
10731
+ /** Set by TerrainBuilder.InstallCasterCulling. */
10732
+ tkTerrainCulling?: boolean;
10733
+ }
10455
10734
  /** @hidden A shadow map whose custom render list the reveal-time pipeline stage wrapped (KeepHiddenCastersInShadowMaps). */
10456
10735
  interface IShadowCasterListWrap {
10457
10736
  /** The shadow map. */
@@ -10461,8 +10740,8 @@ declare namespace TOOLKIT {
10461
10740
  /** The wrapper that keeps the shown hidden casters. */
10462
10741
  keptList: TOOLKIT.CustomRenderListFunction;
10463
10742
  }
10464
- /** @hidden A point or spot shadow map the reveal-time pipeline stage draws with all its casters (DrawPunctualShadowMapsFully). */
10465
- interface IPunctualShadowMapDraw {
10743
+ /** @hidden A gated or caster-culled shadow map the reveal-time pipeline stage draws with all its casters (DrawShadowMapsFully). */
10744
+ interface IShadowMapFullDraw {
10466
10745
  /** The shadow map. */
10467
10746
  shadowMap: BABYLON.RenderTargetTexture;
10468
10747
  /** Its caster culling list, set aside during the stage. */
@@ -11630,6 +11909,17 @@ declare namespace TOOLKIT {
11630
11909
  smoothDeltaTime: number;
11631
11910
  frame: number;
11632
11911
  }
11912
+ /** One shader global component advanced every frame by scene time, for values Unity's scripts drive at runtime. */
11913
+ interface IShaderGlobalDriver {
11914
+ /** The global's Unity reference name. */
11915
+ name: string;
11916
+ /** The vector component advanced: 0 x, 1 y, 2 z, 3 w. */
11917
+ component: number;
11918
+ /** Units per second. */
11919
+ rate: number;
11920
+ /** The value is wrapped by subtracting this when it passes it. Zero means no wrap. */
11921
+ wrap: number;
11922
+ }
11633
11923
  /**
11634
11924
  * Unity's shader globals for transpiled Shader Graph classes (shadergraph-transpiler-complete-coverage D16, D18).
11635
11925
  *
@@ -11648,6 +11938,8 @@ declare namespace TOOLKIT {
11648
11938
  * generated material of a scene animates in lockstep.
11649
11939
  */
11650
11940
  class ShaderGlobals {
11941
+ /** The Vector4 member each `IShaderGlobalDriver.component` index names. */
11942
+ private static readonly DriverComponentNames;
11651
11943
  private static _version;
11652
11944
  private static _floats;
11653
11945
  private static _vectors;
@@ -11681,6 +11973,19 @@ declare namespace TOOLKIT {
11681
11973
  * scene's first frame.
11682
11974
  */
11683
11975
  static LoadSceneGlobals(scene: BABYLON.Scene, block: any): void;
11976
+ /**
11977
+ * Advances exported shader globals every frame, so a value Unity's scripts drive at runtime keeps moving in the browser.
11978
+ * Adds one observer per scene, and only when the export lists a driver.
11979
+ * @param scene - The scene whose clock drives the values.
11980
+ * @param drivers - The exported drivers, or null.
11981
+ */
11982
+ static LoadSceneDrivers(scene: BABYLON.Scene, drivers: TOOLKIT.IShaderGlobalDriver[]): void;
11983
+ /**
11984
+ * Advances one driver in place. The stored Vector4 is mutated, so a frame allocates nothing. Bumps the version.
11985
+ * @param driver - The driver to advance.
11986
+ * @param deltaSeconds - Seconds since the last frame.
11987
+ */
11988
+ private static AdvanceDriver;
11684
11989
  /** The scene clock (registered on first use, removed when the scene is disposed). */
11685
11990
  static GetClock(scene: BABYLON.Scene): TOOLKIT.IShaderClock;
11686
11991
  }
@@ -12028,6 +12333,15 @@ declare namespace TOOLKIT {
12028
12333
  static ApplyInstanceBlock(instance: BABYLON.InstancedMesh, block: any, sub?: number): boolean;
12029
12334
  /** The clone of one material with a property block applied (null when the material is not a toolkit custom material). */
12030
12335
  static CloneWithBlock(material: BABYLON.Material, block: any, meshId: number, loadTexture?: (info: any, done: (texture: BABYLON.BaseTexture) => void) => void): BABYLON.Material;
12336
+ /**
12337
+ * Keeps the exporter's "not carried" list for the scene summary. Schedules the summary itself,
12338
+ * so a scene with no graph material still prints it.
12339
+ * @param scene - The scene the export belongs to.
12340
+ * @param entries - The `exportreport` metadata list; absent or empty when the export lost nothing.
12341
+ */
12342
+ static RecordExportReport(scene: BABYLON.Scene, entries: TOOLKIT.IExportReportEntry[]): void;
12343
+ /** Prints the exporter's list as one collapsed group, then forgets it so a later flush does not repeat it. */
12344
+ private static PrintExportReport;
12031
12345
  /** One warning for the missing classes, then one console.groupCollapsed per scene; clears the record. */
12032
12346
  static FlushSceneSummary(scene: BABYLON.Scene): void;
12033
12347
  }
@@ -12051,6 +12365,19 @@ declare namespace TOOLKIT {
12051
12365
  /** T32.1: the pending quiet-period timer and its latest flush time. */
12052
12366
  timer?: any;
12053
12367
  deadline?: number;
12368
+ /** The exporter's "not carried" list, until the summary prints it. */
12369
+ exportReport?: IExportReportEntry[];
12370
+ }
12371
+ /** One line of `metadata.exportreport`: something the export could not carry to the browser. */
12372
+ interface IExportReportEntry {
12373
+ /** The report group, such as `Renderer features`. */
12374
+ feature: string;
12375
+ /** Why the items do not reach the browser. */
12376
+ reason: string;
12377
+ /** Every distinct item name. */
12378
+ items: string[];
12379
+ /** How many times the exporter met this, which can exceed `items.length`. */
12380
+ count: number;
12054
12381
  }
12055
12382
  /**
12056
12383
  * shadergraph-transpiler-complete-coverage X2: the ShadowDepthWrapper of a graph class that casts through its own shader
@@ -12691,7 +13018,8 @@ declare namespace TOOLKIT {
12691
13018
  * 80-99 %, Ready 100 % (LOADING_SHARE, SHADERS_SHARE) - that only moves forward, glides toward the real progress and creeps slowly
12692
13019
  * while work is pending, so it never sits still or jumps. While SceneManager.PrecompileShaders is false Loading Scene is the only
12693
13020
  * headline before Ready, so its band is the whole bar and the loads' own stages fill it (LOADED_SHARE_WITHOUT_PRECOMPILE).
12694
- * Both page splash screens show it: engine.html and the React splash read SceneManager.OnLoaderStatusObservable.
13021
+ * Every splash screen shows it through SceneManager.OnLoaderStatusObservable: the default splash (LoadingScreenStages, on engine.html
13022
+ * and the built-in loading screen) and the React splash.
12695
13023
  */
12696
13024
  class SplashNarrator {
12697
13025
  /** Every report the narrator receives, before it chooses what to show (tests and host pages that want the raw detail). */
@@ -13984,10 +14312,18 @@ declare namespace TOOLKIT {
13984
14312
  static readonly FADE_SPEEDTREE: number;
13985
14313
  /** Unity's LODGroup.crossFadeAnimationDuration default (the terrain trees use the same, TerrainTrees.FADE_SECONDS). */
13986
14314
  static FADE_SECONDS: number;
14315
+ /** Largest offset, in meters, at which a level still draws correctly with its master's world matrix. */
14316
+ static readonly NATIVE_TRANSFORM_TOLERANCE_METERS: number;
14317
+ /** Largest difference in one rotation or scale matrix element between a level and its master. */
14318
+ static readonly NATIVE_BASIS_TOLERANCE: number;
14319
+ /** The indices of a matrix's rotation and scale elements. */
14320
+ private static readonly BASIS_ELEMENTS;
13987
14321
  /**
13988
14322
  * H-a: the group's world size and local reference point from the exported `lodsize` (LODGroup.size, local) and
13989
- * `lodcenter` (LODGroup.localReferencePoint in the node's glTF local space). Unity's world size is the size times
13990
- * the largest absolute lossy scale. Null when the export has neither (older exports: the mesh boxes are used).
14323
+ * `lodcenter` (LODGroup.localReferencePoint with its x negated). The node's world matrix takes Unity's local axes, so
14324
+ * x is negated back here: the world point then equals Unity's `transform.TransformPoint(localReferencePoint)`.
14325
+ * Unity's world size is the size times the largest absolute lossy scale. Null when the export has neither (older
14326
+ * exports: the mesh boxes are used).
13991
14327
  */
13992
14328
  static ExportedSize(root: BABYLON.TransformNode, metadata: any): {
13993
14329
  worldSize: number;
@@ -13998,6 +14334,32 @@ declare namespace TOOLKIT {
13998
14334
  useDistances: boolean;
13999
14335
  thresholds: number[];
14000
14336
  };
14337
+ /**
14338
+ * Whether every level can be drawn by Babylon's native LOD, which draws a detail level with its master's world
14339
+ * matrix and ignores the detail's own. Levels authored with different pivots must use the shared switcher, or they
14340
+ * appear displaced by the difference. Reads each node's own matrix, so a mesh that is already a detail level is
14341
+ * judged by its own transform too.
14342
+ * @param master The LOD0 mesh.
14343
+ * @param details The lower levels' meshes.
14344
+ * @returns True when each detail's world transform matches the master's within the tolerances.
14345
+ */
14346
+ static LevelsShareTransform(master: BABYLON.AbstractMesh, details: BABYLON.AbstractMesh[]): boolean;
14347
+ /**
14348
+ * Whether two world matrices place a mesh at the same spot within the native tolerances.
14349
+ * @param first One world matrix.
14350
+ * @param second The other world matrix.
14351
+ * @returns True when their translations and their rotation and scale elements match.
14352
+ */
14353
+ private static MatricesShareTransform;
14354
+ /**
14355
+ * Whether a group must run on the shared switcher instead of Babylon's native LOD, on either native entry point
14356
+ * (coverages or the legacy distances): it cross-fades, a level has several renderers, or a level sits away from
14357
+ * LOD0's world transform. Instanced masters answer like any other: their legacy handling stays with the caller.
14358
+ * @param meshLevels The resolved meshes of each level, LOD0 first.
14359
+ * @param fadeMode The group's FADE_* mode.
14360
+ * @returns True when only the switcher can draw the group as authored.
14361
+ */
14362
+ static RequiresSwitcher(meshLevels: BABYLON.AbstractMesh[][], fadeMode: number): boolean;
14001
14363
  /** Exported fade mode name => FADE_*. */
14002
14364
  static ParseFadeMode(mode: string): number;
14003
14365
  /** Scene-wide QualitySettings.lodBias (the exported `lodbias`, 1 when absent). */
@@ -14058,7 +14420,10 @@ declare namespace TOOLKIT {
14058
14420
  * group culls below the last coverage, and an orthographic camera (whose Babylon LOD distance is minZ) gets
14059
14421
  * 0 / 1e30 thresholds that pick Unity's distance-independent level. They are recomputed only when the camera,
14060
14422
  * its fov / fov mode / aspect / projection / ortho size, or the LOD bias change.
14061
- * `details[k - 1]` is level k's mesh. Returns false (nothing registered) when the levels cannot be native.
14423
+ * `details[k - 1]` is level k's mesh. Returns false (nothing registered) when the levels cannot be native: a level
14424
+ * authored away from LOD0 (LevelsShareTransform), or a master with instances. An InstancedMesh follows its source's
14425
+ * LOD levels while the switcher toggles that same instance, so such a master joins its instances on the switcher and
14426
+ * every level has one owner.
14062
14427
  */
14063
14428
  addNativeGroup(master: BABYLON.Mesh, details: BABYLON.Mesh[], coverages: number[], worldSize: number): boolean;
14064
14429
  get nativeGroupCount(): number;
@@ -34595,129 +34960,6 @@ declare namespace PROJECT {
34595
34960
  bindForSubMesh(uniformBuffer: BABYLON.UniformBuffer, scene: BABYLON.Scene, engine: BABYLON.AbstractEngine, subMesh: BABYLON.SubMesh): void;
34596
34961
  }
34597
34962
  }
34598
- declare namespace PROJECT {
34599
- /**
34600
- * Babylon toolkit default camera system class
34601
- * @class DefaultCameraSystem - All rights reserved (c) 2020 Mackey Kinard
34602
- * @deprecated This class is considered legacy and may be removed in future versions.
34603
- */
34604
- class DefaultCameraSystem extends TOOLKIT.ScriptComponent {
34605
- protected static PlayerOneCamera: BABYLON.FreeCamera;
34606
- protected static PlayerTwoCamera: BABYLON.FreeCamera;
34607
- protected static PlayerThreeCamera: BABYLON.FreeCamera;
34608
- protected static PlayerFourCamera: BABYLON.FreeCamera;
34609
- protected static XRExperienceHelper: BABYLON.WebXRDefaultExperience;
34610
- private static multiPlayerView;
34611
- private static multiPlayerCount;
34612
- private static multiPlayerCameras;
34613
- private static stereoCameras;
34614
- private static startupMode;
34615
- private static cameraReady;
34616
- private static cameraInstance;
34617
- static IsCameraSystemReady(): boolean;
34618
- /** Register handler that is triggered when the webxr experience helper has been created */
34619
- static OnXRExperienceHelperObservable: BABYLON.Observable<BABYLON.WebXRDefaultExperience>;
34620
- /** Default Follow Speed */
34621
- static FOLLOW_SPEED: number;
34622
- private mainCamera;
34623
- private cameraType;
34624
- private cameraInertia;
34625
- private cameraController;
34626
- private immersiveOptions;
34627
- private arcRotateConfig;
34628
- private multiPlayerSetup;
34629
- private fullScreenToggle;
34630
- private setPointerLock;
34631
- private setCameraTarget;
34632
- private setSpatialAudio;
34633
- protected m_cameraRig: BABYLON.TargetCamera;
34634
- isMainCamera(): boolean;
34635
- getCameraType(): number;
34636
- getTargetTransform(): BABYLON.TransformNode;
34637
- setTargetTransform(target: BABYLON.TransformNode): void;
34638
- enableSpatialAudio(value: boolean): void;
34639
- constructor(transform: BABYLON.TransformNode, scene: BABYLON.Scene, properties?: any, alias?: string);
34640
- protected awake(): void;
34641
- protected start(): void;
34642
- protected update(): void;
34643
- protected destroy(): void;
34644
- protected awakeCameraSystemState(): void;
34645
- protected startCameraSystemState(): Promise<void>;
34646
- protected updateCameraSystemState(): void;
34647
- protected cleanCameraSystemState(): void;
34648
- protected destroyCameraSystemState(): void;
34649
- /*********************************************/
34650
- /** Follow Target Camera Controller Helpers */
34651
- /*********************************************/
34652
- targetCameraOffset: BABYLON.Vector3;
34653
- getCameraPivotPosition(): BABYLON.Vector3;
34654
- getCameraPivotRotation(): BABYLON.Quaternion;
34655
- getCameraBoomNode(): BABYLON.TransformNode;
34656
- getCameraTransform(): BABYLON.TransformNode;
34657
- private cameraNode;
34658
- private cameraPivot;
34659
- private cameraDistance;
34660
- private cameraPivotOffset;
34661
- private cameraBoomPosition;
34662
- private dollyDirection;
34663
- private rotationEulers;
34664
- private scaledCamDirection;
34665
- private scaledMaxDirection;
34666
- private parentNodePosition;
34667
- private maximumCameraPos;
34668
- private cameraRaycastShape;
34669
- private targetRotationVector;
34670
- private resetCameraRotation;
34671
- private updateCameraController;
34672
- getBoomArmMaxDistance(): number;
34673
- setBoomArmMaxDistance(distance: number): void;
34674
- setSmoothBoomArmLength(length: number, speed: number, updateMaxDistance?: boolean): void;
34675
- private smoothBoomArmLength;
34676
- private smoothBoomArmSpeed;
34677
- private updateSmoothBoomArmLength;
34678
- static EnableTracking(value: boolean): void;
34679
- static IsTrackingEnabled(): boolean;
34680
- static SetAutoUpdate(value: boolean): void;
34681
- static IsAutoUpdateEnabled(): boolean;
34682
- static GetFollowTarget(): BABYLON.TransformNode;
34683
- static SetFollowTarget(target: BABYLON.TransformNode): void;
34684
- static ResetFollowTarget(): void;
34685
- static UpdateFollowTarget(): void;
34686
- /** Get the WebXR default experience helper */
34687
- static GetWebXR(): BABYLON.WebXRDefaultExperience;
34688
- /** Is universal camera system in WebXR mode */
34689
- static IsInWebXR(): boolean;
34690
- /** Setup navigation mesh for WebXR */
34691
- private static SetupNavigationWebXR;
34692
- /** Get main camera rig for the scene */
34693
- static GetMainCamera(scene: BABYLON.Scene, detach?: boolean): BABYLON.FreeCamera;
34694
- /** Get universal camera rig for desired player */
34695
- static GetPlayerCamera(scene: BABYLON.Scene, player?: TOOLKIT.PlayerNumber, detach?: boolean): BABYLON.FreeCamera;
34696
- /** Get camera transform node for desired player */
34697
- static GetCameraTransform(scene: BABYLON.Scene, player?: TOOLKIT.PlayerNumber): BABYLON.TransformNode;
34698
- /** Are stereo side side camera services available. */
34699
- static IsStereoCameras(): boolean;
34700
- /** Are local multi player view services available. */
34701
- static IsMultiPlayerView(): boolean;
34702
- /** Get the current local multi player count */
34703
- static GetMultiPlayerCount(): number;
34704
- /** Activates current local multi player cameras. */
34705
- static ActivateMultiPlayerCameras(scene: BABYLON.Scene): boolean;
34706
- /** Disposes current local multiplayer cameras */
34707
- static DisposeMultiPlayerCameras(): void;
34708
- /** Sets the multi player camera view layout */
34709
- static SetMultiPlayerViewLayout(scene: BABYLON.Scene, totalNumPlayers: number): boolean;
34710
- }
34711
- /*********************************************/
34712
- /** Camera Editor Properties Support Classes */
34713
- /*********************************************/
34714
- interface IEditorArcRtotate {
34715
- alpha: number;
34716
- beta: number;
34717
- radius: number;
34718
- target: TOOLKIT.IUnityVector3;
34719
- }
34720
- }
34721
34963
  declare namespace PROJECT {
34722
34964
  /**
34723
34965
  * Babylon Script Component
@@ -34921,811 +35163,6 @@ declare namespace PROJECT {
34921
35163
  protected destroy(): void;
34922
35164
  }
34923
35165
  }
34924
- declare namespace PROJECT {
34925
- /**
34926
- * Babylon Script Component (LEGACY)
34927
- * @class RemotePlayerController
34928
- * @deprecated This class is considered legacy and may be removed in future versions.
34929
- */
34930
- class RemotePlayerController extends TOOLKIT.ScriptComponent {
34931
- updateStateParams: boolean;
34932
- smoothMotionTime: number;
34933
- smoothInputVectors: boolean;
34934
- private animator;
34935
- private animationStateParams;
34936
- constructor(transform: BABYLON.TransformNode, scene: BABYLON.Scene, properties?: any, alias?: string);
34937
- protected awake(): void;
34938
- protected update(): void;
34939
- protected destroy(): void;
34940
- /** Finds the remote player's `TOOLKIT.Animator`, on this node or on the first child that carries one. */
34941
- private attachAnimationController;
34942
- private validateAnimationStateParams;
34943
- }
34944
- }
34945
- declare namespace PROJECT {
34946
- /**
34947
- * Babylon toolkit standard player controller class (LEGACY)
34948
- * @class StandardPlayerController - All rights reserved (c) 2020 Mackey Kinard
34949
- * @deprecated This class is considered legacy and may be removed in future versions.
34950
- */
34951
- class StandardPlayerController extends TOOLKIT.ScriptComponent {
34952
- static MIN_VERTICAL_VELOCITY: number;
34953
- static MIN_GROUND_DISTANCE: number;
34954
- static MIN_MOVE_EPSILON: number;
34955
- static MIN_TIMER_OFFSET: number;
34956
- static MIN_SLOPE_LIMIT: number;
34957
- static PLAYER_HEIGHT: string;
34958
- enableInput: boolean;
34959
- attachCamera: boolean;
34960
- rotateCamera: boolean;
34961
- mouseWheel: boolean;
34962
- toggleView: boolean;
34963
- freeLooking: boolean;
34964
- requireSprintButton: boolean;
34965
- gravitationalForce: number;
34966
- minFallVelocity: number;
34967
- verticalStepSpeed: number;
34968
- minStepUpHeight: number;
34969
- rigidBodyMass: number;
34970
- airbornTimeout: number;
34971
- maxAngle: number;
34972
- speedFactor: number;
34973
- rootMotion: boolean;
34974
- moveSpeed: number;
34975
- walkSpeed: number;
34976
- lookSpeed: number;
34977
- jumpSpeed: number;
34978
- jumpDelay: number;
34979
- eyesHeight: number;
34980
- pivotHeight: number;
34981
- maxDistance: number;
34982
- scrollSpeed: number;
34983
- topLookLimit: number;
34984
- downLookLimit: number;
34985
- lowTurnSpeed: number;
34986
- highTurnSpeed: number;
34987
- smoothDampTime: number;
34988
- smoothInputVectors: boolean;
34989
- smoothAcceleration: boolean;
34990
- accelerationSpeed: number;
34991
- decelerationSpeed: number;
34992
- avatarSkinTag: string;
34993
- climbVolumeTag: string;
34994
- vaultVolumeTag: string;
34995
- maxHeightRanges: any;
34996
- useClimbSystem: boolean;
34997
- distanceFactor: number;
34998
- cameraSmoothing: number;
34999
- cameraCollisions: boolean;
35000
- inputMagnitude: number;
35001
- /** Unity StarterAssetsInputs.analogMovement: true drives the MotionSpeed parameter with the input magnitude (gamepad sticks), false keeps it at 1 (keyboard). */
35002
- analogMovement: boolean;
35003
- landingEpsilon: number;
35004
- minimumDistance: number;
35005
- movementAllowed: boolean;
35006
- playerInputX: number;
35007
- playerInputZ: number;
35008
- playerMouseX: number;
35009
- playerMouseY: number;
35010
- runKeyRequired: boolean;
35011
- buttonRun: number;
35012
- keyboardRun: number;
35013
- buttonJump: number;
35014
- keyboardJump: number;
35015
- buttonCamera: number;
35016
- keyboardCamera: number;
35017
- postNetworkAttributes: boolean;
35018
- playerNumber: TOOLKIT.PlayerNumber;
35019
- boomPosition: BABYLON.Vector3;
35020
- airbornVelocity: BABYLON.Vector3;
35021
- movementVelocity: BABYLON.Vector3;
35022
- targetCameraOffset: BABYLON.Vector3;
35023
- isAnimationEnabled(): boolean;
35024
- isRunButtonPressed(): boolean;
35025
- isJumpButtonPressed(): boolean;
35026
- getPlayerJumped(): boolean;
35027
- getPlayerJumping(): boolean;
35028
- getPlayerFalling(): boolean;
35029
- getPlayerSliding(): boolean;
35030
- getPlayerGrounded(): boolean;
35031
- getFallTriggered(): boolean;
35032
- getMovementSpeed(): number;
35033
- getCameraBoomNode(): BABYLON.TransformNode;
35034
- getCameraTransform(): BABYLON.TransformNode;
35035
- getAnimator(): TOOLKIT.Animator;
35036
- getVerticalVelocity(): number;
35037
- getCharacterController(): TOOLKIT.CharacterController;
35038
- getPlayerLookRotation(): BABYLON.Vector3;
35039
- getPlayerMoveDirection(): PROJECT.PlayerMoveDirection;
35040
- getInputMovementVector(): BABYLON.Vector3;
35041
- getInputMagnitudeValue(): number;
35042
- getCameraPivotPosition(): BABYLON.Vector3;
35043
- getCameraPivotRotation(): BABYLON.Quaternion;
35044
- rayClimbOffset: number;
35045
- rayClimbLength: number;
35046
- getClimbContact(): boolean;
35047
- getClimbContactNode(): BABYLON.TransformNode;
35048
- getClimbContactPoint(): BABYLON.Vector3;
35049
- getClimbContactAngle(): number;
35050
- getClimbContactNormal(): BABYLON.Vector3;
35051
- getClimbContactDistance(): number;
35052
- canClimbObstaclePredicate: (action: number) => boolean;
35053
- rayHeightOffset: number;
35054
- rayHeightLength: number;
35055
- getHeightContact(): boolean;
35056
- getHeightContactNode(): BABYLON.TransformNode;
35057
- getHeightContactPoint(): BABYLON.Vector3;
35058
- getHeightContactAngle(): number;
35059
- getHeightContactNormal(): BABYLON.Vector3;
35060
- getHeightContactDistance(): number;
35061
- private abstractMesh;
35062
- private cameraDistance;
35063
- private forwardCamera;
35064
- private avatarRadius;
35065
- private groundingObject;
35066
- private groundingCallback;
35067
- private dollyDirection;
35068
- private cameraEulers;
35069
- private rotationEulers;
35070
- private cameraPivotOffset;
35071
- private cameraForwardVector;
35072
- private cameraRightVector;
35073
- private desiredForwardVector;
35074
- private desiredRightVector;
35075
- private lastRotationQuaternion;
35076
- private scaledCamDirection;
35077
- private scaledMaxDirection;
35078
- private parentNodePosition;
35079
- private maximumCameraPos;
35080
- private tempWorldPosition;
35081
- private cameraRaycastShape;
35082
- private defaultRaycastGroup;
35083
- private defaultRaycastMask;
35084
- private cameraRaycastMask;
35085
- private avatarSkins;
35086
- private cameraNode;
35087
- private cameraPivot;
35088
- private navigationAgent;
35089
- private characterController;
35090
- private verticalVelocity;
35091
- private smoothMotionSpeed;
35092
- private movementSpeed;
35093
- private isRunPressed;
35094
- private isJumpPressed;
35095
- private isCharacterSliding;
35096
- private isCharacterFalling;
35097
- private isCharacterGrounded;
35098
- private isCharacterFallTriggered;
35099
- private isCharacterJumpFrame;
35100
- private isCharacterJumping;
35101
- private isCharacterLanding;
35102
- private isCharacterRising;
35103
- private isCharacterNavigating;
35104
- private navigationAngularSpeed;
35105
- private updateStateParams;
35106
- private animationStateParams;
35107
- private sphereCollisionShape;
35108
- private hasGroundedContact;
35109
- private showDebugColliders;
35110
- private colliderVisibility;
35111
- private colliderRenderGroup;
35112
- private groundCheckDistance;
35113
- private deltaTime;
35114
- private minJumpTimer;
35115
- private delayJumpTimer;
35116
- private playerControl;
35117
- private canPlayerJump;
35118
- private animator;
35119
- private lastJumpVelocity;
35120
- private inputMovementVector;
35121
- private playerLookRotation;
35122
- private playerRotationVector;
35123
- private playerMovementVelocity;
35124
- private playerRotationQuaternion;
35125
- private playerMoveDirection;
35126
- private forwardDirection;
35127
- private downDirection;
35128
- private climbContact;
35129
- private climbContactNode;
35130
- private climbContactAngle;
35131
- private climbContactPoint;
35132
- private climbContactNormal;
35133
- private climbContactDistance;
35134
- private climbSensorLine;
35135
- private offsetClimbRaycastPosition;
35136
- private startClimbRaycastPosition;
35137
- private endClimbRaycastPosition;
35138
- private heightContact;
35139
- private heightContactNode;
35140
- private heightContactAngle;
35141
- private heightContactPoint;
35142
- private heightContactNormal;
35143
- private heightContactDistance;
35144
- private heightSensorLine;
35145
- private offsetHeightRaycastPosition;
35146
- private startHeightRaycastPosition;
35147
- private endHeightRaycastPosition;
35148
- protected m_velocityOffset: BABYLON.Vector3;
35149
- protected m_actualVelocity: BABYLON.Vector3;
35150
- protected m_linearVelocity: BABYLON.Vector3;
35151
- protected m_lastPosition: BABYLON.Vector3;
35152
- protected m_positionCenter: BABYLON.Vector3;
35153
- protected m_scaledVelocity: number;
35154
- protected playerDrawVelocity: number;
35155
- constructor(transform: BABYLON.TransformNode, scene: BABYLON.Scene, properties?: any, alias?: string);
35156
- protected awake(): void;
35157
- protected start(): void;
35158
- protected after(): void;
35159
- protected update(): void;
35160
- protected destroy(): void;
35161
- /** Register handler that is triggered before the controller has been updated */
35162
- onPreUpdateObservable: BABYLON.Observable<BABYLON.TransformNode>;
35163
- /** Register handler that is triggered before the controller movement has been applied */
35164
- onBeforeMoveObservable: BABYLON.Observable<BABYLON.TransformNode>;
35165
- /** Register handler that is triggered after the controller has been updated */
35166
- onPostUpdateObservable: BABYLON.Observable<BABYLON.TransformNode>;
35167
- /** Register handler that is triggered after player input has been updated */
35168
- onPlayerInputObservable: BABYLON.Observable<BABYLON.TransformNode>;
35169
- /** Register handler that is triggered when player position should be updated */
35170
- onPlayerPositionObservable: BABYLON.Observable<BABYLON.TransformNode>;
35171
- /** Register handler that is triggered after performing action has been updated */
35172
- onUpdateActionObservable: BABYLON.Observable<BABYLON.TransformNode>;
35173
- /** Observer on the Animator's `onAnimatorMoveObservable` while this controller takes root motion (D19, D20); null otherwise. */
35174
- private animatorMoveObserver;
35175
- /** The Animator's exported `applyRootMotion`, restored when this controller stops taking root motion. */
35176
- private exportedApplyRootMotion;
35177
- /** The last Animator tick's horizontal root-motion velocity (world, metres per second), moved by the character controller when `rootMotion` is on. */
35178
- private readonly rootMotionVelocity;
35179
- /**
35180
- * Registers the `onAnimatorMoveObservable` taker while root motion drives the player (`rootMotion` locomotion or a
35181
- * root-motion action) and removes it otherwise. The Animator may sit on a child model node, so the taker moves this
35182
- * player node rather than letting the built-in path move the model (D19, D20, D29).
35183
- */
35184
- private syncAnimatorMoveTaker;
35185
- /**
35186
- * The `onAnimatorMove` taker: a root-motion action moves and turns the player node; otherwise the horizontal root
35187
- * velocity is kept for the character controller's next move.
35188
- * @param animator The Animator that ticked.
35189
- */
35190
- private onAnimatorMove;
35191
- private isPerformingAction;
35192
- private isRootMotionAction;
35193
- private isActionInterruptable;
35194
- private afterActionHandler;
35195
- private performActionTimer;
35196
- private performActionNumber;
35197
- private playerRotationSpeed;
35198
- private rotatePlayerTowards;
35199
- private matchStartTime;
35200
- private matchTargetTime;
35201
- private matchTargetOffset;
35202
- private matchTargetHeight;
35203
- private lockTargetHeight;
35204
- private lastStartHeight;
35205
- private lastTargetHeight;
35206
- private lastTargetNormal;
35207
- private lastTargetRotation;
35208
- private lastDeltaPosition;
35209
- private lastDeltaRotation;
35210
- /** The eased player height of the height match (world metres). */
35211
- private smoothedPlayerHeight;
35212
- /** The SmoothDamp velocity of the height match (`x` holds it). */
35213
- private readonly playerHeightVelocity;
35214
- /** Full path hash of the base-layer state the running action entered; valid while `actionStateEntered`. */
35215
- private actionStateHash;
35216
- /** True once the running action's state was entered, so its exit ends the action. */
35217
- private actionStateEntered;
35218
- getIsPerformingAction(): boolean;
35219
- getIsRootMotionAction(): boolean;
35220
- getIsActionInterruptable(): boolean;
35221
- playActionAnimation(action: number, interruptableAction?: boolean, enableRootMotion?: boolean, afterActionComplete?: () => void): void;
35222
- resetActionAnimationState(): void;
35223
- /** Advances the action timer that drives the height match (the root motion itself is applied by the move taker). */
35224
- private updateAnimationActionState;
35225
- /**
35226
- * Applies a root-motion action's world root delta to the player node: the height match replaces the vertical delta
35227
- * between the match start and target times, and the player either turns toward the climb surface or by the root
35228
- * rotation delta. Called from the `onAnimatorMove` taker.
35229
- * @param animator The Animator that ticked.
35230
- */
35231
- private applyActionRootMotion;
35232
- /**
35233
- * The height match: from `matchStartTime` the vertical delta eases the player toward the target height
35234
- * (`lastTargetHeight + matchTargetOffset`, Unity SmoothDamp over the match window); once `matchTargetTime` passes it
35235
- * snaps to the target height once.
35236
- * @param deltaTime The frame delta in seconds.
35237
- */
35238
- private applyHeightMatch;
35239
- /**
35240
- * Turns the player toward the climb surface (facing into its normal) at `playerRotationSpeed`, while touching it.
35241
- * @param deltaTime The frame delta in seconds.
35242
- */
35243
- private rotateTowardsClimbSurface;
35244
- /** Set the player world position */
35245
- setWorldPosition(x: number, y: number, z: number): void;
35246
- /** TODO */
35247
- setPlayerControl(mode: PROJECT.PlayerInputControl): void;
35248
- /** TODO */
35249
- togglePlayerControl(): void;
35250
- private showAvatarSkins;
35251
- /** TODO */
35252
- attachPlayerCamera(player: TOOLKIT.PlayerNumber): void;
35253
- private ikLeftFootTarget;
35254
- private ikLeftPoleTarget;
35255
- private ikRightFootTarget;
35256
- private ikRightPoleTarget;
35257
- private abstractSkinMesh;
35258
- private rootBoneTransform;
35259
- private leftFootTransform;
35260
- private leftFootPoleOffset;
35261
- private leftFootMaxAngle;
35262
- private rightFootTransform;
35263
- private rightFootPoleOffset;
35264
- private rightFootMaxAngle;
35265
- private ikLeftController;
35266
- private ikRightController;
35267
- onAnimatorIK: () => void;
35268
- getPlayerMesh(): BABYLON.AbstractMesh;
35269
- getRootHipBone(): BABYLON.Bone;
35270
- getLeftFootBone(): BABYLON.Bone;
35271
- getRightFootBone(): BABYLON.Bone;
35272
- getLeftFootTarget(): BABYLON.Mesh;
35273
- getRightFootTarget(): BABYLON.Mesh;
35274
- getLeftFootPoleTarget(): BABYLON.Mesh;
35275
- getRightFootPoleTarget(): BABYLON.Mesh;
35276
- getRootBoneTransform(): BABYLON.TransformNode;
35277
- getLeftFootTransform(): BABYLON.TransformNode;
35278
- getRightFootTransform(): BABYLON.TransformNode;
35279
- getLeftFootController(): BABYLON.BoneIKController;
35280
- getRightFootController(): BABYLON.BoneIKController;
35281
- isGroundedFootIKActive(): boolean;
35282
- setupBoneControllers(): void;
35283
- /**
35284
- * Finds the player's `TOOLKIT.Animator` (on this node or a child model), ends a running action when its action state
35285
- * exits, runs `onAnimatorIK` or the foot IK controllers in the Animator's IK pass, and takes root motion when
35286
- * `rootMotion` is on.
35287
- */
35288
- private attachAnimationController;
35289
- /**
35290
- * Records the base-layer state a running action enters, so that state's exit can end the action.
35291
- * @param change The entered state.
35292
- */
35293
- private onAnimatorStateEnter;
35294
- /**
35295
- * Ends a running action when its action state exits.
35296
- * @param change The exited state.
35297
- */
35298
- private onAnimatorStateExit;
35299
- /** The Animator's IK pass: the script's `onAnimatorIK` when set, else the foot IK controllers. */
35300
- private onAnimatorIKPass;
35301
- private updateAnimatorTargetMeshes;
35302
- /** TODO */
35303
- enableCharacterController(state: boolean): void;
35304
- /** TODO */
35305
- resetPlayerRotation(): void;
35306
- /** TODO */
35307
- resetPlayerJumpingState(): void;
35308
- private awakePlayerController;
35309
- private startPlayerController;
35310
- private updatePlayerPosition;
35311
- private updatePlayerController;
35312
- private afterPlayerController;
35313
- private updateCharacterController;
35314
- private updateCameraController;
35315
- getBoomArmMaxDistance(): number;
35316
- setBoomArmMaxDistance(distance: number): void;
35317
- setSmoothBoomArmLength(length: number, speed: number, updateMaxDistance?: boolean): void;
35318
- private smoothBoomArmLength;
35319
- private smoothBoomArmSpeed;
35320
- private updateSmoothBoomArmLength;
35321
- private castPhysicsClimbingVolumeRay;
35322
- private castPhysicsHeightCheckVolumeRay;
35323
- private getCheckedVerticalVelocity;
35324
- private destroyPlayerController;
35325
- private validateAnimationStateParams;
35326
- /** Fills a missing params object with the defaults, and merges keys added since a params object was exported (motionSpeed). */
35327
- static ApplyAnimationStateParamDefaults(params: PROJECT.AnimationStateParams): PROJECT.AnimationStateParams;
35328
- }
35329
- /**
35330
- * Babylon Interface Definition
35331
- * @interface AnimationStateParams
35332
- */
35333
- interface AnimationStateParams {
35334
- moveDirection: string;
35335
- inputMagnitude: string;
35336
- horizontalInput: string;
35337
- verticalInput: string;
35338
- mouseXInput: string;
35339
- mouseYInput: string;
35340
- heightInput: string;
35341
- speedInput: string;
35342
- /** Speed multiplier parameter of the Starter Assets controller (Unity sets MotionSpeed every frame). */
35343
- motionSpeed?: string;
35344
- jumpFrame: string;
35345
- jumpState: string;
35346
- actionState: string;
35347
- fallingState: string;
35348
- slidingState: string;
35349
- groundedState: string;
35350
- }
35351
- /**
35352
- * Babylon Enum Definition
35353
- * @interface PlayerInputControl
35354
- */
35355
- enum PlayerInputControl {
35356
- FirstPersonStrafing = 0,
35357
- ThirdPersonStrafing = 1
35358
- }
35359
- /**
35360
- * Babylon Enum Definition
35361
- * @interface PlayerMoveDirection
35362
- */
35363
- enum PlayerMoveDirection {
35364
- Stationary = 0,
35365
- Forward = 1,
35366
- ForwardLeft = 2,
35367
- ForwardRight = 3,
35368
- Backward = 4,
35369
- BackwardLeft = 5,
35370
- BackwardRight = 6,
35371
- StrafingLeft = 7,
35372
- StrafingRight = 8
35373
- }
35374
- /**
35375
- * Babylon Enum Definition
35376
- * @interface ActionAnimationType
35377
- */
35378
- enum ActionAnimationType {
35379
- Neutral = 0,
35380
- StepUp = 1,
35381
- JumpUp = 2,
35382
- ClimbUp = 3,
35383
- VaultOver = 4
35384
- }
35385
- }
35386
- declare namespace PROJECT {
35387
- /**
35388
- * Babylon toolkit third person player controller class (LEGACY)
35389
- * @class ThirdPersonPlayerController - All rights reserved (c) 2020 Mackey Kinard
35390
- * @deprecated This class is considered legacy and may be removed in future versions.
35391
- */
35392
- class ThirdPersonPlayerController extends TOOLKIT.ScriptComponent {
35393
- static MIN_VERTICAL_VELOCITY: number;
35394
- static MIN_GROUND_DISTANCE: number;
35395
- static MIN_MOVE_EPSILON: number;
35396
- static MIN_TIMER_OFFSET: number;
35397
- static MIN_SLOPE_LIMIT: number;
35398
- static PLAYER_HEIGHT: string;
35399
- enableInput: boolean;
35400
- attachCamera: boolean;
35401
- mouseWheel: boolean;
35402
- requireSprintButton: boolean;
35403
- gravitationalForce: number;
35404
- minFallVelocity: number;
35405
- verticalStepSpeed: number;
35406
- minStepUpHeight: number;
35407
- rigidBodyMass: number;
35408
- airbornTimeout: number;
35409
- maxAngle: number;
35410
- speedFactor: number;
35411
- rootMotion: boolean;
35412
- moveSpeed: number;
35413
- walkSpeed: number;
35414
- jumpSpeed: number;
35415
- jumpDelay: number;
35416
- lowTurnSpeed: number;
35417
- highTurnSpeed: number;
35418
- smoothDampTime: number;
35419
- smoothInputVectors: boolean;
35420
- smoothAcceleration: boolean;
35421
- accelerationSpeed: number;
35422
- decelerationSpeed: number;
35423
- climbVolumeTag: string;
35424
- vaultVolumeTag: string;
35425
- maxHeightRanges: any;
35426
- useClimbSystem: boolean;
35427
- distanceFactor: number;
35428
- inputMagnitude: number;
35429
- /** Unity StarterAssetsInputs.analogMovement: true drives the MotionSpeed parameter with the input magnitude (gamepad sticks), false keeps it at 1 (keyboard). */
35430
- analogMovement: boolean;
35431
- landingEpsilon: number;
35432
- minimumDistance: number;
35433
- movementAllowed: boolean;
35434
- playerInputX: number;
35435
- playerInputZ: number;
35436
- playerMouseX: number;
35437
- playerMouseY: number;
35438
- runKeyRequired: boolean;
35439
- buttonRun: number;
35440
- keyboardRun: number;
35441
- buttonJump: number;
35442
- keyboardJump: number;
35443
- buttonCamera: number;
35444
- keyboardCamera: number;
35445
- postNetworkAttributes: boolean;
35446
- playerNumber: TOOLKIT.PlayerNumber;
35447
- airbornVelocity: BABYLON.Vector3;
35448
- movementVelocity: BABYLON.Vector3;
35449
- isAnimationEnabled(): boolean;
35450
- isRunButtonPressed(): boolean;
35451
- isJumpButtonPressed(): boolean;
35452
- getPlayerJumped(): boolean;
35453
- getPlayerJumping(): boolean;
35454
- getPlayerFalling(): boolean;
35455
- getPlayerSliding(): boolean;
35456
- getPlayerGrounded(): boolean;
35457
- getFallTriggered(): boolean;
35458
- getMovementSpeed(): number;
35459
- getAnimator(): TOOLKIT.Animator;
35460
- getVerticalVelocity(): number;
35461
- getCharacterController(): TOOLKIT.CharacterController;
35462
- getPlayerLookRotation(): BABYLON.Vector3;
35463
- getPlayerMoveDirection(): PROJECT.PlayerMoveDirection;
35464
- getInputMovementVector(): BABYLON.Vector3;
35465
- getInputMagnitudeValue(): number;
35466
- rayClimbOffset: number;
35467
- rayClimbLength: number;
35468
- getClimbContact(): boolean;
35469
- getClimbContactNode(): BABYLON.TransformNode;
35470
- getClimbContactPoint(): BABYLON.Vector3;
35471
- getClimbContactAngle(): number;
35472
- getClimbContactNormal(): BABYLON.Vector3;
35473
- getClimbContactDistance(): number;
35474
- canClimbObstaclePredicate: (action: number) => boolean;
35475
- rayHeightOffset: number;
35476
- rayHeightLength: number;
35477
- getHeightContact(): boolean;
35478
- getHeightContactNode(): BABYLON.TransformNode;
35479
- getHeightContactPoint(): BABYLON.Vector3;
35480
- getHeightContactAngle(): number;
35481
- getHeightContactNormal(): BABYLON.Vector3;
35482
- getHeightContactDistance(): number;
35483
- private freeCamera;
35484
- private cameraForwardVector;
35485
- private cameraRightVector;
35486
- private desiredForwardVector;
35487
- private desiredRightVector;
35488
- private lastRotationQuaternion;
35489
- private avatarSkins;
35490
- private avatarRadius;
35491
- private navigationAgent;
35492
- private characterController;
35493
- private verticalVelocity;
35494
- private smoothMotionSpeed;
35495
- private movementSpeed;
35496
- private isRunPressed;
35497
- private isJumpPressed;
35498
- private isCharacterSliding;
35499
- private isCharacterFalling;
35500
- private isCharacterGrounded;
35501
- private isCharacterFallTriggered;
35502
- private isCharacterJumpFrame;
35503
- private isCharacterJumping;
35504
- private isCharacterRising;
35505
- private isCharacterLanding;
35506
- private isCharacterNavigating;
35507
- private navigationAngularSpeed;
35508
- private updateStateParams;
35509
- private animationStateParams;
35510
- private sphereCollisionShape;
35511
- private hasGroundedContact;
35512
- private showDebugColliders;
35513
- private colliderVisibility;
35514
- private colliderRenderGroup;
35515
- private groundCheckDistance;
35516
- private deltaTime;
35517
- private delayJumpTimer;
35518
- private canPlayerJump;
35519
- private animator;
35520
- private lastJumpVelocity;
35521
- private inputMovementVector;
35522
- private playerLookRotation;
35523
- private playerMovementVelocity;
35524
- private playerRotationQuaternion;
35525
- private playerMoveDirection;
35526
- private forwardDirection;
35527
- private downDirection;
35528
- private climbContact;
35529
- private climbContactNode;
35530
- private climbContactAngle;
35531
- private climbContactPoint;
35532
- private climbContactNormal;
35533
- private climbContactDistance;
35534
- private climbSensorLine;
35535
- private offsetClimbRaycastPosition;
35536
- private startClimbRaycastPosition;
35537
- private endClimbRaycastPosition;
35538
- private heightContact;
35539
- private heightContactNode;
35540
- private heightContactAngle;
35541
- private heightContactPoint;
35542
- private heightContactNormal;
35543
- private heightContactDistance;
35544
- private heightSensorLine;
35545
- private offsetHeightRaycastPosition;
35546
- private startHeightRaycastPosition;
35547
- private endHeightRaycastPosition;
35548
- protected m_velocityOffset: BABYLON.Vector3;
35549
- protected m_actualVelocity: BABYLON.Vector3;
35550
- protected m_linearVelocity: BABYLON.Vector3;
35551
- protected m_lastPosition: BABYLON.Vector3;
35552
- protected m_positionCenter: BABYLON.Vector3;
35553
- protected m_scaledVelocity: number;
35554
- protected playerDrawVelocity: number;
35555
- constructor(transform: BABYLON.TransformNode, scene: BABYLON.Scene, properties?: any, alias?: string);
35556
- protected awake(): void;
35557
- protected start(): void;
35558
- protected after(): void;
35559
- protected update(): void;
35560
- protected destroy(): void;
35561
- /** Character controller position
35562
- * @deprecated Moved to default camera controller
35563
- * @see PROJECT.DefaultCameraSystem
35564
- */
35565
- boomPosition: BABYLON.Vector3;
35566
- /** Register handler that is triggered before the controller has been updated */
35567
- onPreUpdateObservable: BABYLON.Observable<BABYLON.TransformNode>;
35568
- /** Register handler that is triggered before the controller movement has been applied */
35569
- onBeforeMoveObservable: BABYLON.Observable<BABYLON.TransformNode>;
35570
- /** Register handler that is triggered after the controller has been updated */
35571
- onPostUpdateObservable: BABYLON.Observable<BABYLON.TransformNode>;
35572
- /** Register handler that is triggered after player input has been updated */
35573
- onPlayerInputObservable: BABYLON.Observable<BABYLON.TransformNode>;
35574
- /** Register handler that is triggered when player position should be updated */
35575
- onPlayerPositionObservable: BABYLON.Observable<BABYLON.TransformNode>;
35576
- /** Register handler that is triggered after performing action has been updated */
35577
- onUpdateActionObservable: BABYLON.Observable<BABYLON.TransformNode>;
35578
- /** Register handler that is triggered after animation state has been updated */
35579
- onAnimationStateObservable: BABYLON.Observable<BABYLON.TransformNode>;
35580
- /** Observer on the Animator's `onAnimatorMoveObservable` while this controller takes root motion (D19, D20); null otherwise. */
35581
- private animatorMoveObserver;
35582
- /** The Animator's exported `applyRootMotion`, restored when this controller stops taking root motion. */
35583
- private exportedApplyRootMotion;
35584
- /** The last Animator tick's horizontal root-motion velocity (world, metres per second), moved by the character controller when `rootMotion` is on. */
35585
- private readonly rootMotionVelocity;
35586
- /**
35587
- * Registers the `onAnimatorMoveObservable` taker while root motion drives the player (`rootMotion` locomotion or a
35588
- * root-motion action) and removes it otherwise. The Animator may sit on a child model node, so the taker moves this
35589
- * player node rather than letting the built-in path move the model (D19, D20, D29).
35590
- */
35591
- private syncAnimatorMoveTaker;
35592
- /**
35593
- * The `onAnimatorMove` taker: a root-motion action moves and turns the player node; otherwise the horizontal root
35594
- * velocity is kept for the character controller's next move.
35595
- * @param animator The Animator that ticked.
35596
- */
35597
- private onAnimatorMove;
35598
- private isPerformingAction;
35599
- private isRootMotionAction;
35600
- private isActionInterruptable;
35601
- private afterActionHandler;
35602
- private performActionTimer;
35603
- private performActionNumber;
35604
- private playerRotationSpeed;
35605
- private rotatePlayerTowards;
35606
- private matchStartTime;
35607
- private matchTargetTime;
35608
- private matchTargetOffset;
35609
- private matchTargetHeight;
35610
- private lockTargetHeight;
35611
- private lastStartHeight;
35612
- private lastTargetHeight;
35613
- private lastTargetNormal;
35614
- private lastTargetRotation;
35615
- private lastDeltaPosition;
35616
- private lastDeltaRotation;
35617
- /** The eased player height of the height match (world metres). */
35618
- private smoothedPlayerHeight;
35619
- /** The SmoothDamp velocity of the height match (`x` holds it). */
35620
- private readonly playerHeightVelocity;
35621
- /** Full path hash of the base-layer state the running action entered; valid while `actionStateEntered`. */
35622
- private actionStateHash;
35623
- /** True once the running action's state was entered, so its exit ends the action. */
35624
- private actionStateEntered;
35625
- getIsPerformingAction(): boolean;
35626
- getIsRootMotionAction(): boolean;
35627
- getIsActionInterruptable(): boolean;
35628
- playActionAnimation(action: number, interruptableAction?: boolean, enableRootMotion?: boolean, afterActionComplete?: () => void): void;
35629
- resetActionAnimationState(): void;
35630
- /** Advances the action timer that drives the height match (the root motion itself is applied by the move taker). */
35631
- private updateAnimationActionState;
35632
- /**
35633
- * Applies a root-motion action's world root delta to the player node: the height match replaces the vertical delta
35634
- * between the match start and target times, and the player either turns toward the climb surface or by the root
35635
- * rotation delta. Called from the `onAnimatorMove` taker.
35636
- * @param animator The Animator that ticked.
35637
- */
35638
- private applyActionRootMotion;
35639
- /**
35640
- * The height match: from `matchStartTime` the vertical delta eases the player toward the target height
35641
- * (`lastTargetHeight + matchTargetOffset`, Unity SmoothDamp over the match window); once `matchTargetTime` passes it
35642
- * snaps to the target height once.
35643
- * @param deltaTime The frame delta in seconds.
35644
- */
35645
- private applyHeightMatch;
35646
- /**
35647
- * Turns the player toward the climb surface (facing into its normal) at `playerRotationSpeed`, while touching it.
35648
- * @param deltaTime The frame delta in seconds.
35649
- */
35650
- private rotateTowardsClimbSurface;
35651
- /** Set the player world position */
35652
- setWorldPosition(x: number, y: number, z: number): void;
35653
- private ikLeftFootTarget;
35654
- private ikLeftPoleTarget;
35655
- private ikRightFootTarget;
35656
- private ikRightPoleTarget;
35657
- private abstractSkinMesh;
35658
- private rootBoneTransform;
35659
- private leftFootTransform;
35660
- private leftFootPoleOffset;
35661
- private leftFootMaxAngle;
35662
- private rightFootTransform;
35663
- private rightFootPoleOffset;
35664
- private rightFootMaxAngle;
35665
- private ikLeftController;
35666
- private ikRightController;
35667
- onAnimatorIK: () => void;
35668
- getPlayerMesh(): BABYLON.AbstractMesh;
35669
- getRootHipBone(): BABYLON.Bone;
35670
- getLeftFootBone(): BABYLON.Bone;
35671
- getRightFootBone(): BABYLON.Bone;
35672
- getLeftFootTarget(): BABYLON.Mesh;
35673
- getRightFootTarget(): BABYLON.Mesh;
35674
- getLeftFootPoleTarget(): BABYLON.Mesh;
35675
- getRightFootPoleTarget(): BABYLON.Mesh;
35676
- getRootBoneTransform(): BABYLON.TransformNode;
35677
- getLeftFootTransform(): BABYLON.TransformNode;
35678
- getRightFootTransform(): BABYLON.TransformNode;
35679
- getLeftFootController(): BABYLON.BoneIKController;
35680
- getRightFootController(): BABYLON.BoneIKController;
35681
- isGroundedFootIKActive(): boolean;
35682
- setupBoneControllers(): void;
35683
- /**
35684
- * Finds the player's `TOOLKIT.Animator` (on this node or a child model), ends a running action when its action state
35685
- * exits, runs `onAnimatorIK` or the foot IK controllers in the Animator's IK pass, and takes root motion when
35686
- * `rootMotion` is on.
35687
- */
35688
- private attachAnimationController;
35689
- /**
35690
- * Records the base-layer state a running action enters, so that state's exit can end the action.
35691
- * @param change The entered state.
35692
- */
35693
- private onAnimatorStateEnter;
35694
- /**
35695
- * Ends a running action when its action state exits.
35696
- * @param change The exited state.
35697
- */
35698
- private onAnimatorStateExit;
35699
- /** The Animator's IK pass: the script's `onAnimatorIK` when set, else the foot IK controllers. */
35700
- private onAnimatorIKPass;
35701
- private updateAnimatorTargetMeshes;
35702
- /** TODO */
35703
- enableCharacterController(state: boolean): void;
35704
- /** TODO */
35705
- resetPlayerJumpingState(): void;
35706
- private awakePlayerController;
35707
- private startPlayerController;
35708
- private updatePlayerPosition;
35709
- private updatePlayerController;
35710
- private afterPlayerController;
35711
- private updateCharacterController;
35712
- private castPhysicsClimbingVolumeRay;
35713
- private castPhysicsHeightCheckVolumeRay;
35714
- private getCheckedVerticalVelocity;
35715
- private destroyPlayerController;
35716
- private validateAnimationStateParams;
35717
- /** Fills a missing params object with the defaults, and merges keys added since a params object was exported (motionSpeed). */
35718
- static ApplyAnimationStateParamDefaults(params: PROJECT.AnimationStateParams): PROJECT.AnimationStateParams;
35719
- }
35720
- /**
35721
- * Babylon Enum Definition
35722
- * @interface ThirdPersonControl
35723
- */
35724
- enum ThirdPersonControl {
35725
- ThirdPersonTurning = 0,
35726
- ThirdPersonForward = 1
35727
- }
35728
- }
35729
35166
  declare namespace PROJECT {
35730
35167
  /**
35731
35168
  * Babylon Script Component
@@ -58285,10 +57722,20 @@ declare namespace TOOLKIT {
58285
57722
  static AllUniforms(): string[];
58286
57723
  private static AllUniformsBase;
58287
57724
  private static registered;
58288
- /** The scene's `hdrp.fog` block (parity scenes only), or null. */
57725
+ /** The scene's fog block: `hdrp.fog` on a parity scene, `urp.fog` on a URP physical sky scene, otherwise null. */
58289
57726
  static FogBlock(scene: BABYLON.Scene): any;
58290
- /** The sky the aerial perspective comes from: the live PhysicallyBasedSky when it runs, else the `hdrp.sky` block. */
57727
+ /** The sky the aerial perspective comes from: the live PhysicallyBasedSky when it runs, else the export's physical sky block. */
58291
57728
  static SkyOf(scene: BABYLON.Scene): any;
57729
+ /**
57730
+ * Binds `fogChain` for a URP physical sky, whose pass runs after everything where Unity's runs before transparents. x = the chain
57731
+ * holds display values (decode, composite in linear, encode), y = a water surface exists, z = its height in metres, so a ray that
57732
+ * meets the water first takes no fog, w = the fog is on, which makes Unity's opaque pass give sky pixels aerial perspective up to
57733
+ * the fog's maximum distance (measured: the Morning preset's zenith 0.023 without it, 0.046 with it). A parity scene binds zero.
57734
+ * @param effect The fog effect.
57735
+ * @param scene The scene.
57736
+ * @param fog The scene's fog block, or null.
57737
+ */
57738
+ private static BindChain;
58292
57739
  /** The fog inputs of this frame (computed once per render id). */
58293
57740
  static Frame(scene: BABYLON.Scene, fog: any): IHdrpFogFrame;
58294
57741
  /** The view depth at and beyond which a pixel is sky: the nearest face of an infinite-distance sky mesh (none -> 1e30). */
@@ -58333,6 +57780,21 @@ declare namespace TOOLKIT {
58333
57780
  static AmbientGlsl(): string;
58334
57781
  /** WGSL twin of `AmbientGlsl`. */
58335
57782
  static AmbientWgsl(): string;
57783
+ /**
57784
+ * The PhysicallyBasedSky aerial perspective at distance `tFrag` along `dir` (AtmosphericScattering.hlsl
57785
+ * `EvaluateAtmosphericScattering`, sky part): the in-scatter from the sky's froxel LUT (`apLut`, sampled at screen `uv`) and
57786
+ * the opacity from the optical depth, with the sky's artistic horizon / zenith tint. Shared by this pass and the volumetric
57787
+ * clouds (at their mean cloud distance). Needs the atmosphere uniforms (HdrpPbSkyShaders.GlslUniforms + GlslCommon) and
57788
+ * a `sampler2DArray apLut` declared first.
57789
+ * @returns GLSL source.
57790
+ */
57791
+ static AerialPerspectiveGlsl(): string;
57792
+ /**
57793
+ * WGSL twin of AerialPerspectiveGlsl (`fogAerialPerspective` returns a `FogAerial`). Needs the atmosphere uniforms and
57794
+ * `apLut` / `apLutSampler` declared first.
57795
+ * @returns WGSL source.
57796
+ */
57797
+ static AerialPerspectiveWgsl(): string;
58336
57798
  static GlslHelpers(prefix: string): string;
58337
57799
  static WgslHelpers(prefix: string): string;
58338
57800
  private static Glsl;
@@ -58674,6 +58136,21 @@ declare namespace TOOLKIT {
58674
58136
  requested: boolean;
58675
58137
  captured: boolean;
58676
58138
  }, nowSeconds: number, frame: number, precomputationHash: string, lightHash: string, updateMode: number, updatePeriod: number): boolean;
58139
+ /** ProbeRenderOutcome: nothing changes. */
58140
+ static readonly ProbeRenderKept: number;
58141
+ /** ProbeRenderOutcome: the render is the requested capture, ready for the prefilter. */
58142
+ static readonly ProbeCaptureAccepted: number;
58143
+ /** ProbeRenderOutcome: the render did not draw the sky, so the capture is taken again on the next frame. */
58144
+ static readonly ProbeCaptureRetry: number;
58145
+ /**
58146
+ * What one finished probe render means for the live environment. A requested capture stands only when the sky was drawn;
58147
+ * a render that did not draw it, while a capture waits for its prefilter, has replaced that capture, so it is taken again.
58148
+ * @param capturing - True while a capture is requested.
58149
+ * @param pendingFilter - True while an accepted capture waits for its prefilter.
58150
+ * @param drewSky - True when the sky material was ready for this render.
58151
+ * @returns ProbeRenderKept, ProbeCaptureAccepted or ProbeCaptureRetry.
58152
+ */
58153
+ static ProbeRenderOutcome(capturing: boolean, pendingFilter: boolean, drewSky: boolean): number;
58677
58154
  /** D34: the ambient SH - Dynamic (1) → the live read-back once it exists, else the exported static SH; Static (0) → the exported SH. */
58678
58155
  static SelectAmbientSh(skyAmbientMode: number, readback: BABYLON.SphericalHarmonics, exported: BABYLON.SphericalHarmonics): BABYLON.SphericalHarmonics;
58679
58156
  /** The polynomial scale that leaves diffuse = SH x indirect.diffuse after the environment level (pe x indirect.reflection) multiplies it. */
@@ -58759,6 +58236,8 @@ declare namespace TOOLKIT {
58759
58236
  private filtering;
58760
58237
  private pendingFilter;
58761
58238
  private capturing;
58239
+ /** True when the probe's current render draws the sky (its material is ready), so the render can stand as a capture. */
58240
+ private probeDrawsSky;
58762
58241
  private shReading;
58763
58242
  /** The live capture's ambient, pre-scaled harmonics in physical units (Dynamic ambient), null until the first read-back. */
58764
58243
  private readbackHarmonics;
@@ -58775,6 +58254,10 @@ declare namespace TOOLKIT {
58775
58254
  private apRequested;
58776
58255
  private apCamera;
58777
58256
  private readonly startTime;
58257
+ /** Multiplies the exported sun intensity to the strength the sky scatters (`sky.sunintensityscale`, 1 on HDRP). */
58258
+ private readonly sunIntensityScale;
58259
+ /** The sky's stars (`params.spaceemissionurl`), or null. */
58260
+ private readonly spaceCube;
58778
58261
  private constructor();
58779
58262
  /** "live" or "baked: <reason>" (Inspector read-out). */
58780
58263
  get mode(): string;
@@ -58794,7 +58277,25 @@ declare namespace TOOLKIT {
58794
58277
  private writeCloudUniforms;
58795
58278
  /** The cloud ambient: the sky's ambient SH at (0, -1, 0), physical (CloudLayerCommon `SampleSH9(_AmbientProbeBuffer, down)`). */
58796
58279
  private cloudAmbient;
58280
+ /**
58281
+ * The sky's ambient probe in one direction, physical and before the indirect-diffuse scale - the ambient the cloud layer and
58282
+ * the volumetric clouds (TOOLKIT.VolumetricClouds) light with.
58283
+ * @param direction The world direction.
58284
+ * @returns The ambient radiance, black when the sky has no ambient yet.
58285
+ */
58286
+ ambientAt(direction: BABYLON.Vector3): BABYLON.Color3;
58797
58287
  private cloudLayers;
58288
+ /**
58289
+ * Loads the sky's exported space emission cube (`params.spaceemissionurl`).
58290
+ * @returns The cube, or null when the export has none.
58291
+ */
58292
+ private loadSpaceEmission;
58293
+ /**
58294
+ * The `pbSpace` uniform: emission multiplier, cosine and sine of the Y rotation, and the X sign that takes a right-handed scene
58295
+ * direction back to Unity's left-handed cube.
58296
+ * @returns The uniform value.
58297
+ */
58298
+ private spaceEmissionUniform;
58798
58299
  private loadCloudMap;
58799
58300
  private bindEffect;
58800
58301
  /**
@@ -58805,6 +58306,12 @@ declare namespace TOOLKIT {
58805
58306
  * @param capturing True before the probe renders its faces, false after.
58806
58307
  */
58807
58308
  setProbeCapture(capturing: boolean): void;
58309
+ /**
58310
+ * True when the sky draws straight to display values: on a non-parity scene with no image-processing pass, materials encode
58311
+ * for display themselves, and the sky's raw radiance would otherwise sit among them as linear values.
58312
+ * @returns True for a scene whose image processing runs inside materials.
58313
+ */
58314
+ private encodesForDisplay;
58808
58315
  private applyMaterialUniforms;
58809
58316
  /** D37: the colour of every interacting light on surfaces x HDRP's atmospheric attenuation at the camera. */
58810
58317
  private attenuateSuns;
@@ -63254,6 +62761,210 @@ declare namespace TOOLKIT {
63254
62761
  private onDataLoaded;
63255
62762
  }
63256
62763
  }
62764
+ declare namespace TOOLKIT {
62765
+ /** One node kept around the camera while it is under water, as FollowPlayerSystem does in Unity. */
62766
+ interface IMeshWaterFollower {
62767
+ /** Node id. */
62768
+ node: string;
62769
+ /** World offset from the camera, in metres. */
62770
+ offset: number[];
62771
+ /** Local scale set once at start, or null to leave the node's own. */
62772
+ scale: number[] | null;
62773
+ }
62774
+ /** Underwater state of a water surface drawn by an ordinary mesh. */
62775
+ interface IMeshWaterUnderwater {
62776
+ /** Height the camera is compared with, in metres. It can differ from the drawn surface: Unity URP Water sits 0.1 m below it. */
62777
+ sealevel: number;
62778
+ /** Raw RGB keys of the fog gradient (`Gradient.Evaluate`), sampled evenly from surface to `fogdepth`. Empty leaves the fog alone. */
62779
+ fogcolors: number[][];
62780
+ /** Added to each fog colour channel that is zero or more, then clamped to 1. A negative channel adds nothing. */
62781
+ fogcolormultiplier: number[];
62782
+ /** Metres of depth over which the gradient runs. */
62783
+ fogdepth: number;
62784
+ /** Fog density in Babylon's terms: Unity's value with the same export factor as `metadata.fogdensity`. */
62785
+ fogdensity: number;
62786
+ /** Linear fog start in metres. */
62787
+ fogstart: number;
62788
+ /** Linear fog end in metres. */
62789
+ fogend: number;
62790
+ /** The sun's raw colour (`Light.color`), which multiplies the fog; white when the effect has no light. */
62791
+ suncolor: number[];
62792
+ /** Node ids of `TOOLKIT.PostProcessor` volumes enabled only under water. */
62793
+ volumenodes: string[];
62794
+ /** Node ids enabled only under water. */
62795
+ shownodes: string[];
62796
+ /** Node ids rotated Euler(180, 0, 0) while under water. */
62797
+ flipnodes: string[];
62798
+ /** Nodes kept around the camera while under water. */
62799
+ follownodes: TOOLKIT.IMeshWaterFollower[];
62800
+ }
62801
+ /** Exported properties of `TOOLKIT.MeshWaterSurface`. */
62802
+ interface IMeshWaterSurfaceProperties {
62803
+ /** World height of the still surface in metres. */
62804
+ sealevel: number;
62805
+ /** Vertical wave amplitude in metres (the material's `_WaveSteepness`), zero for a flat surface. */
62806
+ waveamplitude: number;
62807
+ /** Wave phase speed in radians per second (the material's `_WaveSpeed / 20`). */
62808
+ wavespeed: number;
62809
+ /** The underwater state, or null when the scene has none: the surface then only answers height queries. */
62810
+ underwater: TOOLKIT.IMeshWaterUnderwater | null;
62811
+ }
62812
+ /**
62813
+ * Water drawn by an ordinary mesh with a transpiled graph. It answers height queries in the shape of
62814
+ * `HdrpWaterSurface`, and turns the underwater look on and off as one state switch: each frame it compares the active camera with
62815
+ * sea level, and on a crossing it writes the scene's fog values, enables the listed volumes and nodes, plays their particles, and
62816
+ * turns the listed nodes over. `scene.fogMode` is never written, so no material recompiles, and a scene with fog off has no underwater fog, as in Unity.
62817
+ * @class MeshWaterSurface - All rights reserved (c) 2024 Mackey Kinard
62818
+ */
62819
+ class MeshWaterSurface extends TOOLKIT.ScriptComponent {
62820
+ /** The class name of the volumes this component switches. */
62821
+ private static readonly POST_PROCESSOR_CLASS;
62822
+ /** The class name of the particle systems this component plays. */
62823
+ private static readonly PARTICLES_CLASS;
62824
+ /** `ParticleSystemStopBehavior.StopEmittingAndClear`, because Unity deactivates the object in the same step. */
62825
+ private static readonly STOP_AND_CLEAR;
62826
+ /** CanvasTools doubles Unity's linear fog end on scene intake, so the underwater end takes the same factor. */
62827
+ private static readonly LINEAR_FOG_END_SCALE;
62828
+ /** The scene's water surface, by `scene.uniqueId`. */
62829
+ private static Registry;
62830
+ /** The exported properties. */
62831
+ private waterProperties;
62832
+ /** True between `enterUnderwater` and `leaveUnderwater`. */
62833
+ private isUnderwater;
62834
+ /** One fog colour, reused each frame. */
62835
+ private readonly fogColorChannels;
62836
+ /** The scene's fog colour above water, saved at the first switch. */
62837
+ private readonly surfaceFogColor;
62838
+ /** The scene's fog density above water. */
62839
+ private surfaceFogDensity;
62840
+ /** The scene's linear fog start above water. */
62841
+ private surfaceFogStart;
62842
+ /** The scene's linear fog end above water. */
62843
+ private surfaceFogEnd;
62844
+ /** Nodes enabled only under water. */
62845
+ private shownNodes;
62846
+ /** Particle systems on the shown nodes, played only under water. */
62847
+ private shownParticles;
62848
+ /** Volume nodes enabled only under water. */
62849
+ private volumeNodes;
62850
+ /** Nodes turned over while under water. */
62851
+ private flippedNodes;
62852
+ /** Nodes kept around the camera while under water. */
62853
+ private followers;
62854
+ /** One follower position, reused each frame. */
62855
+ private readonly followPosition;
62856
+ /**
62857
+ * Created by the scene loader from the exported component.
62858
+ * @param transform - The water root.
62859
+ * @param scene - The scene.
62860
+ * @param properties - The exported `IMeshWaterSurfaceProperties`.
62861
+ * @param alias - The class name the component registers under.
62862
+ */
62863
+ constructor(transform: BABYLON.TransformNode, scene: BABYLON.Scene, properties?: any, alias?: string);
62864
+ /**
62865
+ * The scene's water surface. One per scene is the supported case; a second replaces the first with one warning.
62866
+ * @param scene - The scene to look in.
62867
+ * @returns The surface, or null when the scene has none.
62868
+ */
62869
+ static Get(scene: BABYLON.Scene): TOOLKIT.MeshWaterSurface;
62870
+ /**
62871
+ * Reads the exported properties and registers the surface.
62872
+ * Runs before the first frame, so game code can query heights from its own `start`.
62873
+ */
62874
+ protected awake(): void;
62875
+ /**
62876
+ * Builds the components on the nodes shown only under water, which stay asleep while their node is disabled. Their particle
62877
+ * systems then join the reveal-time warm-up, so the first dip compiles nothing.
62878
+ */
62879
+ protected ready(): void;
62880
+ /** Finds the listed nodes once. A camera that starts under water enters the state at once, as Unity's `Start` does. */
62881
+ protected start(): void;
62882
+ /** Runs the state switch for the active camera. Allocates nothing on a frame without a crossing. */
62883
+ protected update(): void;
62884
+ /** Drops the surface from the registry and puts the scene back as it was above water. */
62885
+ protected destroy(): void;
62886
+ /** @returns World height of the still surface in metres. */
62887
+ getSeaLevel(): number;
62888
+ /** @returns World height of the surface now: `sealevel + sin(clockSeconds * wavespeed) * waveamplitude`. */
62889
+ getSurfaceHeight(): number;
62890
+ /**
62891
+ * @param camera - The camera to measure.
62892
+ * @returns Metres of the camera above the surface, negative under water.
62893
+ */
62894
+ getCameraHeight(camera: BABYLON.Camera): number;
62895
+ /**
62896
+ * True at or below the height the Unity underwater component compares with. That height ignores the wave, so a camera
62897
+ * resting at the surface does not flicker between the two states.
62898
+ * @param camera - The camera to test.
62899
+ * @returns True when the underwater state applies to this camera.
62900
+ */
62901
+ isCameraUnderwater(camera: BABYLON.Camera): boolean;
62902
+ /**
62903
+ * Mirrors `HdrpWaterSurface.ProjectPointOnWaterSurface`. The surface is one flat height, so the search ends at once.
62904
+ * @param searchParameters - `targetPositionWS` may be a `Vector3` or a number array.
62905
+ * @returns The surface point under the target, or null without a target.
62906
+ */
62907
+ ProjectPointOnWaterSurface(searchParameters: TOOLKIT.IHdrpWaterSearchParameters): TOOLKIT.IHdrpWaterSearchResult;
62908
+ /**
62909
+ * Mirrors `HdrpWaterSurface.FindWaterSurfaceHeight`.
62910
+ * @param searchParameters - As `ProjectPointOnWaterSurface`.
62911
+ * @returns The surface point under the target, or null without a target.
62912
+ */
62913
+ FindWaterSurfaceHeight(searchParameters: TOOLKIT.IHdrpWaterSearchParameters): TOOLKIT.IHdrpWaterSearchResult;
62914
+ /**
62915
+ * Resolves node ids, skipping one the export no longer holds.
62916
+ * @param nodeIds - Exported node ids.
62917
+ * @returns The nodes found.
62918
+ */
62919
+ private findNodes;
62920
+ /**
62921
+ * Finds the particle systems to start and stop: Unity's underwater component does this from script, so they are authored stopped.
62922
+ * @param nodes - The shown nodes.
62923
+ * @returns The systems found.
62924
+ */
62925
+ private findParticles;
62926
+ /**
62927
+ * Works out a node's two rotations once. Unity turns the plane over because it draws front faces only. The node stays
62928
+ * live: a static water mesh loads with a frozen world matrix, which would ignore the turn.
62929
+ * @param node - The node to turn over.
62930
+ * @returns The node and its rotations.
62931
+ */
62932
+ private prepareFlip;
62933
+ /**
62934
+ * Resolves the follow list and sets each node's fixed scale.
62935
+ * @param follownodes - The exported list, absent on an older export.
62936
+ * @returns The followers found.
62937
+ */
62938
+ private prepareFollowers;
62939
+ /** Saves the surface fog, writes the underwater fog, and turns on everything that shows only below the surface. */
62940
+ private enterUnderwater;
62941
+ /** Restores the surface fog and turns off everything `enterUnderwater` turned on. */
62942
+ private leaveUnderwater;
62943
+ /**
62944
+ * Saves the scene's fog and writes the underwater distances and density. The density takes the scene intake's scale for its mode.
62945
+ * @param underwater - The underwater block.
62946
+ */
62947
+ private writeUnderwaterFog;
62948
+ /** Puts the scene's fog back exactly as it was. */
62949
+ private restoreSurfaceFog;
62950
+ /**
62951
+ * Switches the listed volumes. The node goes first because `IsVolumeEnabled` also tests it.
62952
+ * @param enabled - The new state.
62953
+ */
62954
+ private setVolumesEnabled;
62955
+ /**
62956
+ * Writes the fog colour of the current depth, as the Unity underwater component does each frame, in the same raw
62957
+ * colour values as `metadata.fogcolor`.
62958
+ * @param depthMeters - Metres below the surface, zero or more.
62959
+ */
62960
+ private updateFog;
62961
+ /**
62962
+ * Keeps the horizon box and the particles around the camera, as `FollowPlayerSystem.LateUpdate` does.
62963
+ * @param camera - The active camera.
62964
+ */
62965
+ private updateFollowers;
62966
+ }
62967
+ }
63257
62968
  /** Babylon Toolkit Namespace */
63258
62969
  declare namespace TOOLKIT {
63259
62970
  /**
@@ -68014,6 +67725,11 @@ declare namespace TOOLKIT {
68014
67725
  * @returns True for a Cinemachine volume.
68015
67726
  */
68016
67727
  private isCinemachineVolume;
67728
+ /**
67729
+ * True for a volume the exporter marked `role: "switched"`, which a component turns on later.
67730
+ * @returns True for a switched volume.
67731
+ */
67732
+ private isSwitchedVolume;
68017
67733
  /** Whether this volume contributes: `SetVolumeEnabled` and its node's own enabled state. */
68018
67734
  IsVolumeEnabled(): boolean;
68019
67735
  /** True while the per-frame local-volume observer is registered (only scenes with local volumes register one). */
@@ -69626,6 +69342,8 @@ declare namespace TOOLKIT {
69626
69342
  static readonly VOLUME_TYPES: string[];
69627
69343
  /** cinemachine-port D25: the `role` the exporter writes on a Cinemachine camera's volume. */
69628
69344
  static readonly CINEMACHINE_VOLUME_ROLE: string;
69345
+ /** The `role` of a volume `TOOLKIT.MeshWaterSurface` switches on below the surface. */
69346
+ static readonly SWITCHED_VOLUME_ROLE: string;
69629
69347
  /** PPv2 `GradingMode` enum (`ColorGrading.gradingMode`): 0 LowDefinitionRange, 1 HighDefinitionRange (default), 2 External. */
69630
69348
  static readonly GRADING_MODES: string[];
69631
69349
  /** Unity `RenderingPath` names as exported in `renderingpath`; PPv2 renders SSR only on `DeferredShading`. */
@@ -78703,6 +78421,23 @@ declare namespace TOOLKIT {
78703
78421
  * @returns The body, or null when there is no collider to build it from.
78704
78422
  */
78705
78423
  static CreateComplexCompoundBody(scene: BABYLON.Scene, entity: BABYLON.TransformNode, childItems: TOOLKIT.PhyscisContainerData[], rootMeshShape: BABYLON.PhysicsShape, motionType: BABYLON.PhysicsMotionType, physics: any, mass: number, centerOfMass: BABYLON.Vector3, layermask: number, filtermask: number): BABYLON.PhysicsBody;
78424
+ /**
78425
+ * Marks what the loader may dispose once a complex compound child has given its collider to the root's body: a node
78426
+ * that exists only to carry the collider goes whole, while a node that also renders stays and only loses its
78427
+ * `.Collider` mesh. A LOD level with a BoxCollider is such a node: disposing it would remove the visible mesh,
78428
+ * and with it every lower level, which stay blocked by a disposed LOD master.
78429
+ * @param entity The compound child node.
78430
+ */
78431
+ private static MarkCompoundChildForDisposal;
78432
+ /**
78433
+ * Whether a node is a mesh Unity renders, shadow-only renderers included. Having vertices is not enough: with the
78434
+ * exporter's "Default Collision Proxy" on, a collider whose renderer is absent or disabled gets a generated box.
78435
+ * The exporter writes `metadata.toolkit.renderer` only for a present, enabled renderer whenever physics is exported,
78436
+ * and it writes one on a `.Collider` mesh too, so that name is ruled out first.
78437
+ * @param node A node.
78438
+ * @returns True when the node draws in Unity.
78439
+ */
78440
+ private static RendersItself;
78706
78441
  protected static CreateCompoundPhysicsShapeAndBody(scene: BABYLON.Scene, root: BABYLON.TransformNode, entity: BABYLON.TransformNode, element: any, impostortype: number, staticfriction: number, dynamicfriction: number, restitution: number, fcombine: number, rcombine: number, sitems: TOOLKIT.PhyscisContainerData[], item: TOOLKIT.PhyscisContainerData, center: any, complex: boolean, trigger: boolean, persist: boolean, layer: number, filter: number): void;
78707
78442
  protected static CreateHeightFieldTerrainShapeFromMesh(terrainMesh: BABYLON.Mesh, scaleX: number, scaleZ: number): any;
78708
78443
  static GetPhysicsHeapSize(): number;
@@ -80204,7 +79939,8 @@ declare namespace TOOLKIT {
80204
79939
  getOwnedParticleSystems(): BABYLON.IParticleSystem[];
80205
79940
  /**
80206
79941
  * True when nothing of the system is drawn and it is drawn as quads, so a warm draw can show it (mesh / graph renderers draw through
80207
- * meshes): idle (never started), or playing but held by culling with no live particle.
79942
+ * meshes): idle (never started), or playing but held by culling with no live particle. A system whose object was inactive at
79943
+ * export (`enabled: false`) counts too: script activates it later, and without this draw its first show builds a GPU pipeline.
80208
79944
  */
80209
79945
  canBeginWarmupDraw(): boolean;
80210
79946
  /** Starts the warm draw: one invisible particle, the clock, RNG and emission bookkeeping untouched (SceneShaderWarmup reveal-time pass). */
@@ -83583,6 +83319,10 @@ declare namespace TOOLKIT {
83583
83319
  */
83584
83320
  class TerrainBuilder extends TOOLKIT.ScriptComponent {
83585
83321
  private static _registry;
83322
+ /** worldToUnityUV's inverse world matrix: height queries run every frame and must not allocate one per call. */
83323
+ private static readonly ScratchInverse;
83324
+ /** worldToUnityUV's terrain-local position. */
83325
+ private static readonly ScratchLocal;
83586
83326
  readonly onBuiltObservable: BABYLON.Observable<TOOLKIT.TerrainBuilder>;
83587
83327
  /** Loading progress of this terrain, stage by stage (see ITerrainLoadProgress). */
83588
83328
  readonly onLoadProgressObservable: BABYLON.Observable<TOOLKIT.ITerrainLoadProgress>;
@@ -83740,6 +83480,37 @@ declare namespace TOOLKIT {
83740
83480
  protected destroy(): void;
83741
83481
  private disposeParts;
83742
83482
  private buildAsync;
83483
+ /**
83484
+ * Finds this tile's four neighbours (D17). Reads each one's heights from its contract, because its heightfield may not be built yet.
83485
+ * @returns The neighbours, or null when the tile stands alone.
83486
+ */
83487
+ private resolveEdgeNeighbors;
83488
+ /**
83489
+ * One axis neighbour of this tile.
83490
+ * @param tiles The scene's registered tiles.
83491
+ * @param neighborId The exported node id, or null.
83492
+ * @param useIds True when the export carries neighbour ids, so adjacency is not tested.
83493
+ * @param offsetX -1 or 1 along Unity x, else 0.
83494
+ * @param offsetZ -1 or 1 along Unity z, else 0.
83495
+ * @returns The neighbour's heights, or null when there is no matching tile.
83496
+ */
83497
+ private edgeNeighborFor;
83498
+ /**
83499
+ * D17: tiles continue each other's normals only with equal resolution and equal x and z size.
83500
+ * @param other Another registered tile.
83501
+ * @returns True when a shared edge lines up sample for sample.
83502
+ */
83503
+ private canShareEdgeWith;
83504
+ /**
83505
+ * DR-6.2 rectangle adjacency, for an export without neighbour ids: both tiles allow auto connect, share a grouping id, and
83506
+ * the other tile's origin sits one tile size away in this tile's Unity space. Measured in that space, it holds under any
83507
+ * parent transform, where comparing world axes would swap neighbours below a mirrored root.
83508
+ * @param other Another registered tile.
83509
+ * @param offsetX -1 or 1 along Unity x, else 0.
83510
+ * @param offsetZ -1 or 1 along Unity z, else 0.
83511
+ * @returns True when the other tile is this tile's neighbour on that side.
83512
+ */
83513
+ private isAdjacentTile;
83743
83514
  /** Shows or hides the built trees and details as drawTreesAndFoliage says (on a change, and once the parts are built). */
83744
83515
  private applyTreesAndFoliageVisibility;
83745
83516
  /**
@@ -83896,6 +83667,13 @@ declare namespace TOOLKIT {
83896
83667
  private static NowMs;
83897
83668
  /** [u, v] of a world position in Unity terrain space (unclamped), or null before the contract is known. */
83898
83669
  private worldToUnityUV;
83670
+ /**
83671
+ * True when a world position lies on this tile's rectangle, widened by a tolerance.
83672
+ * @param worldPosition The world position.
83673
+ * @param tolerance Slack in metres on every side.
83674
+ * @returns False outside the widened rectangle, or before the contract is known.
83675
+ */
83676
+ private containsWorldPosition;
83899
83677
  /** Height relative to the terrain (Unity semantics), clamped to the terrain rect. */
83900
83678
  SampleHeight(worldPosition: BABYLON.Vector3): number;
83901
83679
  /** Local height at normalised (u, v). */
@@ -83910,7 +83688,13 @@ declare namespace TOOLKIT {
83910
83688
  private static Unregister;
83911
83689
  /** Every registered (valid-contract) terrain of the scene. */
83912
83690
  static GetTerrains(scene: BABYLON.Scene): TOOLKIT.TerrainBuilder[];
83913
- /** The terrain whose rect contains the world position (the last registered wins overlaps), or null. */
83691
+ /**
83692
+ * The terrain whose rect contains the world position (the last registered wins overlaps), or null. A point that misses
83693
+ * every rect by Float32 rounding on a shared tile edge gets a second scan with TERRAIN_EDGE_TOLERANCE_METERS of slack.
83694
+ * @param scene The scene.
83695
+ * @param worldPosition The world position.
83696
+ * @returns The terrain under the position, or null when none covers it.
83697
+ */
83914
83698
  static GetTerrainAt(scene: BABYLON.Scene, worldPosition: BABYLON.Vector3): TOOLKIT.TerrainBuilder;
83915
83699
  /** World Y of the terrain surface under a world position, or null when no terrain covers it. */
83916
83700
  static GetWorldHeightAt(scene: BABYLON.Scene, worldPosition: BABYLON.Vector3): number;
@@ -84034,6 +83818,20 @@ declare namespace TOOLKIT {
84034
83818
  wavelength: number;
84035
83819
  } | null;
84036
83820
  }
83821
+ /** The heights of one neighbouring tile, enough to continue a central difference across a shared edge. */
83822
+ interface ITerrainEdgeNeighbor {
83823
+ /** The neighbour's 16-bit heights, z outer, index = z * resolution + x. */
83824
+ heights: Uint16Array;
83825
+ /** The neighbour's height scale in metres (`size[1]`), which may differ from this tile's. */
83826
+ heightScale: number;
83827
+ }
83828
+ /** The four axis neighbours of a tile in Unity terrain space: left -x, right +x, top +z, bottom -z. */
83829
+ interface ITerrainEdgeNeighbors {
83830
+ left: ITerrainEdgeNeighbor | null;
83831
+ right: ITerrainEdgeNeighbor | null;
83832
+ top: ITerrainEdgeNeighbor | null;
83833
+ bottom: ITerrainEdgeNeighbor | null;
83834
+ }
84037
83835
  interface ITerrainContract {
84038
83836
  contract: number;
84039
83837
  name: string;
@@ -84256,14 +84054,6 @@ declare namespace TOOLKIT {
84256
84054
  }[];
84257
84055
  /** The layer's main-pass host with room for at least count instances (created or grown on demand). */
84258
84056
  private ensureMain;
84259
- /**
84260
- * Babylon's thinInstanceSetBuffer("matrix") keeps the old previous-world buffer (created on the first draw once the scene
84261
- * needs previous world matrices, e.g. HDRP motion blur velocity), and every draw then writes the grown count into it - on
84262
- * WebGPU that invalidates the whole frame. Rebuilt at the new size the way Babylon's own _thinInstanceUpdateBufferSize does:
84263
- * merely disposing it leaves its four previousWorld vertex buffers on the geometry, and the next pipeline then counts them
84264
- * as four separate buffers (past WebGPU's 8).
84265
- */
84266
- private static ResizePreviousMatrices;
84267
84057
  /** The main host's tint buffer: Babylon's "color" for mesh layers, "tkGrassTint" for texture grass (TerrainGrassPlugin). */
84268
84058
  private static TintBuffer;
84269
84059
  /** XZ distance from the camera (Unity-local metres) to the chunk rect. */
@@ -84436,6 +84226,14 @@ declare namespace TOOLKIT {
84436
84226
  * Keyed on the material's type and shader name, never on a graph, scene or material name.
84437
84227
  */
84438
84228
  static IsGraphMaterial(material: BABYLON.Material): boolean;
84229
+ /**
84230
+ * True when a Shader Graph class alone decides how its mesh moves, so the toolkit adds no sway. In Unity a terrain tree or
84231
+ * mesh detail on a Shader Graph gets no engine wind: only what the graph computes moves it, and the transpiled class
84232
+ * already does that. A SpeedTree material is the exception, because its wind comes from data its host may not carry.
84233
+ * @param material The source material of a tree or detail host.
84234
+ * @returns True when MODE_TREE and MODE_SWAY must be left out.
84235
+ */
84236
+ static GraphOwnsMotion(material: BABYLON.Material): boolean;
84439
84237
  getClassName(): string;
84440
84238
  isCompatible(shaderLanguage: BABYLON.ShaderLanguage): boolean;
84441
84239
  /** Installs (or extends, OR-ing the modes) the plugin on a material. Idempotent per material (metadata.tkFoliage). */
@@ -84749,6 +84547,8 @@ declare namespace TOOLKIT {
84749
84547
  private _errors;
84750
84548
  private _minH;
84751
84549
  private _maxH;
84550
+ /** The tile's axis neighbours, null when it stands alone, so border normals stay one-sided. */
84551
+ private edgeNeighbors;
84752
84552
  constructor(contract: TOOLKIT.ITerrainContract, heights: Uint16Array);
84753
84553
  get cellSizeX(): number;
84754
84554
  get cellSizeZ(): number;
@@ -84758,6 +84558,12 @@ declare namespace TOOLKIT {
84758
84558
  sampleHeight(x: number, z: number): number;
84759
84559
  /** Terrain-local normal (handedness applied to x). */
84760
84560
  normalAt(u: number, v: number, out: number[]): void;
84561
+ /**
84562
+ * Sets the tiles whose heights continue this tile's normals across its shared edges. Call it before any normal is read:
84563
+ * the normal textures are built once from normalAt.
84564
+ * @param neighbors The axis neighbours, or null when the tile stands alone.
84565
+ */
84566
+ setEdgeNeighbors(neighbors: TOOLKIT.ITerrainEdgeNeighbors): void;
84761
84567
  /** Fills the holes grid from TerrainImages pixels (R channel, > 127 = solid). Image row 0 = terrain z 0. */
84762
84568
  setHoles(pixels: Uint8ClampedArray, width: number): void;
84763
84569
  private cellX;
@@ -84813,8 +84619,19 @@ declare namespace TOOLKIT {
84813
84619
  static DecodeHeight(value: number, sizeY: number): number;
84814
84620
  /** Bilinear local height at normalised (u, v), both clamped to 0..1. */
84815
84621
  static SampleHeightBilinear(h: Uint16Array, R: number, sizeY: number, u: number, v: number): number;
84816
- /** Central difference at the nearest sample (one-sided on border samples), normalised [x, y, z] into out. */
84817
- static SampleNormal(h: Uint16Array, R: number, size: number[], u: number, v: number, out: number[]): void;
84622
+ /**
84623
+ * Central difference at the nearest sample, normalised [x, y, z] into out. A border sample continues across its shared
84624
+ * edge into a neighbouring tile, each height decoded with its own tile's scale, so both tiles compute the same normal
84625
+ * on the edge. A border sample without a neighbour stays one-sided.
84626
+ * @param h The tile's heights, z outer.
84627
+ * @param R The tile's samples per side.
84628
+ * @param size The tile's size [x, y, z] in metres.
84629
+ * @param u Unity-space normalised x, clamped to 0..1.
84630
+ * @param v Unity-space normalised z, clamped to 0..1.
84631
+ * @param out Receives the unit normal.
84632
+ * @param neighbors The tile's axis neighbours, or null when it stands alone.
84633
+ */
84634
+ static SampleNormal(h: Uint16Array, R: number, size: number[], u: number, v: number, out: number[], neighbors?: TOOLKIT.ITerrainEdgeNeighbors): void;
84818
84635
  /** handedness 0 → -x */
84819
84636
  static UnityToLocalX(x: number, handedness: number): number;
84820
84637
  /** handedness 0 → -yaw */
@@ -85169,7 +84986,8 @@ declare namespace TOOLKIT {
85169
84986
  }
85170
84987
  /**
85171
84988
  * Terrain trees (unity-terrain-system-parity D15-D18, D29, D41, Design Reference §4.4, §14). Every prototype LOD renderer
85172
- * becomes one thin-instance host parented to the terrain node. Each update selects a Unity LODGroup level per instance
84989
+ * becomes one thin-instance host parented to the terrain node. Hosts start small and grow to what is really drawn (D18), and
84990
+ * every tile's hosts draw one scene-owned copy of each prototype's geometry (D19). Each update selects a Unity LODGroup level per instance
85173
84991
  * (relative height, maxfulllod, 0.5 s dithered crossfade), culls by distance and frustum, and rewrites the host buffers.
85174
84992
  * Instances outside the frustum but inside the terrain's shadow reach still go to the casting hosts, so trees behind
85175
84993
  * the camera cast into view (D44). Instances are visited through a 64 m grid (D45). Tree colliders are one static
@@ -85187,6 +85005,12 @@ declare namespace TOOLKIT {
85187
85005
  private static readonly NO_PROBE_RECORD;
85188
85006
  /** cos(0.5 deg): a smaller dot between light directions counts as the light turning. */
85189
85007
  private static readonly LIGHT_TURN_DOT;
85008
+ /** The clone state a shared host must keep to draw as the renderer mesh does: winding, render group, layer, sort order, vertex colours, bones. */
85009
+ private static readonly HOST_DRAW_STATE;
85010
+ /** Per scene (uniqueId): one hidden mesh per "<templateid>|<lod>|<source uniqueId>", whose GPU buffers every tile's hosts share (D19). */
85011
+ private static PreparedHosts;
85012
+ /** The probe buffer a host holds now: growth replaces it, and the host's dispose must free the current one. */
85013
+ private static ProbeBuffers;
85190
85014
  /** Per-scene clones of prototype materials, keyed "<templateid>|<material uniqueId>" (D41), with a reference count. */
85191
85015
  private static _materials;
85192
85016
  private _owner;
@@ -85200,6 +85024,8 @@ declare namespace TOOLKIT {
85200
85024
  private _colliderShapes;
85201
85025
  private _distance;
85202
85026
  private _built;
85027
+ /** True once a host of this tile fell back to its own geometry, so the warning prints once per tile. */
85028
+ private _warnedUniqueHost;
85203
85029
  private _n;
85204
85030
  private _proto;
85205
85031
  private _local;
@@ -85270,14 +85096,24 @@ declare namespace TOOLKIT {
85270
85096
  * @returns A new array of caster meshes.
85271
85097
  */
85272
85098
  getCasterMeshes(): BABYLON.AbstractMesh[];
85273
- /** Host count and instances drawn per host (diagnostics). */
85099
+ /**
85100
+ * Host count, instances drawn per host, and instances the hosts and caster slots have room for (diagnostics).
85101
+ * @returns The numbers; capacity counts every host and slot.
85102
+ */
85274
85103
  getStats(): {
85275
85104
  hosts: number;
85276
85105
  instances: number;
85277
85106
  drawn: number;
85278
85107
  visibleHosts: number;
85279
85108
  colliders: boolean;
85109
+ capacity: number;
85280
85110
  };
85111
+ /**
85112
+ * How many prepared prototype geometries a scene holds (tests and diagnostics).
85113
+ * @param scene The scene.
85114
+ * @returns One per (template, LOD, source) in use, 0 when the scene has no trees.
85115
+ */
85116
+ static PreparedHostCount(scene: BABYLON.Scene): number;
85281
85117
  /**
85282
85118
  * Builds the tree instancer from the terrain contract: one camera host per LOD renderer of each prototype (plus the
85283
85119
  * caster slots of each casting host, terrain-performance D8), registers the shadow casters with the owner, decodes the
@@ -85288,9 +85124,9 @@ declare namespace TOOLKIT {
85288
85124
  /**
85289
85125
  * Creates the hosts of one prototype (§4.4 step 1): one thin-instance host per renderer mesh of each LOD level, with the
85290
85126
  * host's shadow-casting flag, its light-probe use and, for a casting host, its caster slots (terrain-performance D8).
85291
- * @param p The exported tree prototype.
85292
- * @param tpl The prototype's template node in the scene.
85293
- * @param cap The prototype's instance count (each host's capacity).
85127
+ * @param prototype The exported tree prototype.
85128
+ * @param template The prototype's template node in the scene.
85129
+ * @param instanceCount The prototype's instance count: the ceiling each host and slot can grow to (D18).
85294
85130
  * @returns The prototype's runtime data, or null when no LOD produced a host.
85295
85131
  */
85296
85132
  private buildPrototype;
@@ -85301,6 +85137,19 @@ declare namespace TOOLKIT {
85301
85137
  * TerrainProbePlugin) over `probes` (every record starts at "no probe") - and the probe plugin on its material(s).
85302
85138
  */
85303
85139
  static AttachProbeBuffer(host: BABYLON.Mesh, probes: Float32Array): BABYLON.Buffer;
85140
+ /**
85141
+ * One instanced buffer over a host's probe records, bound as the three vec4 views of TerrainProbePlugin.
85142
+ * @param host The host mesh.
85143
+ * @param probes The packed records, TerrainProbePlugin.STRIDE each.
85144
+ * @returns The new buffer.
85145
+ */
85146
+ private static CreateProbeBuffer;
85147
+ /**
85148
+ * Gives a grown host a probe buffer of its new size. The plugin stays attached, and the views' attribute names do not
85149
+ * change, so no shader recompiles.
85150
+ * @param host The host whose probes array was replaced.
85151
+ */
85152
+ private static ResizeProbeBuffer;
85304
85153
  /**
85305
85154
  * X10 fix loop 2: samples the scene's light-probe network once per instance (spatially ordered by the D45 grid so each
85306
85155
  * tetrahedral walk starts in the previous instance's cell), at the instance's world position (ProbeSampleHeight 0).
@@ -85357,12 +85206,49 @@ declare namespace TOOLKIT {
85357
85206
  * @throws Error when the source has no index buffer, no vertex buffers, or a vertex buffer without a GPU wrapper.
85358
85207
  */
85359
85208
  static CreateSharedHost(scene: BABYLON.Scene, source: BABYLON.Mesh, name: string): BABYLON.Mesh;
85209
+ /**
85210
+ * The mesh a renderer's geometry is drawn from: a copy baked into prototype space, in one interleaved buffer.
85211
+ * @param source The renderer's mesh.
85212
+ * @param templateWorldInverse The inverse world matrix of the prototype's template.
85213
+ * @param name The new mesh's name.
85214
+ * @returns The mesh, or null when the source cannot be cloned.
85215
+ */
85216
+ private static BakeHostGeometry;
85217
+ /**
85218
+ * The scene's one hidden copy of a prototype renderer's geometry (D19): it owns the GPU buffers every tile's hosts draw, so
85219
+ * a tile's dispose never frees another tile's geometry. Lives until the scene is disposed.
85220
+ * @param prototype The exported tree prototype.
85221
+ * @param lod The LOD level.
85222
+ * @param source The renderer's mesh.
85223
+ * @param templateWorldInverse The inverse world matrix of the prototype's template.
85224
+ * @returns The prepared mesh, or null when the source cannot be cloned.
85225
+ */
85226
+ private prepareHostGeometry;
85227
+ /**
85228
+ * Today's path for an engine without shared GPU buffers: the tile keeps its own geometry copy, so its trees never vanish.
85229
+ * @param source The renderer's mesh.
85230
+ * @param templateWorldInverse The inverse world matrix of the prototype's template.
85231
+ * @param name The host's name.
85232
+ * @param reason Why sharing failed, for the warning.
85233
+ * @returns The host, or null when the source cannot be cloned.
85234
+ */
85235
+ private createUniqueHost;
85236
+ /**
85237
+ * One camera host of this tile: the scene's prepared geometry (D19) with this tile's own instance buffers.
85238
+ * @param prototype The exported tree prototype.
85239
+ * @param lod The LOD level.
85240
+ * @param source The renderer's mesh.
85241
+ * @param templateWorldInverse The inverse world matrix of the prototype's template.
85242
+ * @param matrices The host's first instance matrices.
85243
+ * @param fades The host's first LOD fades.
85244
+ * @returns The host, or null when the source cannot be cloned.
85245
+ */
85360
85246
  private createHost;
85361
85247
  /**
85362
85248
  * Builds the CASTER_SLOTS caster-only meshes of a casting host (terrain-performance D8). When GPU sharing fails the host keeps
85363
85249
  * no slots and casts itself, as before.
85364
85250
  * @param host The casting host.
85365
- * @param capacity Instances each slot can hold (the prototype's instance count).
85251
+ * @param capacity Instances each slot can hold at first; it grows to the host's capacityCeiling (D18).
85366
85252
  */
85367
85253
  private createCasterSlots;
85368
85254
  /**
@@ -85384,6 +85270,7 @@ declare namespace TOOLKIT {
85384
85270
  /**
85385
85271
  * D41: one clone per (prototype, source material), named "<material>.<prototype>", with the foliage plugin attached.
85386
85272
  * T8: a SpeedTree 8 material on a host with wind vertex data gets its own clone without the MODE_TREE bend.
85273
+ * A Shader Graph tree gets no bend either, because only its graph moves it in Unity (TerrainFoliagePlugin.GraphOwnsMotion).
85387
85274
  * @param p The exported tree prototype.
85388
85275
  * @param lod The LOD level of the host.
85389
85276
  * @param source The renderer's material (a MultiMaterial is cloned per sub-material).
@@ -85528,12 +85415,19 @@ declare namespace TOOLKIT {
85528
85415
  private static KthSmallest;
85529
85416
  /**
85530
85417
  * Appends instance `instanceIndex` to a host or slot: its matrix, the fade, its probe SH when the target binds probes (a "no probe" record while the scene's network is switched off), and the
85531
- * instance's sphere in the target's terrain-local box. A full target ignores the instance.
85418
+ * instance's sphere in the target's terrain-local box. A full target grows (D18); one at its ceiling ignores the instance.
85532
85419
  * @param target The camera host or caster slot.
85533
85420
  * @param instanceIndex The instance index.
85534
85421
  * @param fade The LOD fade value (1 steady; signed crossfade weight otherwise).
85535
85422
  */
85536
85423
  private appendInstance;
85424
+ /**
85425
+ * Gives a full host or slot larger arrays, keeping the instances written so far (D18). The GPU buffers follow in uploadTarget.
85426
+ * @param target The camera host or caster slot.
85427
+ * @param ceiling The most instances the target can ever hold.
85428
+ * @returns False when the target is already at its ceiling.
85429
+ */
85430
+ private static GrowTarget;
85537
85431
  /**
85538
85432
  * True when any host of a prototype's LOD level casts shadows (billboard LODs and castshadows:false renderers do not).
85539
85433
  * @param hosts The instancer's hosts.
@@ -85560,6 +85454,21 @@ declare namespace TOOLKIT {
85560
85454
  * @param shadowOnly True when the instance is outside the view (state 2).
85561
85455
  */
85562
85456
  private writeCaster;
85457
+ /**
85458
+ * Binds a grown host's or slot's new arrays. Each set uploads its whole array, so the frame needs no partial update.
85459
+ * @param target The camera host or caster slot.
85460
+ */
85461
+ private static RebindGrownTarget;
85462
+ /**
85463
+ * Babylon's thinInstanceSetBuffer("matrix") keeps the old previous-world buffer (created on the first draw once the scene
85464
+ * needs previous world matrices, e.g. HDRP motion blur velocity), and every draw then writes the grown count into it - on
85465
+ * WebGPU that invalidates the whole frame. Rebuilt at the new size the way Babylon's own _thinInstanceUpdateBufferSize does:
85466
+ * merely disposing it leaves its four previousWorld vertex buffers on the geometry, and the next pipeline then counts them
85467
+ * as four separate buffers (past WebGPU's 8).
85468
+ * @param mesh The grown thin-instance mesh.
85469
+ * @param matrices Its new instance matrices.
85470
+ */
85471
+ static ResizePreviousMatrices(mesh: BABYLON.Mesh, matrices: Float32Array): void;
85563
85472
  /**
85564
85473
  * Uploads a host's or slot's instances written this update: count, matrices, fades, the probe buffer when bound, the bounding
85565
85474
  * box, and visibility (an empty target is hidden; a slot must be visible to cast). An empty slot is also disabled, and a
@@ -93156,6 +93065,515 @@ declare namespace TOOLKIT {
93156
93065
  private static crosses;
93157
93066
  }
93158
93067
  }
93068
+ declare namespace TOOLKIT {
93069
+ /** The exported curves of `urp.clouds`: 64 samples each over the layer height (CloudExportMath.CloudCurveSamples). */
93070
+ interface ICloudCurves {
93071
+ density?: number[];
93072
+ erosion?: number[];
93073
+ ambientocclusion?: number[];
93074
+ }
93075
+ /** One noise sidecar: its url, relative to the scene folder, and its volume edge in texels. */
93076
+ interface ICloudNoiseFile {
93077
+ url: string;
93078
+ size: number;
93079
+ }
93080
+ /**
93081
+ * The exported `urp.clouds` block (DR-4.6): the VolumetricClouds Volume fields under their lowercased names, the renderer
93082
+ * feature's resolution scale, the curves and the noise sidecars. Every value may be missing from an older export.
93083
+ */
93084
+ interface IUrpCloudsBlock {
93085
+ state?: boolean;
93086
+ localclouds?: boolean;
93087
+ resolutionscale?: number;
93088
+ densitymultiplier?: number;
93089
+ shapefactor?: number;
93090
+ shapescale?: number;
93091
+ shapeoffset?: number[];
93092
+ coveragevariation?: number;
93093
+ coveragepatternsize?: number;
93094
+ coveragegapamount?: number;
93095
+ coveragepatternoffset?: number[];
93096
+ erosionfactor?: number;
93097
+ erosionscale?: number;
93098
+ microerosion?: boolean;
93099
+ microerosionfactor?: number;
93100
+ microerosionscale?: number;
93101
+ bottomaltitude?: number;
93102
+ altituderange?: number;
93103
+ earthcurvature?: number;
93104
+ globalspeed?: number;
93105
+ globalorientation?: number;
93106
+ shapespeedmultiplier?: number;
93107
+ erosionspeedmultiplier?: number;
93108
+ altitudedistortion?: number;
93109
+ verticalshapewindspeed?: number;
93110
+ verticalerosionwindspeed?: number;
93111
+ cloudmapspeedmultiplier?: number;
93112
+ ambientlightprobedimmer?: number;
93113
+ sunlightdimmer?: number;
93114
+ erosionocclusion?: number;
93115
+ scatteringtint?: number[];
93116
+ powdereffectintensity?: number;
93117
+ multiscattering?: number;
93118
+ temporalaccumulationfactor?: number;
93119
+ perceptualblending?: number;
93120
+ numprimarysteps?: number;
93121
+ longraysamplemultiplier?: number;
93122
+ numlightsteps?: number;
93123
+ fadeinmode?: number;
93124
+ fadeinstart?: number;
93125
+ fadeindistance?: number;
93126
+ curves?: TOOLKIT.ICloudCurves;
93127
+ noise?: {
93128
+ worley?: TOOLKIT.ICloudNoiseFile;
93129
+ erosion?: TOOLKIT.ICloudNoiseFile;
93130
+ };
93131
+ }
93132
+ /** The two `urp.sky` fields the clouds read: the planet and the sun's intensity scale. */
93133
+ interface ICloudSkyFields {
93134
+ planet?: {
93135
+ radius?: number;
93136
+ renderingspace?: number;
93137
+ center?: number[];
93138
+ };
93139
+ sunintensityscale?: number;
93140
+ }
93141
+ /** One tier's march settings (DR-6.4). */
93142
+ interface ICloudTierSettings {
93143
+ /** Cloud target size as a fraction of the render size. */
93144
+ resolutionScale: number;
93145
+ /** Primary march steps. */
93146
+ primarySteps: number;
93147
+ /** How much longer rays may multiply their step count. */
93148
+ longRayMultiplier: number;
93149
+ /** Light march steps toward the sun. */
93150
+ lightSteps: number;
93151
+ }
93152
+ /**
93153
+ * unity-gaia-terrain-port T19 / T20: the pure maths of the volumetric clouds - shell intersection, step size, tier settings and
93154
+ * the curve texture - free of Babylon so the tests run it without a scene.
93155
+ */
93156
+ class VolumetricCloudsMath {
93157
+ /** The lowest tier: clouds are never switched off, only coarser. */
93158
+ static readonly LowestTier: number;
93159
+ /**
93160
+ * Where a ray enters and leaves the cloud shell (the local-clouds case of `IntersectCloudVolume`).
93161
+ * @param rayOrigin - Ray origin in planet space (relative to the planet centre), metres.
93162
+ * @param rayDirection - Normalised ray direction.
93163
+ * @param innerRadius - Radius of the layer bottom, metres from the planet centre.
93164
+ * @param outerRadius - Radius of the layer top, metres from the planet centre.
93165
+ * @param planetRadius - Planet radius for the earth-shadow test below the layer. Defaults to `innerRadius` (no test lost for a ray going up).
93166
+ * @returns `[entry, exit]` in metres along the ray, or null when the ray misses the shell or the planet hides it.
93167
+ */
93168
+ static ShellInterval(rayOrigin: number[], rayDirection: number[], innerRadius: number, outerRadius: number, planetRadius?: number): number[];
93169
+ /**
93170
+ * The primary step length before the long-ray refinement (`TraceVolumetricRay`).
93171
+ * @param shellLength - Metres of the ray inside the shell.
93172
+ * @param steps - Primary step count.
93173
+ * @param maximumStep - The largest step, metres (layer thickness / 8).
93174
+ * @returns The step length in metres.
93175
+ */
93176
+ static StepSize(shellLength: number, steps: number, maximumStep: number): number;
93177
+ /**
93178
+ * The largest primary step (`_MaxStepSize`, layer thickness / 8), lengthened when a tier marches fewer steps than authored so
93179
+ * the march still reaches as far as Unity's, up to CLOUD_MAX_STEP_STRETCH times.
93180
+ * @param altitudeRange - Layer thickness, metres.
93181
+ * @param authoredSteps - The Volume's primary steps (missing gives no stretch).
93182
+ * @param tierSteps - The tier's primary steps.
93183
+ * @returns The largest step, metres.
93184
+ */
93185
+ static MaximumStep(altitudeRange: number, authoredSteps: number, tierSteps: number): number;
93186
+ /**
93187
+ * The march settings of one tier (DR-6.4): every value is the authored one capped by the tier's CLOUD_TIER_CAPS row. Tier 0 caps
93188
+ * at the browser ceiling; tiers 1 and 2 lower the resolution, long-ray refinement and light steps but keep 64 primary steps.
93189
+ * @param tier - 0, 1 or 2 (clamped).
93190
+ * @param authored - The `urp.clouds` block.
93191
+ * @returns The settings.
93192
+ */
93193
+ static TierSettings(tier: number, authored: TOOLKIT.IUrpCloudsBlock): TOOLKIT.ICloudTierSettings;
93194
+ /**
93195
+ * The tier clouds start at: 1 on a phone-width viewport or a GPU whose textures stop below 8192, otherwise 0.
93196
+ * @param maximumTextureSize - `engine.getCaps().maxTextureSize`.
93197
+ * @param viewportCssWidth - The canvas width in CSS pixels.
93198
+ * @returns The starting tier.
93199
+ */
93200
+ static StartTier(maximumTextureSize: number, viewportCssWidth: number): number;
93201
+ /**
93202
+ * True when the camera moved far enough in one frame to be a cut, so the temporal history no longer matches.
93203
+ * @param previousPosition - Last frame's camera position, or null on the first frame.
93204
+ * @param currentPosition - This frame's camera position.
93205
+ * @returns True for a cut (or the first frame).
93206
+ */
93207
+ static IsCameraCut(previousPosition: number[], currentPosition: number[]): boolean;
93208
+ /**
93209
+ * The 64 x 1 curve texture (`PrepareCustomLutData`): density in red (zero at both ends), erosion in green, one minus ambient
93210
+ * occlusion in blue, each clamped to 0..1. Missing curves give white, as the cloud feature does without a density curve.
93211
+ * @param density - 64 density samples over the layer height.
93212
+ * @param erosion - 64 erosion samples.
93213
+ * @param ambientOcclusion - 64 ambient occlusion samples.
93214
+ * @returns RGBA floats, 64 texels.
93215
+ */
93216
+ static PackCurves(density: number[], erosion: number[], ambientOcclusion: number[]): Float32Array;
93217
+ /**
93218
+ * Both hits of a sphere centred on the planet (`IntersectSphere`), or a negative pair when the ray misses.
93219
+ * @param sphereRadius - Sphere radius, metres.
93220
+ * @param cosChi - Cosine between the ray and the up vector at the origin.
93221
+ * @param radialDistance - Distance of the origin from the planet centre, metres.
93222
+ * @returns `[near, far]` distances along the ray.
93223
+ */
93224
+ private static IntersectSphere;
93225
+ }
93226
+ /**
93227
+ * unity-gaia-terrain-port T20 / T21 (DR-6.4, amended): decides the cloud tier from what a tier saves, not from the whole frame.
93228
+ * Frame times are averaged over windows of CLOUD_TIER_WINDOW_FRAMES frames. A second steady window over CLOUD_TIER_BUDGET_MS steps
93229
+ * down one tier on trial; if the next window is not at least CLOUD_TIER_MINIMUM_SAVING faster, the clouds were not what made the frame
93230
+ * slow, so the previous tier comes back and the tier stays there for the scene. A step that saves time stays, and a later slow
93231
+ * window may try the next tier. The tier never goes above the starting tier, and clouds are never switched off.
93232
+ */
93233
+ class VolumetricCloudsTier {
93234
+ /** The tier now drawn. */
93235
+ tier: number;
93236
+ /** True once a trial step saved nothing: the tier no longer changes. */
93237
+ isSettled: boolean;
93238
+ private windowMilliseconds;
93239
+ private windowFrames;
93240
+ /** The mean frame time of the window before the step on trial, or 0 when no step is on trial. */
93241
+ private meanBeforeStep;
93242
+ /** The previous window's mean frame time, or 0 before the first window. */
93243
+ private previousMean;
93244
+ /**
93245
+ * Starts tracking at a tier.
93246
+ * @param startTier - The starting tier (VolumetricCloudsMath.StartTier).
93247
+ */
93248
+ constructor(startTier: number);
93249
+ /**
93250
+ * Adds one frame.
93251
+ * @param frameMilliseconds - The frame's duration (engine.getDeltaTime()).
93252
+ * @returns True when this frame closed a window that changed the tier (a trial step down, or the restore of one).
93253
+ */
93254
+ addFrame(frameMilliseconds: number): boolean;
93255
+ }
93256
+ /**
93257
+ * unity-gaia-terrain-port T19 / T20 (D16): the URP volumetric clouds (`urp.clouds`) drawn in the browser. One fragment pass marches
93258
+ * the clouds into a half-float target at the authored resolution scale, limited by the camera depth copy, and a full-screen mesh
93259
+ * composites them as the first transparent of the main rendering group, so water draws over the clouds and terrain hides them.
93260
+ * A temporal pass reprojects last frame's clouds and blends them in (`temporalaccumulationfactor`), and the march settings step
93261
+ * down a tier when frames run slow (DR-6.4).
93262
+ * One instance per scene, on `scene._tkVolumetricClouds`. Cloud shadows on the ground and the clouds' own ambient probe are not
93263
+ * carried (the export reports it).
93264
+ */
93265
+ class VolumetricClouds {
93266
+ /** The composite mesh's name. */
93267
+ static readonly MeshName: string;
93268
+ /**
93269
+ * Creates the scene's clouds when the export carries a `urp.clouds` block and the engine can render half-float targets.
93270
+ * @param scene - The scene being loaded.
93271
+ * @param metadata - The scene metadata.
93272
+ * @param root - The scene's root url, which the noise urls are relative to.
93273
+ * @returns The clouds, or null when there are none to draw.
93274
+ */
93275
+ static TryCreate(scene: BABYLON.Scene, metadata: unknown, root: string): TOOLKIT.VolumetricClouds;
93276
+ /**
93277
+ * The scene's clouds.
93278
+ * @param scene - The scene.
93279
+ * @returns The live clouds, or null.
93280
+ */
93281
+ static Get(scene: BABYLON.Scene): TOOLKIT.VolumetricClouds;
93282
+ /** The scene the clouds draw in. */
93283
+ readonly scene: BABYLON.Scene;
93284
+ /** The exported `urp.clouds` block. */
93285
+ readonly block: TOOLKIT.IUrpCloudsBlock;
93286
+ /** True once disposed. */
93287
+ disposed: boolean;
93288
+ /** The tier now drawn (DR-6.4). */
93289
+ tier: number;
93290
+ private readonly sky;
93291
+ private readonly root;
93292
+ private readonly isLocal;
93293
+ /** True when the live sky draws aerial perspective, so the march hazes the clouds at their distance (`CLOUD_AERIAL`). */
93294
+ private hasAerial;
93295
+ /** Bound to `apLut` until the sky's aerial perspective exists (a 1 x 1 x 1 black layer). */
93296
+ private placeholderAerial;
93297
+ private readonly planetRadius;
93298
+ private readonly planetCenter;
93299
+ private readonly scatteringTint;
93300
+ private settings;
93301
+ private worleyTexture;
93302
+ private erosionTexture;
93303
+ private curveTexture;
93304
+ private placeholderDepth;
93305
+ private marchTarget;
93306
+ private renderer;
93307
+ private marchPass;
93308
+ private temporalPass;
93309
+ /** Ping-pong history at cloud resolution: the temporal pass reads one and writes the other. */
93310
+ private readonly historyTargets;
93311
+ private historyIndex;
93312
+ private hasHistory;
93313
+ private compositeMesh;
93314
+ private compositeMaterial;
93315
+ private isReady;
93316
+ private isPending;
93317
+ private preExposure;
93318
+ private preExposureBinding;
93319
+ private frameSeed;
93320
+ private readonly windOffset;
93321
+ private verticalShapeOffset;
93322
+ private verticalErosionOffset;
93323
+ private sceneDepth;
93324
+ private beforeRenderObserver;
93325
+ private afterRenderObserver;
93326
+ private tierTracker;
93327
+ private targetWidth;
93328
+ private targetHeight;
93329
+ private lastCamera;
93330
+ private sunLight;
93331
+ private ambientSource;
93332
+ private ambientCaptureCount;
93333
+ private readonly previousEye;
93334
+ private readonly currentEye;
93335
+ private hasPreviousEye;
93336
+ private beforeTargetsObserver;
93337
+ private afterTargetsObserver;
93338
+ private disposeObserver;
93339
+ private readonly mirror;
93340
+ private readonly inverseViewProjection;
93341
+ /** Last frame's view-projection (Babylon space), for the temporal reprojection. */
93342
+ private readonly previousViewProjection;
93343
+ /** Last frame's view-projection taking Unity-space points, bound to the temporal pass. */
93344
+ private readonly previousViewProjectionUnity;
93345
+ private readonly sunDirection;
93346
+ private readonly cameraForward;
93347
+ /** The camera's local forward axis: +Z, or -Z in a right-handed scene. */
93348
+ private readonly localForward;
93349
+ private readonly ambientTop;
93350
+ private readonly ambientBottom;
93351
+ /**
93352
+ * Builds the passes and starts loading the noise. The scene's loading is held until both noise volumes are uploaded and every
93353
+ * shader compiled, so the first frame has clouds and no compile follows the reveal.
93354
+ * @param scene - The scene.
93355
+ * @param block - The `urp.clouds` block.
93356
+ * @param sky - The `urp.sky` block (planet), or null.
93357
+ * @param root - The scene's root url.
93358
+ */
93359
+ private constructor();
93360
+ /** Releases every target, texture, mesh and observer, and the scene's loading if it is still held. */
93361
+ dispose(): void;
93362
+ /** Creates the curve texture, the march target and pass, and the composite mesh. */
93363
+ private createPasses;
93364
+ /**
93365
+ * One half-float RGBA target at cloud resolution, sampled bilinearly and clamped.
93366
+ * @param name - Target name.
93367
+ * @param textureType - Half float, or float where half-float targets cannot render.
93368
+ * @returns The target.
93369
+ */
93370
+ private createCloudTarget;
93371
+ /**
93372
+ * The 64 x 1 half-float curve texture (density, erosion, ambient occlusion), sampled with a repeating bilinear sampler as
93373
+ * Unity's `s_linear_repeat_sampler` does.
93374
+ * @returns The texture.
93375
+ */
93376
+ private createCurveTexture;
93377
+ /**
93378
+ * The composite: a clip-space quad drawn as the first transparent of the default rendering group, blending
93379
+ * `scene x transmittance + scattering`. It is hidden while render targets (probes, reflections) draw.
93380
+ * @param language - The shader language of the engine.
93381
+ */
93382
+ private createCompositeMesh;
93383
+ /**
93384
+ * Loads both noise sidecars into wrapping single-channel 3D textures.
93385
+ * @returns True when both loaded. On a failure one warning prints and the clouds do not draw (the sky still does).
93386
+ */
93387
+ private loadNoise;
93388
+ /**
93389
+ * One noise volume: `size³` bytes, x fastest, then y, then slice, as CloudExportMath.FlipbookToVolume wrote them.
93390
+ * @param name - Texture name.
93391
+ * @param buffer - The sidecar bytes.
93392
+ * @param size - Volume edge in texels.
93393
+ * @returns The texture, or null (with one warning) when the file has the wrong length.
93394
+ */
93395
+ private createNoiseTexture;
93396
+ /** Polls until the noise is uploaded and every shader compiled, then starts drawing and releases the scene's loading. */
93397
+ private waitUntilReady;
93398
+ /** Lets the scene finish loading (once). */
93399
+ private releasePending;
93400
+ /**
93401
+ * Advances the wind, sizes the targets, marches the clouds and blends in the reprojected history. The composite then reads
93402
+ * the new history (or the march itself when the accumulation factor is off, as Unity's `denoiseClouds`).
93403
+ */
93404
+ private render;
93405
+ /**
93406
+ * True when the colour buffer holds display-encoded values: a non-parity scene whose image processing runs in the materials
93407
+ * (the sky encodes for display and the fog pass decodes the same way, HdrpPhysicallyBasedSky.encodesForDisplay).
93408
+ * @returns True to encode the composite.
93409
+ */
93410
+ private isDisplayEncoded;
93411
+ /**
93412
+ * Resets the temporal history on the first frame, a camera switch or a cut (a move above CLOUD_CAMERA_CUT_METERS in one frame).
93413
+ * @param camera - The active camera.
93414
+ */
93415
+ private trackCamera;
93416
+ /**
93417
+ * DR-6.4: one frame into the tier window; a slow window steps the clouds down one tier, resizes the targets once and reports it.
93418
+ */
93419
+ private updateTier;
93420
+ /** Reports once each authored value the starting tier lowers (tier 0 holds the browser ceiling). */
93421
+ private reportLoweredSettings;
93422
+ /**
93423
+ * Accumulates the wind offsets like VolumetricCloudsURP: kilometres per hour along the global orientation, wrapped.
93424
+ * @param deltaSeconds - Seconds since the last frame.
93425
+ */
93426
+ private advanceWind;
93427
+ /** Resizes the cloud targets (once) when the render size or the tier's resolution scale changed; the history restarts. */
93428
+ private resizeTargets;
93429
+ /**
93430
+ * Sets the cloud target size: the render size times the tier's resolution scale, at least 1 pixel.
93431
+ * @returns True when the size changed.
93432
+ */
93433
+ private updateTargetSize;
93434
+ /**
93435
+ * Binds the march uniforms. Each vec4 packs (VolumetricCloudsURP.UpdateMaterialProperties):
93436
+ * cloudEye = camera position · cloudForward = (camera forward, x mirror sign) · cloudCamera = (far plane, depth copy bound, frame seed,
93437
+ * pre-exposure) · cloudPlanet = (planet centre, radius) · cloudLayer = (bottom radius, top radius, largest step, primary steps)
93438
+ * · cloudSteps = (long ray multiplier, light steps, fade start, fade distance) · cloudShape = (shape scale, shape factor,
93439
+ * erosion scale, erosion factor) · cloudDetail = (erosion occlusion, micro erosion scale, micro erosion factor, density)
93440
+ * · cloudShapeOffset = (offset x, offset z, offset y, altitude distortion) · cloudWind = (wind direction, wind offset)
93441
+ * · cloudWindSpeed = (shape speed, erosion speed, vertical shape offset, vertical erosion offset) · cloudCoverage = (variation,
93442
+ * inverse pattern size, gap amount) · cloudScattering = (multi scattering, powder) · cloudTint · cloudSunDirection (toward the
93443
+ * sun) · cloudSunColor · cloudAmbientTop / Bottom. Positions and directions are mirrored into Unity's space.
93444
+ * @param effect - The march effect.
93445
+ */
93446
+ private bindMarch;
93447
+ /**
93448
+ * The sun and ambient terms: the first interacting directional light's colour (already attenuated by the sky) times its
93449
+ * intensity, the sky's sun scale and the sun dimmer, and the sky's ambient probe evaluated up and down times the probe dimmer.
93450
+ * @param effect - The march effect.
93451
+ * @param mirrorX - -1 in a right-handed scene, else 1.
93452
+ */
93453
+ private bindLighting;
93454
+ /**
93455
+ * Binds the live sky's aerial perspective (its froxel LUT, camera and atmosphere uniforms) for the haze at cloud distance.
93456
+ * Until the sky has built the LUT (its first frames) the placeholder is bound and the haze is skipped.
93457
+ * @param effect - The march effect.
93458
+ */
93459
+ private bindAerial;
93460
+ /**
93461
+ * The sun: the first interacting directional light, looked up again only when the cached one is gone or switched off. Its
93462
+ * world direction (parent rotation applied) is written to `sunDirection` without allocating.
93463
+ * @returns The sun, or null when the scene has no enabled directional light.
93464
+ */
93465
+ private resolveSun;
93466
+ /**
93467
+ * Re-evaluates the ambient up and down only when its source changed (the live sky captured again, or a new environment), so
93468
+ * the per-frame bind does not allocate: the live sky's ambient probe, else the environment's polynomial, else the scene's
93469
+ * ambient colour.
93470
+ */
93471
+ private refreshAmbient;
93472
+ /**
93473
+ * Binds the temporal pass: this frame's march, last frame's history and view-projection (into Unity's space), and
93474
+ * `cloudCamera` = (far plane, depth copy bound, history valid, accumulation factor).
93475
+ * @param effect - The temporal effect.
93476
+ */
93477
+ private bindTemporal;
93478
+ /**
93479
+ * Unity hands the shader `white - tint x 0.75` through Material.SetColor, which linearises it.
93480
+ * @param tint - The authored scattering tint (sRGB components).
93481
+ * @returns The linear extinction tint.
93482
+ */
93483
+ private static LinearScatteringTint;
93484
+ /**
93485
+ * The canvas width in CSS pixels (the render width when there is no canvas).
93486
+ * @param scene - The scene.
93487
+ * @returns The width.
93488
+ */
93489
+ private static CanvasCssWidth;
93490
+ }
93491
+ }
93492
+ declare namespace TOOLKIT {
93493
+ /**
93494
+ * unity-gaia-terrain-port T19 (D16): the GLSL and WGSL sources of the volumetric clouds - a line-for-line fragment port of the
93495
+ * cloud march (`TraceVolumetricRay`, `EvaluateCloudProperties`, the two-octave light march `EvaluateSunTransmittance`) and of the
93496
+ * combine pass. Every shader is registered in `ShaderStore` (GLSL) and `ShaderStoreWGSL` (WGSL) as twins.
93497
+ * No `;` inside `//` comments of a shader string, no sampler function parameters, WGSL samplers at module scope.
93498
+ * Defines: `CLOUD_LOCAL` (the camera flies through the layer, Unity's `_LOCAL_VOLUMETRIC_CLOUDS`), `CLOUD_MICRO_EROSION`, and
93499
+ * `CLOUD_AERIAL`: the sky's aerial perspective at the mean cloud distance, as Unity's clouds combine pass with
93500
+ * `PHYSICALLY_BASED_SKY` (VolumetricClouds.shader, `EvaluateAtmosphericScattering` at cloud depth). It reuses the fog pass's
93501
+ * shared function (HdrpFogPass.AerialPerspectiveGlsl / Wgsl), so clouds take the in-scatter and extinction terrain takes at
93502
+ * the same distance.
93503
+ */
93504
+ class VolumetricCloudsShaders {
93505
+ /** The march pass: scattering in rgb, transmittance in alpha, one fragment per cloud-target pixel. */
93506
+ static readonly MarchName: string;
93507
+ /** The full-screen composite drawn as the first transparent. */
93508
+ static readonly CompositeName: string;
93509
+ /** The temporal pass: reprojects last frame's clouds and blends them in (pass 3, Temporal Denoising). */
93510
+ static readonly TemporalName: string;
93511
+ /** Every vec4 / mat4 uniform of the temporal pass. */
93512
+ static readonly TemporalUniforms: string[];
93513
+ /** The samplers of the temporal pass. */
93514
+ static readonly TemporalSamplers: string[];
93515
+ /** Every vec4 / mat4 uniform of the march pass, in declaration order. */
93516
+ static readonly MarchUniforms: string[];
93517
+ /** The samplers of the march pass. */
93518
+ static readonly MarchSamplers: string[];
93519
+ /** The extra sampler of the march when `CLOUD_AERIAL` is on: the live sky's aerial perspective froxels. */
93520
+ static readonly AerialSampler: string;
93521
+ /** The extra uniform of the march when `CLOUD_AERIAL` is on: (camera - planet centre, 1 when the LUT is bound). */
93522
+ static readonly AerialCameraUniform: string;
93523
+ private static registered;
93524
+ /** Registers every cloud shader once (GLSL in ShadersStore, WGSL in ShadersStoreWGSL). */
93525
+ static Register(): void;
93526
+ /**
93527
+ * Every source, GLSL then WGSL (tests scan them for `;` inside `//` comments).
93528
+ * @returns The shader strings.
93529
+ */
93530
+ static AllSources(): string[];
93531
+ /** The march pass uniforms. The packing of each vec4 is documented on `VolumetricClouds.bindMarch`. */
93532
+ private static GlslMarchUniforms;
93533
+ /** Constants of VolumetricCloudsUtilities.hlsl. */
93534
+ private static GlslConstants;
93535
+ /** Ray and shell geometry: sphere intersections in planet space (`cloudPlanet.xyz` is the planet centre, `.w` its radius). */
93536
+ private static GlslGeometry;
93537
+ /** Cloud density: coverage pattern, shape and erosion noise, the curve texture (`EvaluateCloudProperties`). */
93538
+ private static GlslDensity;
93539
+ /** Lighting: phase function, powder effect and the light march toward the sun (`EvaluateSunTransmittance`, `EvaluateCloud`). */
93540
+ private static GlslLighting;
93541
+ /** The aerial perspective declarations and functions of the march (only under `CLOUD_AERIAL`). */
93542
+ private static GlslAerial;
93543
+ /** The march pass (`frag` of pass 0 and `TraceVolumetricRay`). */
93544
+ private static GlslMarch;
93545
+ /** A clip-space quad: positions are already in clip space, the uv follows them. */
93546
+ private static GlslCompositeVertex;
93547
+ /**
93548
+ * Pass 1 (Combine): blending gives scene x transmittance + scattering (premultiplied, alpha = 1 - transmittance). When the
93549
+ * colour buffer holds display-encoded values (`cloudDisplayEncoded` = 1: a non-parity scene whose image processing runs in
93550
+ * the materials, as the sky and fog pass assume), the wanted `encode(L x T + S)` is not linear in the encoded scene `d`,
93551
+ * so the blend uses the straight line through its two ends: `encode(S)` at d = 0 and `encode(T + S)` at d = 1, that is
93552
+ * `encode(S) + d x (encode(T + S) - encode(S))` (the slope from the scattering's luminance). It is exact where the cloud
93553
+ * is clear or opaque and within a few hundredths over a bright sky, where a plain `T^(1/gamma)` overshoots cloud edges.
93554
+ */
93555
+ private static GlslCompositeFragment;
93556
+ /**
93557
+ * Pass 3 (Temporal Denoising): the history is reprojected with last frame's view-projection at the distance where the ray
93558
+ * enters the cloud layer (or the scene depth, when nearer), clamped to the current colour's 5-tap box and blended in by
93559
+ * the accumulation factor, faded by the reprojection velocity. Transmittance stays the current frame's, as in Unity.
93560
+ * `cloudCamera` = (far plane, depth copy bound, history valid, accumulation factor), `cloudTexel` = (1 / width, 1 / height).
93561
+ */
93562
+ private static GlslTemporal;
93563
+ /** The march pass uniforms (WGSL twin of GlslMarchUniforms). */
93564
+ private static WgslMarchUniforms;
93565
+ private static WgslConstants;
93566
+ private static WgslGeometry;
93567
+ private static WgslDensity;
93568
+ private static WgslLighting;
93569
+ /** WGSL twin of GlslAerial. */
93570
+ private static WgslAerial;
93571
+ private static WgslMarch;
93572
+ private static WgslCompositeVertex;
93573
+ private static WgslCompositeFragment;
93574
+ private static WgslTemporal;
93575
+ }
93576
+ }
93159
93577
  /** Babylon Toolkit Namespace */
93160
93578
  declare namespace TOOLKIT {
93161
93579
  /**