babylonjs-loaders 9.7.0 → 9.9.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.
@@ -702,6 +702,7 @@ import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
702
702
  import { Nullable } from "babylonjs/types";
703
703
  import { Color3 } from "babylonjs/Maths/math.color";
704
704
  import { IMaterialLoadingAdapter } from "babylonjs-loaders/glTF/2.0/materialLoadingAdapter";
705
+ import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
705
706
  /**
706
707
  * Material Loading Adapter for PBR materials that provides a unified OpenPBR-like interface.
707
708
  */
@@ -717,6 +718,11 @@ export class PBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
717
718
  * Gets the underlying material
718
719
  */
719
720
  get material(): PBRMaterial;
721
+ /**
722
+ * No-op: PBRMaterial has no deferred finalization.
723
+ * @param _loader Unused.
724
+ */
725
+ finalizeAsync(_loader: GLTFLoader): Promise<void>;
720
726
  /**
721
727
  * Whether the material should be treated as unlit
722
728
  */
@@ -1432,6 +1438,7 @@ import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
1432
1438
  import { Nullable } from "babylonjs/types";
1433
1439
  import { Color3 } from "babylonjs/Maths/math.color";
1434
1440
  import { IMaterialLoadingAdapter } from "babylonjs-loaders/glTF/2.0/materialLoadingAdapter";
1441
+ import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
1435
1442
  /**
1436
1443
  * Material Loading Adapter for OpenPBR materials that provides a unified OpenPBR-like interface.
1437
1444
  */
@@ -2132,10 +2139,9 @@ export class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
2132
2139
  set geometryCoatNormalTextureScale(value: number);
2133
2140
  /**
2134
2141
  * Finalizes material properties after all loading is complete.
2135
- * @param signal An AbortSignal that fires when the loader is disposed. Intermediate
2136
- * textures are disposed and the method returns early when aborted.
2142
+ * @param loader The glTF loader; `loader._disposed` is polled between texture passes to bail early on dispose.
2137
2143
  */
2138
- finalizeAsync(signal: AbortSignal): Promise<void>;
2144
+ finalizeAsync(loader: GLTFLoader): Promise<void>;
2139
2145
  private copySurfaceToCoatAsync;
2140
2146
  }
2141
2147
 
@@ -2145,6 +2151,7 @@ import { Material } from "babylonjs/Materials/material";
2145
2151
  import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
2146
2152
  import { Nullable } from "babylonjs/types";
2147
2153
  import { Color3 } from "babylonjs/Maths/math.color";
2154
+ import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
2148
2155
  /**
2149
2156
  * Interface for material loading adapters that provides a unified OpenPBR-like interface
2150
2157
  * for both OpenPBR and PBR materials, eliminating conditional branches in extensions.
@@ -2154,20 +2161,17 @@ export interface IMaterialLoadingAdapter {
2154
2161
  * Gets the underlying material
2155
2162
  */
2156
2163
  readonly material: Material;
2157
- /** @deprecated Use finalizeAsync instead. */
2158
- finalize?(): void;
2159
2164
  /**
2160
2165
  * Finalizes material properties after all loading is complete.
2161
- * May return a Promise for async work (e.g. GPU texture processing). Any returned
2162
- * Promise is tracked by the loader and awaited before the COMPLETE state is reached,
2163
- * so callers can rely on onCompleteObservable for fully processed materials.
2166
+ * May do async work (e.g. GPU texture processing); the returned Promise is tracked
2167
+ * by the loader and awaited before the COMPLETE state is reached, so callers can rely
2168
+ * on onCompleteObservable for fully processed materials.
2164
2169
  *
2165
- * The loader passes an AbortSignal that is aborted when the loader is disposed.
2166
- * Implementations should check `signal.aborted` after each await point and, if
2167
- * aborted, release any intermediate resources and return early.
2168
- * @param signal An AbortSignal that fires when the loader is disposed mid-flight.
2170
+ * Implementations should check `loader._disposed` between awaits to bail out early
2171
+ * when the loader is disposed mid-flight.
2172
+ * @param loader The glTF loader driving the finalize step.
2169
2173
  */
2170
- finalizeAsync?(signal: AbortSignal): Promise<void> | void;
2174
+ finalizeAsync(loader: GLTFLoader): Promise<void>;
2171
2175
  /**
2172
2176
  * Whether the material should be treated as unlit
2173
2177
  */
@@ -3132,8 +3136,6 @@ type PBRMaterialImplementation = {
3132
3136
  export class GLTFLoader implements IGLTFLoader {
3133
3137
  /** @internal */
3134
3138
  readonly _completePromises: Promise<unknown>[];
3135
- /** AbortController used to cancel in-flight finalizeAsync() calls when dispose() is called. */
3136
- private _finalizeController;
3137
3139
  /** @internal */
3138
3140
  _assetContainer: Nullable<AssetContainer>;
3139
3141
  /** Storage */
@@ -3146,7 +3148,8 @@ export class GLTFLoader implements IGLTFLoader {
3146
3148
  _skipStartAnimationStep: boolean;
3147
3149
  private readonly _parent;
3148
3150
  private readonly _extensions;
3149
- private _disposed;
3151
+ /** @internal */
3152
+ _disposed: boolean;
3150
3153
  private _rootUrl;
3151
3154
  private _fileName;
3152
3155
  private _uniqueRootUrl;
@@ -3158,12 +3161,17 @@ export class GLTFLoader implements IGLTFLoader {
3158
3161
  private readonly _postSceneLoadActions;
3159
3162
  private readonly _materialAdapterCache;
3160
3163
  private readonly _materialAdapters;
3161
- /** @internal */
3162
- _pbrMaterialImpl: Nullable<Readonly<PBRMaterialImplementation>> | false;
3163
3164
  /**
3164
- * Test if the given material is of the same type as the one used by the loader
3165
+ * Loaded PBR material implementations, keyed by their identifier (e.g. "pbr", "openpbr").
3166
+ * Only populated after the load has started and only for the types actually needed by the asset.
3167
+ * Empty when PBR materials are disabled (skipMaterials).
3168
+ * @internal
3169
+ */
3170
+ readonly _pbrMaterialImpls: Map<string, Readonly<PBRMaterialImplementation>>;
3171
+ /**
3172
+ * Test if the given material is an instance of any PBR material type known to this loader.
3165
3173
  * @param material The material to test
3166
- * @returns true if the material is of the same type, false otherwise
3174
+ * @returns true if the material matches one of the loaded PBR implementations
3167
3175
  */
3168
3176
  isMatchingMaterialType(material: Nullable<Material>): boolean;
3169
3177
  /**
@@ -3358,6 +3366,21 @@ export class GLTFLoader implements IGLTFLoader {
3358
3366
  * @internal
3359
3367
  */
3360
3368
  _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
3369
+ /**
3370
+ * Selects the appropriate PBR material implementation for a given glTF material.
3371
+ * Uses OpenPBR when the material carries a "KHR_materials_openpbr" extension or when
3372
+ * the loader-level `useOpenPBR` flag is set; falls back to standard PBR otherwise.
3373
+ * @param material The glTF material
3374
+ * @returns The matching loaded implementation
3375
+ */
3376
+ private _selectImplForGltfMaterial;
3377
+ /**
3378
+ * Returns the default PBR material implementation used when there is no per-material
3379
+ * selection context (e.g. when creating the built-in default material for primitives
3380
+ * that have no glTF material assigned). Prefers OpenPBR when `useOpenPBR` is set.
3381
+ * @returns The default loaded implementation
3382
+ */
3383
+ private _getDefaultImpl;
3361
3384
  private _createDefaultMaterial;
3362
3385
  /**
3363
3386
  * Creates a Babylon material from a glTF material.
@@ -3511,6 +3534,166 @@ export class GLTFLoader implements IGLTFLoader {
3511
3534
  endPerformanceCounter(counterName: string): void;
3512
3535
  }
3513
3536
 
3537
+ }
3538
+ declare module "babylonjs-loaders/glTF/2.0/Extensions/transmissionHelper" {
3539
+ import { Nullable } from "babylonjs/types";
3540
+ import { Material } from "babylonjs/Materials/material";
3541
+ import { Scene } from "babylonjs/scene";
3542
+ import { Texture } from "babylonjs/Materials/Textures/texture";
3543
+ import { Observable } from "babylonjs/Misc/observable";
3544
+ import { Color4 } from "babylonjs/Maths/math.color";
3545
+ import { IMaterialLoadingAdapter } from "babylonjs-loaders/glTF/2.0/materialLoadingAdapter";
3546
+ import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
3547
+ /**
3548
+ * Describes a material class and its corresponding loading adapter.
3549
+ * Passed to TransmissionHelper so it can classify and interact with materials
3550
+ * independently of any specific loader instance.
3551
+ */
3552
+ export interface ITransmissionHelperMaterialImpl {
3553
+ /** The material class constructor */
3554
+ materialClass: typeof Material;
3555
+ /** The adapter class constructor */
3556
+ adapterClass: new (material: Material) => IMaterialLoadingAdapter;
3557
+ }
3558
+ /**
3559
+ * @internal
3560
+ */
3561
+ export interface ITransmissionHelperHolder {
3562
+ /** The transmission helper instance, if created on the scene */
3563
+ _transmissionHelper: TransmissionHelper | undefined;
3564
+ }
3565
+ /**
3566
+ * Options for the TransmissionHelper.
3567
+ */
3568
+ export interface ITransmissionHelperOptions {
3569
+ /**
3570
+ * The size of the render buffers (default: 1024)
3571
+ */
3572
+ renderSize: number;
3573
+ /**
3574
+ * The number of samples to use when generating the render target texture for opaque meshes (default: 4)
3575
+ */
3576
+ samples: number;
3577
+ /**
3578
+ * Scale to apply when selecting the LOD level to sample the refraction texture (default: 1)
3579
+ */
3580
+ lodGenerationScale: number;
3581
+ /**
3582
+ * Offset to apply when selecting the LOD level to sample the refraction texture (default: -4)
3583
+ */
3584
+ lodGenerationOffset: number;
3585
+ /**
3586
+ * Type of the refraction render target texture (default: TEXTURETYPE_HALF_FLOAT)
3587
+ */
3588
+ renderTargetTextureType: number;
3589
+ /**
3590
+ * Defines if the mipmaps for the refraction render target texture must be generated (default: true)
3591
+ */
3592
+ generateMipmaps: boolean;
3593
+ /**
3594
+ * Clear color of the opaque texture. If not provided, use the scene clear color (which will be converted to linear space).
3595
+ * If provided, should be in linear space
3596
+ */
3597
+ clearColor?: Color4;
3598
+ }
3599
+ /**
3600
+ * A class to handle setting up the rendering of opaque objects to be shown through transmissive objects.
3601
+ * @internal
3602
+ */
3603
+ export class TransmissionHelper {
3604
+ /**
3605
+ * Creates the default options for the helper.
3606
+ * @returns the default options
3607
+ */
3608
+ private static _GetDefaultOptions;
3609
+ private readonly _scene;
3610
+ private _options;
3611
+ private _opaqueRenderTarget;
3612
+ private _opaqueMeshesCache;
3613
+ private _transparentMeshesCache;
3614
+ private _materialObservers;
3615
+ private readonly _materialImpls;
3616
+ private readonly _adapterCache;
3617
+ /**
3618
+ * This observable will be notified with any error during the creation of the environment,
3619
+ * mainly texture creation errors.
3620
+ */
3621
+ onErrorObservable: Observable<{
3622
+ message?: string;
3623
+ exception?: any;
3624
+ }>;
3625
+ private _translucentMaterialIndices;
3626
+ private _opaqueOnlySubMeshes;
3627
+ private _savedSubMeshes;
3628
+ /**
3629
+ * constructor
3630
+ * @param options Defines the options we want to customize the helper
3631
+ * @param scene The scene to add the material to
3632
+ */
3633
+ constructor(options: Partial<ITransmissionHelperOptions>, scene: Scene);
3634
+ /**
3635
+ * Registers a material implementation with the helper so it can classify and create
3636
+ * adapters for materials of that type. Safe to call multiple times with the same
3637
+ * implementation — duplicates are ignored.
3638
+ * @param impl The material implementation to register
3639
+ */
3640
+ addMaterialImpl(impl: ITransmissionHelperMaterialImpl): void;
3641
+ /**
3642
+ * Updates the helper options.
3643
+ * @param options the options to update
3644
+ */
3645
+ updateOptions(options: Partial<ITransmissionHelperOptions>): void;
3646
+ /**
3647
+ * @returns the opaque render target texture or null if not available.
3648
+ */
3649
+ getOpaqueTarget(): Nullable<Texture>;
3650
+ private _getOrCreateAdapter;
3651
+ /**
3652
+ * Classify a mesh's materials as transparent, opaque, or mixed.
3653
+ * Sets the refraction background texture on any translucent materials found.
3654
+ * For mixed MultiMaterial meshes, populates _translucentMaterialIndices so
3655
+ * their translucent submeshes can be excluded from the opaque render target.
3656
+ * @param mesh - The mesh to classify
3657
+ * @returns 'transparent' if all materials are translucent, 'opaque' if none are, 'mixed' if both
3658
+ */
3659
+ private _classifyMeshMaterials;
3660
+ /**
3661
+ * Rebuild the cached opaque-only submesh array for a mixed mesh.
3662
+ * Called when classification changes so the per-frame swap is allocation-free.
3663
+ * @param mesh - The mesh to rebuild for
3664
+ * @param translucentIndices - Set of materialIndex values that are translucent
3665
+ */
3666
+ private _rebuildOpaqueOnlySubMeshes;
3667
+ private _addMesh;
3668
+ private _removeMesh;
3669
+ private _parseScene;
3670
+ private _onMeshMaterialChanged;
3671
+ /**
3672
+ * @internal
3673
+ * Check if the opaque render target has not been disposed and can still be used.
3674
+ * @returns
3675
+ */
3676
+ _isRenderTargetValid(): boolean;
3677
+ /**
3678
+ * @internal
3679
+ * Setup the render targets according to the specified options.
3680
+ */
3681
+ _setupRenderTargets(): void;
3682
+ /**
3683
+ * Dispose all the elements created by the Helper.
3684
+ */
3685
+ dispose(): void;
3686
+ }
3687
+ /**
3688
+ * Ensures a TransmissionHelper exists on the scene and has all of the loader's material
3689
+ * implementations registered with it. Creates the helper if one does not yet exist on the
3690
+ * scene, and recreates its render target if it has been disposed. Does nothing when the
3691
+ * loader's parent has `dontUseTransmissionHelper` set.
3692
+ * @param loader The glTF loader whose material implementations should be registered
3693
+ * @param babylonMaterial A material belonging to the scene where the helper should live
3694
+ */
3695
+ export function ensureTransmissionHelper(loader: GLTFLoader, babylonMaterial: Material): void;
3696
+
3514
3697
  }
3515
3698
  declare module "babylonjs-loaders/glTF/2.0/Extensions/objectModelMapping" {
3516
3699
  import { TransformNode } from "babylonjs/Meshes/transformNode";
@@ -3842,6 +4025,7 @@ export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_fuzz";
3842
4025
  export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_specular";
3843
4026
  export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_ior";
3844
4027
  export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_variants";
4028
+ export * from "babylonjs-loaders/glTF/2.0/Extensions/transmissionHelper";
3845
4029
  export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_transmission";
3846
4030
  export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_diffuse_transmission";
3847
4031
  export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_volume";
@@ -8619,6 +8803,11 @@ declare namespace BABYLON.GLTF2 {
8619
8803
  * Gets the underlying material
8620
8804
  */
8621
8805
  get material(): PBRMaterial;
8806
+ /**
8807
+ * No-op: PBRMaterial has no deferred finalization.
8808
+ * @param _loader Unused.
8809
+ */
8810
+ finalizeAsync(_loader: BABYLON.GLTF2.GLTFLoader): Promise<void>;
8622
8811
  /**
8623
8812
  * Whether the material should be treated as unlit
8624
8813
  */
@@ -10034,10 +10223,9 @@ declare namespace BABYLON.GLTF2 {
10034
10223
  set geometryCoatNormalTextureScale(value: number);
10035
10224
  /**
10036
10225
  * Finalizes material properties after all loading is complete.
10037
- * @param signal An AbortSignal that fires when the loader is disposed. Intermediate
10038
- * textures are disposed and the method returns early when aborted.
10226
+ * @param loader The glTF loader; `loader._disposed` is polled between texture passes to bail early on dispose.
10039
10227
  */
10040
- finalizeAsync(signal: AbortSignal): Promise<void>;
10228
+ finalizeAsync(loader: BABYLON.GLTF2.GLTFLoader): Promise<void>;
10041
10229
  private copySurfaceToCoatAsync;
10042
10230
  }
10043
10231
 
@@ -10058,20 +10246,17 @@ declare namespace BABYLON.GLTF2 {
10058
10246
  * Gets the underlying material
10059
10247
  */
10060
10248
  readonly material: Material;
10061
- /** @deprecated Use finalizeAsync instead. */
10062
- finalize?(): void;
10063
10249
  /**
10064
10250
  * Finalizes material properties after all loading is complete.
10065
- * May return a Promise for async work (e.g. GPU texture processing). Any returned
10066
- * Promise is tracked by the loader and awaited before the COMPLETE state is reached,
10067
- * so callers can rely on onCompleteObservable for fully processed materials.
10251
+ * May do async work (e.g. GPU texture processing); the returned Promise is tracked
10252
+ * by the loader and awaited before the COMPLETE state is reached, so callers can rely
10253
+ * on onCompleteObservable for fully processed materials.
10068
10254
  *
10069
- * The loader passes an AbortSignal that is aborted when the loader is disposed.
10070
- * Implementations should check `signal.aborted` after each await point and, if
10071
- * aborted, release any intermediate resources and return early.
10072
- * @param signal An AbortSignal that fires when the loader is disposed mid-flight.
10255
+ * Implementations should check `loader._disposed` between awaits to bail out early
10256
+ * when the loader is disposed mid-flight.
10257
+ * @param loader The glTF loader driving the finalize step.
10073
10258
  */
10074
- finalizeAsync?(signal: AbortSignal): Promise<void> | void;
10259
+ finalizeAsync(loader: BABYLON.GLTF2.GLTFLoader): Promise<void>;
10075
10260
  /**
10076
10261
  * Whether the material should be treated as unlit
10077
10262
  */
@@ -11006,8 +11191,6 @@ declare namespace BABYLON.GLTF2 {
11006
11191
  export class GLTFLoader implements IGLTFLoader {
11007
11192
  /** @internal */
11008
11193
  readonly _completePromises: Promise<unknown>[];
11009
- /** AbortController used to cancel in-flight finalizeAsync() calls when dispose() is called. */
11010
- private _finalizeController;
11011
11194
  /** @internal */
11012
11195
  _assetContainer: Nullable<AssetContainer>;
11013
11196
  /** Storage */
@@ -11020,7 +11203,8 @@ declare namespace BABYLON.GLTF2 {
11020
11203
  _skipStartAnimationStep: boolean;
11021
11204
  private readonly _parent;
11022
11205
  private readonly _extensions;
11023
- private _disposed;
11206
+ /** @internal */
11207
+ _disposed: boolean;
11024
11208
  private _rootUrl;
11025
11209
  private _fileName;
11026
11210
  private _uniqueRootUrl;
@@ -11032,12 +11216,17 @@ declare namespace BABYLON.GLTF2 {
11032
11216
  private readonly _postSceneLoadActions;
11033
11217
  private readonly _materialAdapterCache;
11034
11218
  private readonly _materialAdapters;
11035
- /** @internal */
11036
- _pbrMaterialImpl: Nullable<Readonly<PBRMaterialImplementation>> | false;
11037
11219
  /**
11038
- * Test if the given material is of the same type as the one used by the loader
11220
+ * Loaded PBR material implementations, keyed by their identifier (e.g. "pbr", "openpbr").
11221
+ * Only populated after the load has started and only for the types actually needed by the asset.
11222
+ * Empty when PBR materials are disabled (skipMaterials).
11223
+ * @internal
11224
+ */
11225
+ readonly _pbrMaterialImpls: Map<string, Readonly<PBRMaterialImplementation>>;
11226
+ /**
11227
+ * Test if the given material is an instance of any PBR material type known to this loader.
11039
11228
  * @param material The material to test
11040
- * @returns true if the material is of the same type, false otherwise
11229
+ * @returns true if the material matches one of the loaded PBR implementations
11041
11230
  */
11042
11231
  isMatchingMaterialType(material: Nullable<Material>): boolean;
11043
11232
  /**
@@ -11232,6 +11421,21 @@ declare namespace BABYLON.GLTF2 {
11232
11421
  * @internal
11233
11422
  */
11234
11423
  _loadMaterialAsync(context: string, material: BABYLON.GLTF2.Loader.IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
11424
+ /**
11425
+ * Selects the appropriate PBR material implementation for a given glTF material.
11426
+ * Uses OpenPBR when the material carries a "KHR_materials_openpbr" extension or when
11427
+ * the loader-level `useOpenPBR` flag is set; falls back to standard PBR otherwise.
11428
+ * @param material The glTF material
11429
+ * @returns The matching loaded implementation
11430
+ */
11431
+ private _selectImplForGltfMaterial;
11432
+ /**
11433
+ * Returns the default PBR material implementation used when there is no per-material
11434
+ * selection context (e.g. when creating the built-in default material for primitives
11435
+ * that have no glTF material assigned). Prefers OpenPBR when `useOpenPBR` is set.
11436
+ * @returns The default loaded implementation
11437
+ */
11438
+ private _getDefaultImpl;
11235
11439
  private _createDefaultMaterial;
11236
11440
  /**
11237
11441
  * Creates a Babylon material from a glTF material.
@@ -11387,6 +11591,164 @@ declare namespace BABYLON.GLTF2 {
11387
11591
 
11388
11592
 
11389
11593
 
11594
+ }
11595
+ declare namespace BABYLON {
11596
+
11597
+
11598
+ }
11599
+ declare namespace BABYLON.GLTF2.Loader.Extensions {
11600
+ /**
11601
+ * Describes a material class and its corresponding loading adapter.
11602
+ * Passed to TransmissionHelper so it can classify and interact with materials
11603
+ * independently of any specific loader instance.
11604
+ */
11605
+ export interface ITransmissionHelperMaterialImpl {
11606
+ /** The material class constructor */
11607
+ materialClass: typeof Material;
11608
+ /** The adapter class constructor */
11609
+ adapterClass: new (material: Material) => BABYLON.GLTF2.IMaterialLoadingAdapter;
11610
+ }
11611
+ /**
11612
+ * @internal
11613
+ */
11614
+ export interface ITransmissionHelperHolder {
11615
+ /** The transmission helper instance, if created on the scene */
11616
+ _transmissionHelper: TransmissionHelper | undefined;
11617
+ }
11618
+ /**
11619
+ * Options for the TransmissionHelper.
11620
+ */
11621
+ export interface ITransmissionHelperOptions {
11622
+ /**
11623
+ * The size of the render buffers (default: 1024)
11624
+ */
11625
+ renderSize: number;
11626
+ /**
11627
+ * The number of samples to use when generating the render target texture for opaque meshes (default: 4)
11628
+ */
11629
+ samples: number;
11630
+ /**
11631
+ * Scale to apply when selecting the LOD level to sample the refraction texture (default: 1)
11632
+ */
11633
+ lodGenerationScale: number;
11634
+ /**
11635
+ * Offset to apply when selecting the LOD level to sample the refraction texture (default: -4)
11636
+ */
11637
+ lodGenerationOffset: number;
11638
+ /**
11639
+ * Type of the refraction render target texture (default: TEXTURETYPE_HALF_FLOAT)
11640
+ */
11641
+ renderTargetTextureType: number;
11642
+ /**
11643
+ * Defines if the mipmaps for the refraction render target texture must be generated (default: true)
11644
+ */
11645
+ generateMipmaps: boolean;
11646
+ /**
11647
+ * Clear color of the opaque texture. If not provided, use the scene clear color (which will be converted to linear space).
11648
+ * If provided, should be in linear space
11649
+ */
11650
+ clearColor?: Color4;
11651
+ }
11652
+ /**
11653
+ * A class to handle setting up the rendering of opaque objects to be shown through transmissive objects.
11654
+ * @internal
11655
+ */
11656
+ export class TransmissionHelper {
11657
+ /**
11658
+ * Creates the default options for the helper.
11659
+ * @returns the default options
11660
+ */
11661
+ private static _GetDefaultOptions;
11662
+ private readonly _scene;
11663
+ private _options;
11664
+ private _opaqueRenderTarget;
11665
+ private _opaqueMeshesCache;
11666
+ private _transparentMeshesCache;
11667
+ private _materialObservers;
11668
+ private readonly _materialImpls;
11669
+ private readonly _adapterCache;
11670
+ /**
11671
+ * This observable will be notified with any error during the creation of the environment,
11672
+ * mainly texture creation errors.
11673
+ */
11674
+ onErrorObservable: Observable<{
11675
+ message?: string;
11676
+ exception?: any;
11677
+ }>;
11678
+ private _translucentMaterialIndices;
11679
+ private _opaqueOnlySubMeshes;
11680
+ private _savedSubMeshes;
11681
+ /**
11682
+ * constructor
11683
+ * @param options Defines the options we want to customize the helper
11684
+ * @param scene The scene to add the material to
11685
+ */
11686
+ constructor(options: Partial<ITransmissionHelperOptions>, scene: Scene);
11687
+ /**
11688
+ * Registers a material implementation with the helper so it can classify and create
11689
+ * adapters for materials of that type. Safe to call multiple times with the same
11690
+ * implementation — duplicates are ignored.
11691
+ * @param impl The material implementation to register
11692
+ */
11693
+ addMaterialImpl(impl: ITransmissionHelperMaterialImpl): void;
11694
+ /**
11695
+ * Updates the helper options.
11696
+ * @param options the options to update
11697
+ */
11698
+ updateOptions(options: Partial<ITransmissionHelperOptions>): void;
11699
+ /**
11700
+ * @returns the opaque render target texture or null if not available.
11701
+ */
11702
+ getOpaqueTarget(): Nullable<Texture>;
11703
+ private _getOrCreateAdapter;
11704
+ /**
11705
+ * Classify a mesh's materials as transparent, opaque, or mixed.
11706
+ * Sets the refraction background texture on any translucent materials found.
11707
+ * For mixed MultiMaterial meshes, populates _translucentMaterialIndices so
11708
+ * their translucent submeshes can be excluded from the opaque render target.
11709
+ * @param mesh - The mesh to classify
11710
+ * @returns 'transparent' if all materials are translucent, 'opaque' if none are, 'mixed' if both
11711
+ */
11712
+ private _classifyMeshMaterials;
11713
+ /**
11714
+ * Rebuild the cached opaque-only submesh array for a mixed mesh.
11715
+ * Called when classification changes so the per-frame swap is allocation-free.
11716
+ * @param mesh - The mesh to rebuild for
11717
+ * @param translucentIndices - Set of materialIndex values that are translucent
11718
+ */
11719
+ private _rebuildOpaqueOnlySubMeshes;
11720
+ private _addMesh;
11721
+ private _removeMesh;
11722
+ private _parseScene;
11723
+ private _onMeshMaterialChanged;
11724
+ /**
11725
+ * @internal
11726
+ * Check if the opaque render target has not been disposed and can still be used.
11727
+ * @returns
11728
+ */
11729
+ _isRenderTargetValid(): boolean;
11730
+ /**
11731
+ * @internal
11732
+ * Setup the render targets according to the specified options.
11733
+ */
11734
+ _setupRenderTargets(): void;
11735
+ /**
11736
+ * Dispose all the elements created by the Helper.
11737
+ */
11738
+ dispose(): void;
11739
+ }
11740
+ /**
11741
+ * Ensures a TransmissionHelper exists on the scene and has all of the loader's material
11742
+ * implementations registered with it. Creates the helper if one does not yet exist on the
11743
+ * scene, and recreates its render target if it has been disposed. Does nothing when the
11744
+ * loader's parent has `dontUseTransmissionHelper` set.
11745
+ * @param loader The glTF loader whose material implementations should be registered
11746
+ * @param babylonMaterial A material belonging to the scene where the helper should live
11747
+ */
11748
+ export function ensureTransmissionHelper(loader: BABYLON.GLTF2.GLTFLoader, babylonMaterial: Material): void;
11749
+
11750
+
11751
+
11390
11752
  }
11391
11753
  declare namespace BABYLON {
11392
11754
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babylonjs-loaders",
3
- "version": "9.7.0",
3
+ "version": "9.9.0",
4
4
  "main": "babylonjs.loaders.min.js",
5
5
  "types": "babylonjs.loaders.module.d.ts",
6
6
  "files": [
@@ -16,8 +16,8 @@
16
16
  "test:escheck": "es-check es6 ./babylonjs.loaders.js"
17
17
  },
18
18
  "dependencies": {
19
- "babylonjs": "9.7.0",
20
- "babylonjs-gltf2interface": "9.7.0"
19
+ "babylonjs": "9.9.0",
20
+ "babylonjs-gltf2interface": "9.9.0"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@dev/build-tools": "1.0.0",