babylonjs-loaders 9.22.2 → 9.25.0

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.
@@ -448,11 +448,13 @@ abstract class GLTFLoaderOptions extends GLTFLoaderBaseOptions {
448
448
  */
449
449
  abstract onValidated?: (results: GLTF2.IGLTFValidationResults) => void;
450
450
  /**
451
- * Function called before loading a url referenced by the asset.
452
- * @param url url referenced by the asset
453
- * @returns Async url to load
451
+ * Function called before loading a URL referenced by the asset.
452
+ * Setting this function allows parent-relative asset URIs and makes the callback responsible for URI safety.
453
+ * @param url The URL referenced by the asset
454
+ * @param rootUrl The root URL of the asset, if available
455
+ * @returns A promise that resolves to the URL to load
454
456
  */
455
- preprocessUrlAsync: (url: string) => Promise<string>;
457
+ preprocessUrlAsync: (url: string, rootUrl?: string) => Promise<string>;
456
458
  }
457
459
  /**
458
460
  * File loader for loading glTF files into a scene.
@@ -467,6 +469,8 @@ export class GLTFFileLoader extends GLTFLoaderOptions implements IDisposable, IS
467
469
  * @param options The options for the loader
468
470
  */
469
471
  constructor(options?: Partial<Readonly<GLTFLoaderOptions>>);
472
+ /** @internal */
473
+ get _isPreprocessUrlAsyncSet(): boolean;
470
474
  /**
471
475
  * Raised when the asset has been parsed
472
476
  */
@@ -755,6 +759,7 @@ export * from "babylonjs-loaders/glTF/2.0/glTFLoader.pure";
755
759
  export * from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
756
760
  export * from "babylonjs-loaders/glTF/2.0/glTFLoaderExtensionRegistry";
757
761
  export * from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
762
+ export * from "babylonjs-loaders/glTF/2.0/glTFLoaderAnimation.pure";
758
763
  export * from "babylonjs-loaders/glTF/2.0/openpbrMaterialLoadingAdapter";
759
764
  export * from "babylonjs-loaders/glTF/2.0/pbrMaterialLoadingAdapter";
760
765
  export * from "babylonjs-loaders/glTF/2.0/Extensions/pure";
@@ -3081,7 +3086,8 @@ export interface IGLTFLoaderExtension extends IGLTFBaseLoaderExtension, IDisposa
3081
3086
  }
3082
3087
 
3083
3088
  }
3084
- declare module "babylonjs-loaders/glTF/2.0/glTFLoaderAnimation" {
3089
+ declare module "babylonjs-loaders/glTF/2.0/glTFLoaderAnimation.pure" {
3090
+ /** This file must only contain pure code and pure imports */
3085
3091
  import { Animation } from "babylonjs/Animations/animation.pure";
3086
3092
  import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector.pure";
3087
3093
  import { INode } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
@@ -3124,6 +3130,14 @@ export class WeightAnimationPropertyInfo extends AnimationPropertyInfo {
3124
3130
  babylonAnimation: Animation;
3125
3131
  }[];
3126
3132
  }
3133
+ /**
3134
+ * Registers the core glTF animation interpolation mappings.
3135
+ */
3136
+ export function RegisterGLTFLoaderAnimation(): void;
3137
+
3138
+ }
3139
+ declare module "babylonjs-loaders/glTF/2.0/glTFLoaderAnimation" {
3140
+ export * from "babylonjs-loaders/glTF/2.0/glTFLoaderAnimation.pure";
3127
3141
 
3128
3142
  }
3129
3143
  declare module "babylonjs-loaders/glTF/2.0/glTFLoader.pure" {
@@ -3131,7 +3145,7 @@ import { IndicesArray, Nullable } from "babylonjs/types";
3131
3145
  import { Camera } from "babylonjs/Cameras/camera.pure";
3132
3146
  import { Animation } from "babylonjs/Animations/animation";
3133
3147
  import { IAnimatable } from "babylonjs/Animations/animatable.interface";
3134
- import { AnimationGroup } from "babylonjs/Animations/animationGroup";
3148
+ import { AnimationGroup } from "babylonjs/Animations/animationGroup.pure";
3135
3149
  import { Material } from "babylonjs/Materials/material";
3136
3150
  import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
3137
3151
  import { TransformNode } from "babylonjs/Meshes/transformNode.pure";
@@ -3147,7 +3161,7 @@ import { IDataBuffer } from "babylonjs/Misc/dataReader";
3147
3161
  import { Light } from "babylonjs/Lights/light";
3148
3162
  import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
3149
3163
  import { AssetContainer } from "babylonjs/assetContainer";
3150
- import { AnimationPropertyInfo } from "babylonjs-loaders/glTF/2.0/glTFLoaderAnimation";
3164
+ import { AnimationPropertyInfo } from "babylonjs-loaders/glTF/2.0/glTFLoaderAnimation.pure";
3151
3165
  import { IObjectInfo } from "babylonjs/ObjectModel/objectModelInterfaces";
3152
3166
  import { GLTFExtensionFactory } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtensionRegistry";
3153
3167
  import { IInterpolationPropertyInfo } from "babylonjs/FlowGraph/typeDefinitions";
@@ -3820,6 +3834,7 @@ export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_node_selectability.pure
3820
3834
  export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_node_hoverability.pure";
3821
3835
  export * from "babylonjs-loaders/glTF/2.0/Extensions/ExtrasAsMetadata.pure";
3822
3836
  export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_interactivity/pure";
3837
+ export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_animation_pointer.data.pure";
3823
3838
 
3824
3839
  }
3825
3840
  declare module "babylonjs-loaders/glTF/2.0/Extensions/objectModelMapping" {
@@ -5112,6 +5127,11 @@ export class KHR_node_visibility implements IGLTFLoaderExtension {
5112
5127
  onReady(): void;
5113
5128
  dispose(): void;
5114
5129
  }
5130
+ /**
5131
+ * @internal
5132
+ * Registers KHR_node_visibility runtime dependencies without changing the extension registry.
5133
+ */
5134
+ export function _RegisterKHRNodeVisibilityRuntime(): void;
5115
5135
  /**
5116
5136
  * Registers the KHR_node_visibility glTF loader extension.
5117
5137
  * Safe to call multiple times; only the first call has an effect.
@@ -5163,6 +5183,11 @@ export class KHR_node_selectability implements IGLTFLoaderExtension {
5163
5183
  onReady(): Promise<void>;
5164
5184
  dispose(): void;
5165
5185
  }
5186
+ /**
5187
+ * @internal
5188
+ * Registers KHR_node_selectability runtime dependencies without changing the extension registry.
5189
+ */
5190
+ export function _RegisterKHRNodeSelectabilityRuntime(): void;
5166
5191
  /**
5167
5192
  * Registers the KHR_node_selectability glTF loader extension.
5168
5193
  * Safe to call multiple times; only the first call has an effect.
@@ -5215,6 +5240,11 @@ export class KHR_node_hoverability implements IGLTFLoaderExtension {
5215
5240
  onReady(): Promise<void>;
5216
5241
  dispose(): void;
5217
5242
  }
5243
+ /**
5244
+ * @internal
5245
+ * Registers KHR_node_hoverability runtime dependencies without changing the extension registry.
5246
+ */
5247
+ export function _RegisterKHRNodeHoverabilityRuntime(): void;
5218
5248
  /**
5219
5249
  * Registers the KHR_node_hoverability glTF loader extension.
5220
5250
  * Safe to call multiple times; only the first call has an effect.
@@ -6620,6 +6650,11 @@ export class KHR_interactivity implements IGLTFLoaderExtension {
6620
6650
  * populates the object model with the interactivity extension
6621
6651
  */
6622
6652
  export function _AddInteractivityObjectModel(scene: Scene): void;
6653
+ /**
6654
+ * @internal
6655
+ * Registers KHR_interactivity runtime dependencies without changing the extension registry.
6656
+ */
6657
+ export function _RegisterKHRInteractivityRuntime(): void;
6623
6658
  /**
6624
6659
  * Registers the KHR_interactivity glTF loader extension.
6625
6660
  * Safe to call multiple times; only the first call has an effect.
@@ -6820,9 +6855,17 @@ export class KHR_animation_pointer implements IGLTFLoaderExtension {
6820
6855
  */
6821
6856
  export function RegisterKHR_animation_pointer(): void;
6822
6857
 
6858
+ }
6859
+ declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_animation_pointer.data.pure" {
6860
+ /**
6861
+ * Registers the KHR_animation_pointer interpolation mappings.
6862
+ * @internal
6863
+ */
6864
+ export function _RegisterKHRAnimationPointerData(): void;
6865
+
6823
6866
  }
6824
6867
  declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_animation_pointer.data" {
6825
- export {};
6868
+ export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_animation_pointer.data.pure";
6826
6869
 
6827
6870
  }
6828
6871
  declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_animation_pointer" {
@@ -6832,7 +6875,6 @@ declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_animation_pointer" {
6832
6875
  */
6833
6876
  export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_animation_pointer.types";
6834
6877
  export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_animation_pointer.pure";
6835
- import "babylonjs-loaders/glTF/2.0/Extensions/KHR_animation_pointer.data";
6836
6878
 
6837
6879
  }
6838
6880
  declare module "babylonjs-loaders/glTF/2.0/Extensions/ExtrasAsMetadata.types" {
@@ -7964,8 +8006,11 @@ export {};
7964
8006
  }
7965
8007
  declare module "babylonjs-loaders/glTF/1.0/pure" {
7966
8008
  /** Pure barrel — re-exports only side-effect-free modules */
8009
+ export * from "babylonjs-loaders/glTF/1.0/glTFBinaryExtension.pure";
8010
+ export * from "babylonjs-loaders/glTF/1.0/glTFLoader.pure";
7967
8011
  export * from "babylonjs-loaders/glTF/1.0/glTFLoaderInterfaces";
7968
8012
  export * from "babylonjs-loaders/glTF/1.0/glTFLoaderUtils";
8013
+ export * from "babylonjs-loaders/glTF/1.0/glTFMaterialsCommonExtension.pure";
7969
8014
 
7970
8015
  }
7971
8016
  declare module "babylonjs-loaders/glTF/1.0/index" {
@@ -7976,10 +8021,10 @@ export * from "babylonjs-loaders/glTF/1.0/glTFLoaderUtils";
7976
8021
  export * from "babylonjs-loaders/glTF/1.0/glTFMaterialsCommonExtension";
7977
8022
 
7978
8023
  }
7979
- declare module "babylonjs-loaders/glTF/1.0/glTFMaterialsCommonExtension" {
7980
- import { GLTFLoaderExtension } from "babylonjs-loaders/glTF/1.0/glTFLoader";
8024
+ declare module "babylonjs-loaders/glTF/1.0/glTFMaterialsCommonExtension.pure" {
8025
+ import { GLTFLoaderExtension } from "babylonjs-loaders/glTF/1.0/glTFLoader.pure";
7981
8026
  import { IGLTFRuntime } from "babylonjs-loaders/glTF/1.0/glTFLoaderInterfaces";
7982
- import { Material } from "babylonjs/Materials/material";
8027
+ import { Material } from "babylonjs/Materials/material.pure";
7983
8028
  /**
7984
8029
  * @internal
7985
8030
  * @deprecated
@@ -7990,12 +8035,26 @@ export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
7990
8035
  loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
7991
8036
  private _loadTexture;
7992
8037
  }
8038
+ /**
8039
+ * Registers the KHR_materials_common extension.
8040
+ * Safe to call multiple times; only the first call has an effect.
8041
+ */
8042
+ export function RegisterGLTFMaterialsCommonExtension(): void;
8043
+
8044
+ }
8045
+ declare module "babylonjs-loaders/glTF/1.0/glTFMaterialsCommonExtension" {
8046
+ /**
8047
+ * Re-exports the pure implementation and applies the runtime registration side effect.
8048
+ * Import "./glTFMaterialsCommonExtension.pure" for tree-shakeable, side-effect-free usage.
8049
+ */
8050
+ export * from "babylonjs-loaders/glTF/1.0/glTFMaterialsCommonExtension.pure";
8051
+ import "babylonjs-loaders/glTF/1.0/glTFLoader";
7993
8052
 
7994
8053
  }
7995
8054
  declare module "babylonjs-loaders/glTF/1.0/glTFLoaderUtils" {
7996
8055
  import { IGLTFTechniqueParameter, IGLTFAccessor, IGLTFRuntime, IGLTFBufferView, EComponentType } from "babylonjs-loaders/glTF/1.0/glTFLoaderInterfaces";
7997
- import { Effect } from "babylonjs/Materials/effect";
7998
- import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
8056
+ import { Effect } from "babylonjs/Materials/effect.pure";
8057
+ import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial.pure";
7999
8058
  import { Node } from "babylonjs/node";
8000
8059
  import { Scene } from "babylonjs/scene";
8001
8060
  /**
@@ -8480,14 +8539,14 @@ export interface IJointNode {
8480
8539
  }
8481
8540
 
8482
8541
  }
8483
- declare module "babylonjs-loaders/glTF/1.0/glTFLoader" {
8542
+ declare module "babylonjs-loaders/glTF/1.0/glTFLoader.pure" {
8484
8543
  import { IGLTFRuntime } from "babylonjs-loaders/glTF/1.0/glTFLoaderInterfaces";
8485
8544
  import { Nullable } from "babylonjs/types";
8486
- import { Material } from "babylonjs/Materials/material";
8487
- import { Texture } from "babylonjs/Materials/Textures/texture";
8545
+ import { Material } from "babylonjs/Materials/material.pure";
8546
+ import { Texture } from "babylonjs/Materials/Textures/texture.pure";
8488
8547
  import { ISceneLoaderAsyncResult, ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
8489
- import { Scene } from "babylonjs/scene";
8490
- import { IGLTFLoader, IGLTFLoaderData } from "babylonjs-loaders/glTF/glTFFileLoader";
8548
+ import { Scene } from "babylonjs/scene.pure";
8549
+ import { IGLTFLoader, IGLTFLoaderData } from "babylonjs-loaders/glTF/glTFFileLoader.pure";
8491
8550
  import { AssetContainer } from "babylonjs/assetContainer";
8492
8551
  /**
8493
8552
  * Implementation of the base glTF spec
@@ -8625,12 +8684,25 @@ export abstract class GLTFLoaderExtension {
8625
8684
  private static _CreateTextureAsync;
8626
8685
  private static _ApplyExtensions;
8627
8686
  }
8687
+ /**
8688
+ * Registers the glTF 1.0 loader factory.
8689
+ * Safe to call multiple times; only the first call has an effect.
8690
+ */
8691
+ export function RegisterGLTF1Loader(): void;
8628
8692
 
8629
8693
  }
8630
- declare module "babylonjs-loaders/glTF/1.0/glTFBinaryExtension" {
8631
- import { GLTFLoaderExtension } from "babylonjs-loaders/glTF/1.0/glTFLoader";
8632
- import { Scene } from "babylonjs/scene";
8633
- import { IGLTFLoaderData } from "babylonjs-loaders/glTF/glTFFileLoader";
8694
+ declare module "babylonjs-loaders/glTF/1.0/glTFLoader" {
8695
+ /**
8696
+ * Re-exports the pure implementation and applies the runtime registration side effect.
8697
+ * Import "./glTFLoader.pure" for tree-shakeable, side-effect-free usage.
8698
+ */
8699
+ export * from "babylonjs-loaders/glTF/1.0/glTFLoader.pure";
8700
+
8701
+ }
8702
+ declare module "babylonjs-loaders/glTF/1.0/glTFBinaryExtension.pure" {
8703
+ import { GLTFLoaderExtension } from "babylonjs-loaders/glTF/1.0/glTFLoader.pure";
8704
+ import { Scene } from "babylonjs/scene.pure";
8705
+ import { IGLTFLoaderData } from "babylonjs-loaders/glTF/glTFFileLoader.pure";
8634
8706
  import { IGLTFRuntime } from "babylonjs-loaders/glTF/1.0/glTFLoaderInterfaces";
8635
8707
  /**
8636
8708
  * @internal
@@ -8644,6 +8716,20 @@ export class GLTFBinaryExtension extends GLTFLoaderExtension {
8644
8716
  loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void): boolean;
8645
8717
  loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void): boolean;
8646
8718
  }
8719
+ /**
8720
+ * Registers the KHR_binary_glTF extension.
8721
+ * Safe to call multiple times; only the first call has an effect.
8722
+ */
8723
+ export function RegisterGLTFBinaryExtension(): void;
8724
+
8725
+ }
8726
+ declare module "babylonjs-loaders/glTF/1.0/glTFBinaryExtension" {
8727
+ /**
8728
+ * Re-exports the pure implementation and applies the runtime registration side effect.
8729
+ * Import "./glTFBinaryExtension.pure" for tree-shakeable, side-effect-free usage.
8730
+ */
8731
+ export * from "babylonjs-loaders/glTF/1.0/glTFBinaryExtension.pure";
8732
+ import "babylonjs-loaders/glTF/1.0/glTFLoader";
8647
8733
 
8648
8734
  }
8649
8735
  declare module "babylonjs-loaders/STL/stlFileLoader.types" {
@@ -9617,7 +9703,7 @@ export class GaussianSplattingWorkBuffer {
9617
9703
 
9618
9704
  }
9619
9705
  declare module "babylonjs-loaders/SPLAT/gaussianSplattingStream" {
9620
- import { GaussianSplattingMesh } from "babylonjs/Meshes/GaussianSplatting/gaussianSplattingMesh";
9706
+ import { GaussianSplattingMesh, IGaussianSplattingLodBudgetParticipant } from "babylonjs/Meshes/GaussianSplatting/gaussianSplattingMesh";
9621
9707
  import { GaussianSplattingPartProxyMesh } from "babylonjs/Meshes/GaussianSplatting/gaussianSplattingPartProxyMesh";
9622
9708
  import { Scene } from "babylonjs/scene";
9623
9709
  import { Nullable } from "babylonjs/types";
@@ -9650,6 +9736,9 @@ interface ISOGLODNode {
9650
9736
  activeLod?: number;
9651
9737
  /** Distance-based ideal LOD level for this node, recomputed per frame. */
9652
9738
  optimalLod?: number;
9739
+ /** Projected screen size (pixels) of the node's AABB — the max across active cameras. Larger nodes keep finer
9740
+ * detail under the splat budget. Only computed while the budget is enabled. */
9741
+ pixelSize?: number;
9653
9742
  /** Available LOD levels for this leaf, sorted ascending (0 = finest). Set during the tree walk. */
9654
9743
  availableLevels?: number[];
9655
9744
  /** Coarsest available level (= max key), always streamed as the permanent base layer. */
@@ -9751,6 +9840,17 @@ export interface IGaussianSplattingStreamOptions {
9751
9840
  * return to it avoids a re-download. Only used when a budget enables eviction. PlayCanvas default `100`.
9752
9841
  */
9753
9842
  evictionCooldownFrames?: number;
9843
+ /**
9844
+ * Enables budget-driven LOD: caps the total rendered splats by converging a screen-space (size + distance)
9845
+ * pixel-size threshold to the budget. Selection is view-direction-independent, so it is consistent across any
9846
+ * number of active cameras (each node takes the finest level and largest projected size any camera demands).
9847
+ * A number is an explicit splat cap; `"auto"` picks a device-tiered default (desktop 2.5M / iOS 1.5M /
9848
+ * other mobile 1M; XR shares the mobile tier). **Undefined (default) disables the cap** — LOD is pure
9849
+ * distance, identical to prior behavior. Runtime-mutable via the {@link splatBudget} accessor. When this stream
9850
+ * is hosted in a compound, the compound's {@link GaussianSplattingMesh.splatBudget} (if set) overrides this and
9851
+ * apportions a shared budget across all its streams.
9852
+ */
9853
+ splatBudget?: number | "auto";
9754
9854
  /**
9755
9855
  * When set, the stream does not render itself; instead it reserves a region of this compound mesh and
9756
9856
  * decodes/sorts into it, so its splats are depth-sorted and drawn in ONE pass together with the compound's
@@ -9790,7 +9890,7 @@ export interface IGaussianSplattingStreamOptions {
9790
9890
  *
9791
9891
  * @experimental
9792
9892
  */
9793
- export class GaussianSplattingStream extends GaussianSplattingMesh {
9893
+ export class GaussianSplattingStream extends GaussianSplattingMesh implements IGaussianSplattingLodBudgetParticipant {
9794
9894
  private readonly _metadata;
9795
9895
  private readonly _rootUrl;
9796
9896
  private readonly _streamOptions;
@@ -9805,9 +9905,12 @@ export class GaussianSplattingStream extends GaussianSplattingMesh {
9805
9905
  private _lodUpdateInterval;
9806
9906
  private _lodUpdateDistance;
9807
9907
  private _maxDetailLod;
9908
+ private _lodPixelThreshold;
9909
+ private _hostBudgetAllocation;
9808
9910
  private _frustumCulling;
9809
9911
  private readonly _frustumPlanes;
9810
9912
  private readonly _cullViewProj;
9913
+ private readonly _frustumScratch;
9811
9914
  private _workBuffer;
9812
9915
  private _decodeSh;
9813
9916
  private _streamShDegree;
@@ -9838,7 +9941,8 @@ export class GaussianSplattingStream extends GaussianSplattingMesh {
9838
9941
  private _lodObserver;
9839
9942
  private _baseLayerReady;
9840
9943
  private _framesSinceLodUpdate;
9841
- private readonly _lastLodCamPos;
9944
+ private readonly _lastLodCamPositions;
9945
+ private _lastLodSignature;
9842
9946
  private _forceLodUpdate;
9843
9947
  private readonly _boundsMin;
9844
9948
  private readonly _boundsMax;
@@ -9937,6 +10041,66 @@ export class GaussianSplattingStream extends GaussianSplattingMesh {
9937
10041
  */
9938
10042
  get maxDetailLod(): number;
9939
10043
  set maxDetailLod(value: number);
10044
+ /**
10045
+ * This stream's own budget-driven LOD cap in splats (see {@link IGaussianSplattingStreamOptions.splatBudget}).
10046
+ * `0` disables the budget (pure distance LOD). Setting it caps the rendered splat count, taking effect on the
10047
+ * next frame. When this stream is hosted in a compound whose own budget is set, that shared budget overrides
10048
+ * this value — read the actual runtime cap from {@link effectiveSplatBudget}, not this getter (which always
10049
+ * reports the configured own cap).
10050
+ * @experimental
10051
+ */
10052
+ get splatBudget(): number;
10053
+ set splatBudget(value: number);
10054
+ /**
10055
+ * The splat cap actually in force this frame: a hosting compound's apportioned allocation when this stream is
10056
+ * coordinated, otherwise this stream's own {@link splatBudget}, clamped to what can be kept resident. `0` means
10057
+ * no cap (pure distance LOD). Unlike {@link splatBudget}, this reflects the compound override, so it is the value
10058
+ * to display or reason about at runtime.
10059
+ * @experimental
10060
+ */
10061
+ get effectiveSplatBudget(): number;
10062
+ /**
10063
+ * Resolves the raw {@link splatBudget} option to a concrete cap: `undefined` ⇒ 0 (disabled), `"auto"` ⇒ a
10064
+ * device-tiered default, a positive number ⇒ itself (floored).
10065
+ * @param option the raw option value
10066
+ * @returns the resolved splat cap (0 = disabled)
10067
+ */
10068
+ private _resolveSplatBudget;
10069
+ /**
10070
+ * Device-tiered default splat budget for {@link splatBudget} `"auto"`: desktop 2.5M, iOS 1.5M, other mobile
10071
+ * (incl. Android/XR) 1M. XR is folded into the mobile tier (no reliable at-construction detection).
10072
+ * @returns the default splat cap for this device
10073
+ */
10074
+ private _computeDefaultSplatBudget;
10075
+ /**
10076
+ * The splat budget this stream converges against this frame: the compound's apportioned allocation when hosted
10077
+ * and coordinated, else this stream's own resolved budget. Clamped to the resident budget so the stream never
10078
+ * targets more splats than can be kept resident. `0` means the budget is disabled.
10079
+ * @returns the effective splat cap (0 = disabled)
10080
+ */
10081
+ private _effectiveSplatBudget;
10082
+ /**
10083
+ * Whether budget-driven LOD is active this frame.
10084
+ * @returns true when a positive effective budget is in force
10085
+ */
10086
+ private _splatBudgetEnabled;
10087
+ /**
10088
+ * {@link IGaussianSplattingLodBudgetParticipant}: the splats this stream would render at full (distance-optimal)
10089
+ * detail — its demand on a host compound's shared budget. Computed from the current per-node distance-optimal
10090
+ * levels (no pixel threshold), so it does not depend on the allocation it is helping to compute.
10091
+ * @returns the full-detail rendered splat count (0 before the base layer is ready)
10092
+ */
10093
+ getBudgetDemand(): number;
10094
+ /**
10095
+ * {@link IGaussianSplattingLodBudgetParticipant}: sets the compound's apportioned share of the shared budget.
10096
+ * `null` releases coordination (revert to this stream's own {@link splatBudget}); a number (incl. 0, meaning
10097
+ * "coordinated at the coarsest level") drives the pixel-threshold convergence. Any change to the (already integer)
10098
+ * allocation forces a next-frame re-eval: a decrease may put the current selection over the new cap, and even a
10099
+ * small increase can unlock a finer level that a stationary camera would otherwise never re-evaluate to. The
10100
+ * apportioned demand is allocation-independent, so this settles in one step and does not churn frame to frame.
10101
+ * @param splats the apportioned allocation, or null to release coordination
10102
+ */
10103
+ setBudgetAllocation(splats: Nullable<number>): void;
9940
10104
  /**
9941
10105
  * Coarsest LOD level index in the scene (number of LOD levels minus one). Useful as the upper bound
9942
10106
  * for {@link maxDetailLod}.
@@ -9980,10 +10144,17 @@ export class GaussianSplattingStream extends GaussianSplattingMesh {
9980
10144
  */
9981
10145
  private _getEffectiveWorldMatrix;
9982
10146
  /**
9983
- * Re-evaluates the optimal LOD for every node based on the camera position. The result is stored in
9984
- * each node's `optimalLod`. Rendering is unaffected; this currently drives only diagnostics and the
9985
- * debug wireframe display.
9986
- * @param camera camera to evaluate against (defaults to the scene's active camera)
10147
+ * The cameras the LOD should serve: `scene.activeCameras` when set (split-view / multi-view), else the single
10148
+ * `scene.activeCamera`. Mirrors the sort path's multi-camera handling.
10149
+ * @returns the non-null active cameras (may be empty)
10150
+ */
10151
+ private _getActiveLodCameras;
10152
+ /**
10153
+ * Re-evaluates the optimal LOD for every node from the active cameras. Each node takes the finest level and the
10154
+ * largest projected pixel size any active camera demands (so every pane of a split view is served), and the
10155
+ * frustum bias uses the union of the frusta. Selection is view-direction-independent, so single- and multi-camera
10156
+ * rendering are consistent. The results are stored in each node's `optimalLod` / `pixelSize`.
10157
+ * @param camera when provided, evaluate against just this camera; otherwise use the active-camera set
9987
10158
  */
9988
10159
  evaluateOptimalLods(camera?: Nullable<Camera>): void;
9989
10160
  /**
@@ -10167,10 +10338,61 @@ export class GaussianSplattingStream extends GaussianSplattingMesh {
10167
10338
  */
10168
10339
  private _cappedLevelForNode;
10169
10340
  /**
10170
- * Computes each node's {@link ISOGLODNode.targetLevel}: the distance-based optimal level snapped to an
10171
- * available level, capped so no node renders finer (more detailed) than {@link maxDetailLod}.
10341
+ * Computes each node's {@link ISOGLODNode.targetLevel}. With the splat budget disabled this is the
10342
+ * distance-optimal level snapped to an available level (capped by {@link maxDetailLod}) — unchanged prior
10343
+ * behavior. With the budget enabled it converges a global pixel-size threshold to the budget and coarsens each
10344
+ * node from its distance-optimal ceiling by how far its projected size falls below that threshold.
10172
10345
  */
10173
10346
  private _computeTargetLevels;
10347
+ /**
10348
+ * Splat count of the always-rendered environment layer (0 when none), coerced to a finite non-negative integer.
10349
+ * Counted as a fixed cost in both the budget demand and the leaf convergence so it is never over-drawn.
10350
+ * @returns the environment's rendered splat count
10351
+ */
10352
+ private _environmentSplatCount;
10353
+ /**
10354
+ * The level a node renders at for a given pixel-size threshold `t`: its distance-optimal ceiling, coarsened by
10355
+ * `round(log_mult(t / pixelSize))` geometric steps when its projected size is below `t`. Snapped to
10356
+ * an available level honoring {@link maxDetailLod}.
10357
+ * @param node leaf node
10358
+ * @param t pixel-size threshold (pixels)
10359
+ * @returns the chosen available LOD level
10360
+ */
10361
+ private _budgetedLevel;
10362
+ /**
10363
+ * Splat count of a node's file at a given (already snapped) available level.
10364
+ * @param node leaf node
10365
+ * @param level available LOD level
10366
+ * @returns the level's splat count (0 if absent)
10367
+ */
10368
+ private _countAtLevel;
10369
+ /**
10370
+ * Sum of every leaf's rendered splat count at pixel-size threshold `t`.
10371
+ * @param t pixel-size threshold (pixels)
10372
+ * @returns total rendered splats
10373
+ */
10374
+ private _totalSplatsAtThreshold;
10375
+ /**
10376
+ * Converges the global pixel-size threshold {@link _lodPixelThreshold} to the largest detail whose total rendered
10377
+ * splats is still within `budget` (the pixel-scale cut, floored at the true sub-pixel limit of 1 px). The
10378
+ * total is monotonically non-increasing in the threshold, so a bisection on `[floorT, ceilT]` — where `ceilT`
10379
+ * coarsens every node to its coarsest available level — gives a GUARANTEED result at or under the cap. When even
10380
+ * that coarsest state exceeds the budget (the budget is below the pinned minimum detail), the threshold is set to
10381
+ * `ceilT` so every node renders at minimum detail — the best achievable; the cap is then unavoidable. O(leaves)
10382
+ * per iteration; no decode.
10383
+ * @param budget target maximum rendered splat count
10384
+ */
10385
+ private _convergePixelThreshold;
10386
+ /**
10387
+ * The finest already-decoded level of a node that is at least as coarse as `level` (index >= level). Used to
10388
+ * enforce the budget cap immediately without waiting for a download. Returns `null` when no such level is resident
10389
+ * — including when eviction has freed the base layer — so the caller keeps the currently-visible (resident) file
10390
+ * rather than switching to a non-resident one, which would render a hole.
10391
+ * @param node leaf node
10392
+ * @param level the minimum coarseness (level index) required
10393
+ * @returns a resident level index >= level, or null when none is resident
10394
+ */
10395
+ private _residentLevelAtLeast;
10174
10396
  /**
10175
10397
  * Applies each node's {@link ISOGLODNode.targetLevel}: switches a node to its target level when that
10176
10398
  * level's file is already decoded, otherwise records a pending download request for the file and leaves
@@ -10224,17 +10446,28 @@ export class GaussianSplattingStream extends GaussianSplattingMesh {
10224
10446
  */
10225
10447
  private _onLodFrame;
10226
10448
  /**
10227
- * Updates each leaf node's {@link ISOGLODNode.inFrustum} flag from a per-node frustum test against the
10228
- * active camera. When {@link frustumCulling} is disabled (or there is no camera) every node is marked
10229
- * in-frustum. Bounds are static (from the LOD tree), so flags are valid for all nodes regardless of
10230
- * decode state. Returns true when any node's in-frustum state changed (so the LOD bias must be re-applied).
10449
+ * A cheap signature of the discrete inputs (besides camera translation, tracked separately) that affect projected
10450
+ * pixel size: each camera's identity, FOV, FOV mode and viewport, plus the engine render size and the effective
10451
+ * world matrix revision. A change invalidates the throttled budget LOD so a colocated camera swap / viewport
10452
+ * resize / FOV change — or the stream (or its hosted proxy) being moved or scaled while still in frustum, which
10453
+ * shifts every node's distance and projected size — can't leave it stale.
10454
+ * @param cameras the active cameras
10455
+ * @returns the signature string
10456
+ */
10457
+ private _computeLodSignature;
10458
+ /**
10459
+ * Updates each leaf node's {@link ISOGLODNode.inFrustum} flag: a node is in-frustum if it is inside ANY
10460
+ * active camera's frustum (the union). When {@link frustumCulling} is disabled (or there are no cameras)
10461
+ * every node is marked in-frustum. Bounds are static (from the LOD tree), so flags are valid for all nodes
10462
+ * regardless of decode state. Returns true when any node's in-frustum state changed (so the LOD bias must be re-applied).
10231
10463
  * @returns whether any node's in-frustum state changed
10232
10464
  */
10233
10465
  private _updateNodeFrustum;
10234
10466
  /**
10235
- * Reads the splat count from SOG metadata.
10467
+ * Reads the splat count from SOG metadata, coerced to a finite non-negative integer (metadata is untrusted, so
10468
+ * `count` / `shape[0]` may be a string or malformed — a non-numeric value must not leak into count arithmetic).
10236
10469
  * @param data SOG metadata
10237
- * @returns the splat count
10470
+ * @returns the splat count (0 when absent/invalid)
10238
10471
  */
10239
10472
  private static _GetSplatCount;
10240
10473
  /**
@@ -10897,6 +11130,12 @@ import { Vector2 } from "babylonjs/Maths/math.vector";
10897
11130
  * Options for loading OBJ/MTL files
10898
11131
  */
10899
11132
  export type OBJLoadingOptions = {
11133
+ /**
11134
+ * Defines the character encoding used to decode OBJ and MTL files.
11135
+ * Use "auto" to detect UTF-8/UTF-16 and fall back to GB18030, or provide an encoding label supported by TextDecoder.
11136
+ * Defaults to "auto".
11137
+ */
11138
+ encoding?: string;
10900
11139
  /**
10901
11140
  * Defines if UVs are optimized by default during load.
10902
11141
  */
@@ -10966,6 +11205,10 @@ import { OBJLoadingOptions } from "babylonjs-loaders/OBJ/objLoadingOptions";
10966
11205
  * This is a babylon scene loader plugin.
10967
11206
  */
10968
11207
  export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
11208
+ /**
11209
+ * Defines the character encoding used to decode OBJ and MTL files.
11210
+ */
11211
+ static ENCODING: string;
10969
11212
  /**
10970
11213
  * Defines if UVs are optimized by default during load.
10971
11214
  */
@@ -11017,7 +11260,11 @@ export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPlugi
11017
11260
  /**
11018
11261
  * Defines the extension the plugin is able to load.
11019
11262
  */
11020
- readonly extensions: ".obj";
11263
+ readonly extensions: {
11264
+ readonly ".obj": {
11265
+ readonly isBinary: true;
11266
+ };
11267
+ };
11021
11268
  private _assetContainer;
11022
11269
  private _loadingOptions;
11023
11270
  /**
@@ -11039,6 +11286,7 @@ export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPlugi
11039
11286
  * @param onFailure
11040
11287
  */
11041
11288
  private _loadMTL;
11289
+ private _decode;
11042
11290
  /** @internal */
11043
11291
  createPlugin(options: SceneLoaderPluginOptions): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
11044
11292
  /**
@@ -11062,7 +11310,7 @@ export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPlugi
11062
11310
  * @param rootUrl root url to load from
11063
11311
  * @returns a promise which completes when objects have been loaded to the scene
11064
11312
  */
11065
- loadAsync(scene: Scene, data: string, rootUrl: string): Promise<void>;
11313
+ loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string): Promise<void>;
11066
11314
  /**
11067
11315
  * Load into an asset container.
11068
11316
  * @param scene The scene to load into
@@ -11070,7 +11318,7 @@ export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPlugi
11070
11318
  * @param rootUrl The root url for scene and resources
11071
11319
  * @returns The loaded asset container
11072
11320
  */
11073
- loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string): Promise<AssetContainer>;
11321
+ loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string): Promise<AssetContainer>;
11074
11322
  /**
11075
11323
  * Read the OBJ file and create an Array of meshes.
11076
11324
  * Each mesh contains all information given by the OBJ and the MTL file.
@@ -11093,7 +11341,11 @@ export function RegisterOBJFileLoader(): void;
11093
11341
  declare module "babylonjs-loaders/OBJ/objFileLoader.metadata" {
11094
11342
  export const OBJFileLoaderMetadata: {
11095
11343
  readonly name: "obj";
11096
- readonly extensions: ".obj";
11344
+ readonly extensions: {
11345
+ readonly ".obj": {
11346
+ readonly isBinary: true;
11347
+ };
11348
+ };
11097
11349
  };
11098
11350
 
11099
11351
  }
@@ -12718,11 +12970,13 @@ declare namespace BABYLON {
12718
12970
  */
12719
12971
  abstract onValidated?: (results: GLTF2.IGLTFValidationResults) => void;
12720
12972
  /**
12721
- * Function called before loading a url referenced by the asset.
12722
- * @param url url referenced by the asset
12723
- * @returns Async url to load
12973
+ * Function called before loading a URL referenced by the asset.
12974
+ * Setting this function allows parent-relative asset URIs and makes the callback responsible for URI safety.
12975
+ * @param url The URL referenced by the asset
12976
+ * @param rootUrl The root URL of the asset, if available
12977
+ * @returns A promise that resolves to the URL to load
12724
12978
  */
12725
- preprocessUrlAsync: (url: string) => Promise<string>;
12979
+ preprocessUrlAsync: (url: string, rootUrl?: string) => Promise<string>;
12726
12980
  }
12727
12981
  /**
12728
12982
  * File loader for loading glTF files into a scene.
@@ -12737,6 +12991,8 @@ declare namespace BABYLON {
12737
12991
  * @param options The options for the loader
12738
12992
  */
12739
12993
  constructor(options?: Partial<Readonly<GLTFLoaderOptions>>);
12994
+ /** @internal */
12995
+ get _isPreprocessUrlAsyncSet(): boolean;
12740
12996
  /**
12741
12997
  * Raised when the asset has been parsed
12742
12998
  */
@@ -15334,7 +15590,8 @@ declare namespace BABYLON {
15334
15590
 
15335
15591
  }
15336
15592
  declare namespace BABYLON.GLTF2 {
15337
- /** @internal */
15593
+ /** This file must only contain pure code and pure imports */
15594
+ /** @internal */
15338
15595
  export type GetValueFn = (target: any, source: Float32Array, offset: number, scale: number) => any;
15339
15596
  /** @internal */
15340
15597
  export function getVector3(_target: any, source: Float32Array, offset: number, scale: number): Vector3;
@@ -15372,9 +15629,22 @@ declare namespace BABYLON.GLTF2 {
15372
15629
  babylonAnimation: Animation;
15373
15630
  }[];
15374
15631
  }
15632
+ /**
15633
+ * Registers the core glTF animation interpolation mappings.
15634
+ */
15635
+ export function RegisterGLTFLoaderAnimation(): void;
15375
15636
 
15376
15637
 
15377
15638
 
15639
+ }
15640
+ declare namespace BABYLON {
15641
+
15642
+
15643
+ }
15644
+ declare namespace BABYLON.GLTF2 {
15645
+
15646
+
15647
+
15378
15648
  }
15379
15649
  declare namespace BABYLON {
15380
15650
 
@@ -17327,6 +17597,11 @@ declare namespace BABYLON.GLTF2.Loader.Extensions {
17327
17597
  onReady(): void;
17328
17598
  dispose(): void;
17329
17599
  }
17600
+ /**
17601
+ * @internal
17602
+ * Registers KHR_node_visibility runtime dependencies without changing the extension registry.
17603
+ */
17604
+ export function _RegisterKHRNodeVisibilityRuntime(): void;
17330
17605
  /**
17331
17606
  * Registers the KHR_node_visibility glTF loader extension.
17332
17607
  * Safe to call multiple times; only the first call has an effect.
@@ -17388,6 +17663,11 @@ declare namespace BABYLON.GLTF2.Loader.Extensions {
17388
17663
  onReady(): Promise<void>;
17389
17664
  dispose(): void;
17390
17665
  }
17666
+ /**
17667
+ * @internal
17668
+ * Registers KHR_node_selectability runtime dependencies without changing the extension registry.
17669
+ */
17670
+ export function _RegisterKHRNodeSelectabilityRuntime(): void;
17391
17671
  /**
17392
17672
  * Registers the KHR_node_selectability glTF loader extension.
17393
17673
  * Safe to call multiple times; only the first call has an effect.
@@ -17450,6 +17730,11 @@ declare namespace BABYLON.GLTF2.Loader.Extensions {
17450
17730
  onReady(): Promise<void>;
17451
17731
  dispose(): void;
17452
17732
  }
17733
+ /**
17734
+ * @internal
17735
+ * Registers KHR_node_hoverability runtime dependencies without changing the extension registry.
17736
+ */
17737
+ export function _RegisterKHRNodeHoverabilityRuntime(): void;
17453
17738
  /**
17454
17739
  * Registers the KHR_node_hoverability glTF loader extension.
17455
17740
  * Safe to call multiple times; only the first call has an effect.
@@ -19006,6 +19291,11 @@ declare namespace BABYLON.GLTF2.Loader.Extensions {
19006
19291
  * populates the object model with the interactivity extension
19007
19292
  */
19008
19293
  export function _AddInteractivityObjectModel(scene: Scene): void;
19294
+ /**
19295
+ * @internal
19296
+ * Registers KHR_interactivity runtime dependencies without changing the extension registry.
19297
+ */
19298
+ export function _RegisterKHRInteractivityRuntime(): void;
19009
19299
  /**
19010
19300
  * Registers the KHR_interactivity glTF loader extension.
19011
19301
  * Safe to call multiple times; only the first call has an effect.
@@ -19226,6 +19516,20 @@ declare namespace BABYLON.GLTF2.Loader.Extensions {
19226
19516
 
19227
19517
 
19228
19518
 
19519
+ }
19520
+ declare namespace BABYLON {
19521
+
19522
+
19523
+ }
19524
+ declare namespace BABYLON.GLTF2.Loader.Extensions {
19525
+ /**
19526
+ * Registers the KHR_animation_pointer interpolation mappings.
19527
+ * @internal
19528
+ */
19529
+ export function _RegisterKHRAnimationPointerData(): void;
19530
+
19531
+
19532
+
19229
19533
  }
19230
19534
  declare namespace BABYLON {
19231
19535
 
@@ -20473,6 +20777,24 @@ declare namespace BABYLON.GLTF1 {
20473
20777
  loadMaterialAsync(gltfRuntime: BABYLON.GLTF1.IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
20474
20778
  private _loadTexture;
20475
20779
  }
20780
+ /**
20781
+ * Registers the KHR_materials_common extension.
20782
+ * Safe to call multiple times; only the first call has an effect.
20783
+ */
20784
+ export function RegisterGLTFMaterialsCommonExtension(): void;
20785
+
20786
+
20787
+
20788
+ }
20789
+ declare namespace BABYLON {
20790
+
20791
+
20792
+ }
20793
+ declare namespace BABYLON.GLTF1 {
20794
+ /**
20795
+ * Re-exports the pure implementation and applies the runtime registration side effect.
20796
+ * Import "./glTFMaterialsCommonExtension.pure" for tree-shakeable, side-effect-free usage.
20797
+ */
20476
20798
 
20477
20799
 
20478
20800
 
@@ -21106,6 +21428,24 @@ declare namespace BABYLON.GLTF1 {
21106
21428
  private static _CreateTextureAsync;
21107
21429
  private static _ApplyExtensions;
21108
21430
  }
21431
+ /**
21432
+ * Registers the glTF 1.0 loader factory.
21433
+ * Safe to call multiple times; only the first call has an effect.
21434
+ */
21435
+ export function RegisterGLTF1Loader(): void;
21436
+
21437
+
21438
+
21439
+ }
21440
+ declare namespace BABYLON {
21441
+
21442
+
21443
+ }
21444
+ declare namespace BABYLON.GLTF1 {
21445
+ /**
21446
+ * Re-exports the pure implementation and applies the runtime registration side effect.
21447
+ * Import "./glTFLoader.pure" for tree-shakeable, side-effect-free usage.
21448
+ */
21109
21449
 
21110
21450
 
21111
21451
 
@@ -21127,6 +21467,24 @@ declare namespace BABYLON.GLTF1 {
21127
21467
  loadTextureBufferAsync(gltfRuntime: BABYLON.GLTF1.IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void): boolean;
21128
21468
  loadShaderStringAsync(gltfRuntime: BABYLON.GLTF1.IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void): boolean;
21129
21469
  }
21470
+ /**
21471
+ * Registers the KHR_binary_glTF extension.
21472
+ * Safe to call multiple times; only the first call has an effect.
21473
+ */
21474
+ export function RegisterGLTFBinaryExtension(): void;
21475
+
21476
+
21477
+
21478
+ }
21479
+ declare namespace BABYLON {
21480
+
21481
+
21482
+ }
21483
+ declare namespace BABYLON.GLTF1 {
21484
+ /**
21485
+ * Re-exports the pure implementation and applies the runtime registration side effect.
21486
+ * Import "./glTFBinaryExtension.pure" for tree-shakeable, side-effect-free usage.
21487
+ */
21130
21488
 
21131
21489
 
21132
21490
 
@@ -22061,6 +22419,9 @@ declare namespace BABYLON {
22061
22419
  activeLod?: number;
22062
22420
  /** Distance-based ideal LOD level for this node, recomputed per frame. */
22063
22421
  optimalLod?: number;
22422
+ /** Projected screen size (pixels) of the node's AABB — the max across active cameras. Larger nodes keep finer
22423
+ * detail under the splat budget. Only computed while the budget is enabled. */
22424
+ pixelSize?: number;
22064
22425
  /** Available LOD levels for this leaf, sorted ascending (0 = finest). Set during the tree walk. */
22065
22426
  availableLevels?: number[];
22066
22427
  /** Coarsest available level (= max key), always streamed as the permanent base layer. */
@@ -22162,6 +22523,17 @@ declare namespace BABYLON {
22162
22523
  * return to it avoids a re-download. Only used when a budget enables eviction. PlayCanvas default `100`.
22163
22524
  */
22164
22525
  evictionCooldownFrames?: number;
22526
+ /**
22527
+ * Enables budget-driven LOD: caps the total rendered splats by converging a screen-space (size + distance)
22528
+ * pixel-size threshold to the budget. Selection is view-direction-independent, so it is consistent across any
22529
+ * number of active cameras (each node takes the finest level and largest projected size any camera demands).
22530
+ * A number is an explicit splat cap; `"auto"` picks a device-tiered default (desktop 2.5M / iOS 1.5M /
22531
+ * other mobile 1M; XR shares the mobile tier). **Undefined (default) disables the cap** — LOD is pure
22532
+ * distance, identical to prior behavior. Runtime-mutable via the {@link splatBudget} accessor. When this stream
22533
+ * is hosted in a compound, the compound's {@link GaussianSplattingMesh.splatBudget} (if set) overrides this and
22534
+ * apportions a shared budget across all its streams.
22535
+ */
22536
+ splatBudget?: number | "auto";
22165
22537
  /**
22166
22538
  * When set, the stream does not render itself; instead it reserves a region of this compound mesh and
22167
22539
  * decodes/sorts into it, so its splats are depth-sorted and drawn in ONE pass together with the compound's
@@ -22201,7 +22573,7 @@ declare namespace BABYLON {
22201
22573
  *
22202
22574
  * @experimental
22203
22575
  */
22204
- export class GaussianSplattingStream extends GaussianSplattingMesh {
22576
+ export class GaussianSplattingStream extends GaussianSplattingMesh implements IGaussianSplattingLodBudgetParticipant {
22205
22577
  private readonly _metadata;
22206
22578
  private readonly _rootUrl;
22207
22579
  private readonly _streamOptions;
@@ -22216,9 +22588,12 @@ declare namespace BABYLON {
22216
22588
  private _lodUpdateInterval;
22217
22589
  private _lodUpdateDistance;
22218
22590
  private _maxDetailLod;
22591
+ private _lodPixelThreshold;
22592
+ private _hostBudgetAllocation;
22219
22593
  private _frustumCulling;
22220
22594
  private readonly _frustumPlanes;
22221
22595
  private readonly _cullViewProj;
22596
+ private readonly _frustumScratch;
22222
22597
  private _workBuffer;
22223
22598
  private _decodeSh;
22224
22599
  private _streamShDegree;
@@ -22249,7 +22624,8 @@ declare namespace BABYLON {
22249
22624
  private _lodObserver;
22250
22625
  private _baseLayerReady;
22251
22626
  private _framesSinceLodUpdate;
22252
- private readonly _lastLodCamPos;
22627
+ private readonly _lastLodCamPositions;
22628
+ private _lastLodSignature;
22253
22629
  private _forceLodUpdate;
22254
22630
  private readonly _boundsMin;
22255
22631
  private readonly _boundsMax;
@@ -22348,6 +22724,66 @@ declare namespace BABYLON {
22348
22724
  */
22349
22725
  get maxDetailLod(): number;
22350
22726
  set maxDetailLod(value: number);
22727
+ /**
22728
+ * This stream's own budget-driven LOD cap in splats (see {@link IGaussianSplattingStreamOptions.splatBudget}).
22729
+ * `0` disables the budget (pure distance LOD). Setting it caps the rendered splat count, taking effect on the
22730
+ * next frame. When this stream is hosted in a compound whose own budget is set, that shared budget overrides
22731
+ * this value — read the actual runtime cap from {@link effectiveSplatBudget}, not this getter (which always
22732
+ * reports the configured own cap).
22733
+ * @experimental
22734
+ */
22735
+ get splatBudget(): number;
22736
+ set splatBudget(value: number);
22737
+ /**
22738
+ * The splat cap actually in force this frame: a hosting compound's apportioned allocation when this stream is
22739
+ * coordinated, otherwise this stream's own {@link splatBudget}, clamped to what can be kept resident. `0` means
22740
+ * no cap (pure distance LOD). Unlike {@link splatBudget}, this reflects the compound override, so it is the value
22741
+ * to display or reason about at runtime.
22742
+ * @experimental
22743
+ */
22744
+ get effectiveSplatBudget(): number;
22745
+ /**
22746
+ * Resolves the raw {@link splatBudget} option to a concrete cap: `undefined` ⇒ 0 (disabled), `"auto"` ⇒ a
22747
+ * device-tiered default, a positive number ⇒ itself (floored).
22748
+ * @param option the raw option value
22749
+ * @returns the resolved splat cap (0 = disabled)
22750
+ */
22751
+ private _resolveSplatBudget;
22752
+ /**
22753
+ * Device-tiered default splat budget for {@link splatBudget} `"auto"`: desktop 2.5M, iOS 1.5M, other mobile
22754
+ * (incl. Android/XR) 1M. XR is folded into the mobile tier (no reliable at-construction detection).
22755
+ * @returns the default splat cap for this device
22756
+ */
22757
+ private _computeDefaultSplatBudget;
22758
+ /**
22759
+ * The splat budget this stream converges against this frame: the compound's apportioned allocation when hosted
22760
+ * and coordinated, else this stream's own resolved budget. Clamped to the resident budget so the stream never
22761
+ * targets more splats than can be kept resident. `0` means the budget is disabled.
22762
+ * @returns the effective splat cap (0 = disabled)
22763
+ */
22764
+ private _effectiveSplatBudget;
22765
+ /**
22766
+ * Whether budget-driven LOD is active this frame.
22767
+ * @returns true when a positive effective budget is in force
22768
+ */
22769
+ private _splatBudgetEnabled;
22770
+ /**
22771
+ * {@link IGaussianSplattingLodBudgetParticipant}: the splats this stream would render at full (distance-optimal)
22772
+ * detail — its demand on a host compound's shared budget. Computed from the current per-node distance-optimal
22773
+ * levels (no pixel threshold), so it does not depend on the allocation it is helping to compute.
22774
+ * @returns the full-detail rendered splat count (0 before the base layer is ready)
22775
+ */
22776
+ getBudgetDemand(): number;
22777
+ /**
22778
+ * {@link IGaussianSplattingLodBudgetParticipant}: sets the compound's apportioned share of the shared budget.
22779
+ * `null` releases coordination (revert to this stream's own {@link splatBudget}); a number (incl. 0, meaning
22780
+ * "coordinated at the coarsest level") drives the pixel-threshold convergence. Any change to the (already integer)
22781
+ * allocation forces a next-frame re-eval: a decrease may put the current selection over the new cap, and even a
22782
+ * small increase can unlock a finer level that a stationary camera would otherwise never re-evaluate to. The
22783
+ * apportioned demand is allocation-independent, so this settles in one step and does not churn frame to frame.
22784
+ * @param splats the apportioned allocation, or null to release coordination
22785
+ */
22786
+ setBudgetAllocation(splats: Nullable<number>): void;
22351
22787
  /**
22352
22788
  * Coarsest LOD level index in the scene (number of LOD levels minus one). Useful as the upper bound
22353
22789
  * for {@link maxDetailLod}.
@@ -22391,10 +22827,17 @@ declare namespace BABYLON {
22391
22827
  */
22392
22828
  private _getEffectiveWorldMatrix;
22393
22829
  /**
22394
- * Re-evaluates the optimal LOD for every node based on the camera position. The result is stored in
22395
- * each node's `optimalLod`. Rendering is unaffected; this currently drives only diagnostics and the
22396
- * debug wireframe display.
22397
- * @param camera camera to evaluate against (defaults to the scene's active camera)
22830
+ * The cameras the LOD should serve: `scene.activeCameras` when set (split-view / multi-view), else the single
22831
+ * `scene.activeCamera`. Mirrors the sort path's multi-camera handling.
22832
+ * @returns the non-null active cameras (may be empty)
22833
+ */
22834
+ private _getActiveLodCameras;
22835
+ /**
22836
+ * Re-evaluates the optimal LOD for every node from the active cameras. Each node takes the finest level and the
22837
+ * largest projected pixel size any active camera demands (so every pane of a split view is served), and the
22838
+ * frustum bias uses the union of the frusta. Selection is view-direction-independent, so single- and multi-camera
22839
+ * rendering are consistent. The results are stored in each node's `optimalLod` / `pixelSize`.
22840
+ * @param camera when provided, evaluate against just this camera; otherwise use the active-camera set
22398
22841
  */
22399
22842
  evaluateOptimalLods(camera?: Nullable<Camera>): void;
22400
22843
  /**
@@ -22578,10 +23021,61 @@ declare namespace BABYLON {
22578
23021
  */
22579
23022
  private _cappedLevelForNode;
22580
23023
  /**
22581
- * Computes each node's {@link ISOGLODNode.targetLevel}: the distance-based optimal level snapped to an
22582
- * available level, capped so no node renders finer (more detailed) than {@link maxDetailLod}.
23024
+ * Computes each node's {@link ISOGLODNode.targetLevel}. With the splat budget disabled this is the
23025
+ * distance-optimal level snapped to an available level (capped by {@link maxDetailLod}) — unchanged prior
23026
+ * behavior. With the budget enabled it converges a global pixel-size threshold to the budget and coarsens each
23027
+ * node from its distance-optimal ceiling by how far its projected size falls below that threshold.
22583
23028
  */
22584
23029
  private _computeTargetLevels;
23030
+ /**
23031
+ * Splat count of the always-rendered environment layer (0 when none), coerced to a finite non-negative integer.
23032
+ * Counted as a fixed cost in both the budget demand and the leaf convergence so it is never over-drawn.
23033
+ * @returns the environment's rendered splat count
23034
+ */
23035
+ private _environmentSplatCount;
23036
+ /**
23037
+ * The level a node renders at for a given pixel-size threshold `t`: its distance-optimal ceiling, coarsened by
23038
+ * `round(log_mult(t / pixelSize))` geometric steps when its projected size is below `t`. Snapped to
23039
+ * an available level honoring {@link maxDetailLod}.
23040
+ * @param node leaf node
23041
+ * @param t pixel-size threshold (pixels)
23042
+ * @returns the chosen available LOD level
23043
+ */
23044
+ private _budgetedLevel;
23045
+ /**
23046
+ * Splat count of a node's file at a given (already snapped) available level.
23047
+ * @param node leaf node
23048
+ * @param level available LOD level
23049
+ * @returns the level's splat count (0 if absent)
23050
+ */
23051
+ private _countAtLevel;
23052
+ /**
23053
+ * Sum of every leaf's rendered splat count at pixel-size threshold `t`.
23054
+ * @param t pixel-size threshold (pixels)
23055
+ * @returns total rendered splats
23056
+ */
23057
+ private _totalSplatsAtThreshold;
23058
+ /**
23059
+ * Converges the global pixel-size threshold {@link _lodPixelThreshold} to the largest detail whose total rendered
23060
+ * splats is still within `budget` (the pixel-scale cut, floored at the true sub-pixel limit of 1 px). The
23061
+ * total is monotonically non-increasing in the threshold, so a bisection on `[floorT, ceilT]` — where `ceilT`
23062
+ * coarsens every node to its coarsest available level — gives a GUARANTEED result at or under the cap. When even
23063
+ * that coarsest state exceeds the budget (the budget is below the pinned minimum detail), the threshold is set to
23064
+ * `ceilT` so every node renders at minimum detail — the best achievable; the cap is then unavoidable. O(leaves)
23065
+ * per iteration; no decode.
23066
+ * @param budget target maximum rendered splat count
23067
+ */
23068
+ private _convergePixelThreshold;
23069
+ /**
23070
+ * The finest already-decoded level of a node that is at least as coarse as `level` (index >= level). Used to
23071
+ * enforce the budget cap immediately without waiting for a download. Returns `null` when no such level is resident
23072
+ * — including when eviction has freed the base layer — so the caller keeps the currently-visible (resident) file
23073
+ * rather than switching to a non-resident one, which would render a hole.
23074
+ * @param node leaf node
23075
+ * @param level the minimum coarseness (level index) required
23076
+ * @returns a resident level index >= level, or null when none is resident
23077
+ */
23078
+ private _residentLevelAtLeast;
22585
23079
  /**
22586
23080
  * Applies each node's {@link ISOGLODNode.targetLevel}: switches a node to its target level when that
22587
23081
  * level's file is already decoded, otherwise records a pending download request for the file and leaves
@@ -22635,17 +23129,28 @@ declare namespace BABYLON {
22635
23129
  */
22636
23130
  private _onLodFrame;
22637
23131
  /**
22638
- * Updates each leaf node's {@link ISOGLODNode.inFrustum} flag from a per-node frustum test against the
22639
- * active camera. When {@link frustumCulling} is disabled (or there is no camera) every node is marked
22640
- * in-frustum. Bounds are static (from the LOD tree), so flags are valid for all nodes regardless of
22641
- * decode state. Returns true when any node's in-frustum state changed (so the LOD bias must be re-applied).
23132
+ * A cheap signature of the discrete inputs (besides camera translation, tracked separately) that affect projected
23133
+ * pixel size: each camera's identity, FOV, FOV mode and viewport, plus the engine render size and the effective
23134
+ * world matrix revision. A change invalidates the throttled budget LOD so a colocated camera swap / viewport
23135
+ * resize / FOV change — or the stream (or its hosted proxy) being moved or scaled while still in frustum, which
23136
+ * shifts every node's distance and projected size — can't leave it stale.
23137
+ * @param cameras the active cameras
23138
+ * @returns the signature string
23139
+ */
23140
+ private _computeLodSignature;
23141
+ /**
23142
+ * Updates each leaf node's {@link ISOGLODNode.inFrustum} flag: a node is in-frustum if it is inside ANY
23143
+ * active camera's frustum (the union). When {@link frustumCulling} is disabled (or there are no cameras)
23144
+ * every node is marked in-frustum. Bounds are static (from the LOD tree), so flags are valid for all nodes
23145
+ * regardless of decode state. Returns true when any node's in-frustum state changed (so the LOD bias must be re-applied).
22642
23146
  * @returns whether any node's in-frustum state changed
22643
23147
  */
22644
23148
  private _updateNodeFrustum;
22645
23149
  /**
22646
- * Reads the splat count from SOG metadata.
23150
+ * Reads the splat count from SOG metadata, coerced to a finite non-negative integer (metadata is untrusted, so
23151
+ * `count` / `shape[0]` may be a string or malformed — a non-numeric value must not leak into count arithmetic).
22647
23152
  * @param data SOG metadata
22648
- * @returns the splat count
23153
+ * @returns the splat count (0 when absent/invalid)
22649
23154
  */
22650
23155
  private static _GetSplatCount;
22651
23156
  /**
@@ -23289,6 +23794,12 @@ declare namespace BABYLON {
23289
23794
  * Options for loading OBJ/MTL files
23290
23795
  */
23291
23796
  export type OBJLoadingOptions = {
23797
+ /**
23798
+ * Defines the character encoding used to decode OBJ and MTL files.
23799
+ * Use "auto" to detect UTF-8/UTF-16 and fall back to GB18030, or provide an encoding label supported by TextDecoder.
23800
+ * Defaults to "auto".
23801
+ */
23802
+ encoding?: string;
23292
23803
  /**
23293
23804
  * Defines if UVs are optimized by default during load.
23294
23805
  */
@@ -23346,6 +23857,10 @@ declare namespace BABYLON {
23346
23857
  * This is a babylon scene loader plugin.
23347
23858
  */
23348
23859
  export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
23860
+ /**
23861
+ * Defines the character encoding used to decode OBJ and MTL files.
23862
+ */
23863
+ static ENCODING: string;
23349
23864
  /**
23350
23865
  * Defines if UVs are optimized by default during load.
23351
23866
  */
@@ -23397,7 +23912,11 @@ declare namespace BABYLON {
23397
23912
  /**
23398
23913
  * Defines the extension the plugin is able to load.
23399
23914
  */
23400
- readonly extensions: ".obj";
23915
+ readonly extensions: {
23916
+ readonly ".obj": {
23917
+ readonly isBinary: true;
23918
+ };
23919
+ };
23401
23920
  private _assetContainer;
23402
23921
  private _loadingOptions;
23403
23922
  /**
@@ -23419,6 +23938,7 @@ declare namespace BABYLON {
23419
23938
  * @param onFailure
23420
23939
  */
23421
23940
  private _loadMTL;
23941
+ private _decode;
23422
23942
  /** @internal */
23423
23943
  createPlugin(options: SceneLoaderPluginOptions): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
23424
23944
  /**
@@ -23442,7 +23962,7 @@ declare namespace BABYLON {
23442
23962
  * @param rootUrl root url to load from
23443
23963
  * @returns a promise which completes when objects have been loaded to the scene
23444
23964
  */
23445
- loadAsync(scene: Scene, data: string, rootUrl: string): Promise<void>;
23965
+ loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string): Promise<void>;
23446
23966
  /**
23447
23967
  * Load into an asset container.
23448
23968
  * @param scene The scene to load into
@@ -23450,7 +23970,7 @@ declare namespace BABYLON {
23450
23970
  * @param rootUrl The root url for scene and resources
23451
23971
  * @returns The loaded asset container
23452
23972
  */
23453
- loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string): Promise<AssetContainer>;
23973
+ loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string): Promise<AssetContainer>;
23454
23974
  /**
23455
23975
  * Read the OBJ file and create an Array of meshes.
23456
23976
  * Each mesh contains all information given by the OBJ and the MTL file.
@@ -23472,7 +23992,11 @@ declare namespace BABYLON {
23472
23992
 
23473
23993
  export var OBJFileLoaderMetadata: {
23474
23994
  readonly name: "obj";
23475
- readonly extensions: ".obj";
23995
+ readonly extensions: {
23996
+ readonly ".obj": {
23997
+ readonly isBinary: true;
23998
+ };
23999
+ };
23476
24000
  };
23477
24001
 
23478
24002