babylonjs-loaders 9.6.2 → 9.8.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,11 +702,13 @@ 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
  */
708
709
  export class PBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
709
710
  private _material;
711
+ private _specWorkflow;
710
712
  /**
711
713
  * Creates a new instance of the PBRMaterialLoadingAdapter.
712
714
  * @param material - The PBR material to adapt.
@@ -716,6 +718,11 @@ export class PBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
716
718
  * Gets the underlying material
717
719
  */
718
720
  get material(): PBRMaterial;
721
+ /**
722
+ * No-op: PBRMaterial has no deferred finalization.
723
+ * @param _loader Unused.
724
+ */
725
+ finalizeAsync(_loader: GLTFLoader): Promise<void>;
719
726
  /**
720
727
  * Whether the material should be treated as unlit
721
728
  */
@@ -848,6 +855,10 @@ export class PBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
848
855
  * @param enableEdgeColor Whether to enable OpenPBR BRDF models for edge color support
849
856
  */
850
857
  enableSpecularEdgeColor(enableEdgeColor?: boolean): void;
858
+ /**
859
+ * Enable the specular/glossiness workflow and disable metallic/roughness.
860
+ */
861
+ configureSpecularGlossiness(): void;
851
862
  /**
852
863
  * Sets the specular weight (mapped to PBR metallicF0Factor).
853
864
  * @param value The specular weight value
@@ -921,6 +932,16 @@ export class PBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
921
932
  * @returns The IOR value
922
933
  */
923
934
  get specularIor(): number;
935
+ /**
936
+ * Sets/gets the glossiness (inverted roughness)
937
+ * ONLY used for specular/glossiness workflow; has no effect when metallic/roughness workflow is active
938
+ */
939
+ get glossiness(): number;
940
+ /**
941
+ * Sets/gets the glossiness (inverted roughness)
942
+ * ONLY used for specular/glossiness workflow; has no effect when metallic/roughness workflow is active
943
+ */
944
+ set glossiness(value: number);
924
945
  /**
925
946
  * Sets the emission color (mapped to PBR emissiveColor).
926
947
  * @param value The emission color as a Color3
@@ -1154,6 +1175,9 @@ export class PBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
1154
1175
  * Sets up the material for proper thin-surface transmission behavior.
1155
1176
  */
1156
1177
  configureTransmission(): void;
1178
+ /**
1179
+ * Configures volume properties for PBR material. Nothing to do for PBRMaterial.
1180
+ */
1157
1181
  configureVolume(): void;
1158
1182
  /**
1159
1183
  * Sets whether the material is thin-walled (i.e. non-volumetric) or not.
@@ -1414,11 +1438,13 @@ import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
1414
1438
  import { Nullable } from "babylonjs/types";
1415
1439
  import { Color3 } from "babylonjs/Maths/math.color";
1416
1440
  import { IMaterialLoadingAdapter } from "babylonjs-loaders/glTF/2.0/materialLoadingAdapter";
1441
+ import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
1417
1442
  /**
1418
1443
  * Material Loading Adapter for OpenPBR materials that provides a unified OpenPBR-like interface.
1419
1444
  */
1420
1445
  export class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
1421
1446
  private _material;
1447
+ private _specWorkflow;
1422
1448
  /**
1423
1449
  * Creates a new instance of the OpenPBRMaterialLoadingAdapter.
1424
1450
  * @param material - The OpenPBR material to adapt.
@@ -1561,6 +1587,7 @@ export class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
1561
1587
  * @param _enableEdgeColor Whether to enable edge color support (ignored for OpenPBR)
1562
1588
  */
1563
1589
  enableSpecularEdgeColor(_enableEdgeColor?: boolean): void;
1590
+ configureSpecularGlossiness(): void;
1564
1591
  /**
1565
1592
  * Sets the specular weight of the OpenPBR material.
1566
1593
  * @param value The specular weight value (0-1)
@@ -1633,6 +1660,11 @@ export class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
1633
1660
  * @returns The IOR value
1634
1661
  */
1635
1662
  get specularIor(): number;
1663
+ /**
1664
+ * Sets the glossiness (inverted roughness) of the OpenPBR material.
1665
+ */
1666
+ set glossiness(value: number);
1667
+ get glossiness(): number;
1636
1668
  /**
1637
1669
  * Sets the emission color of the OpenPBR material.
1638
1670
  * @param value The emission color as a Color3
@@ -1713,6 +1745,10 @@ export class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
1713
1745
  * @param value The coat color as a Color3
1714
1746
  */
1715
1747
  set coatColor(value: Color3);
1748
+ /**
1749
+ * Gets the coat color of the OpenPBR material.
1750
+ */
1751
+ get coatColor(): Color3;
1716
1752
  /**
1717
1753
  * Sets the coat color texture of the OpenPBR material.
1718
1754
  * @param value The coat color texture or null
@@ -1742,11 +1778,13 @@ export class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
1742
1778
  * Sets the coat index of refraction (IOR) of the OpenPBR material.
1743
1779
  */
1744
1780
  set coatIor(value: number);
1781
+ get coatIor(): number;
1745
1782
  /**
1746
1783
  * Sets the coat darkening value of the OpenPBR material.
1747
1784
  * @param value The coat darkening value
1748
1785
  */
1749
1786
  set coatDarkening(value: number);
1787
+ get coatDarkening(): number;
1750
1788
  /**
1751
1789
  * Sets the coat darkening texture (OpenPBR: coatDarkeningTexture, no PBR equivalent)
1752
1790
  */
@@ -1795,6 +1833,7 @@ export class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
1795
1833
  * @param value The transmission weight texture or null
1796
1834
  */
1797
1835
  set transmissionWeightTexture(value: Nullable<BaseTexture>);
1836
+ get transmissionWeightTexture(): Nullable<BaseTexture>;
1798
1837
  /**
1799
1838
  * Gets the transmission weight.
1800
1839
  * @returns Currently returns 0 as transmission is not yet available
@@ -1863,6 +1902,9 @@ export class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
1863
1902
  * @param value The refraction background texture or null
1864
1903
  */
1865
1904
  set refractionBackgroundTexture(value: Nullable<BaseTexture>);
1905
+ /**
1906
+ * Configures volume properties for OpenPBR material.
1907
+ */
1866
1908
  configureVolume(): void;
1867
1909
  /**
1868
1910
  * Sets whether the material is thin-walled (i.e. non-volumetric) or not.
@@ -1895,6 +1937,7 @@ export class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
1895
1937
  * Sets the subsurface weight texture
1896
1938
  */
1897
1939
  set subsurfaceWeightTexture(value: Nullable<BaseTexture>);
1940
+ get subsurfaceWeightTexture(): Nullable<BaseTexture>;
1898
1941
  /**
1899
1942
  * Sets the subsurface color.
1900
1943
  * @param value The subsurface tint color as a Color3
@@ -2094,7 +2137,12 @@ export class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
2094
2137
  * @param value The scale value for the coat normal texture
2095
2138
  */
2096
2139
  set geometryCoatNormalTextureScale(value: number);
2097
- finalize(): void;
2140
+ /**
2141
+ * Finalizes material properties after all loading is complete.
2142
+ * @param loader The glTF loader; `loader._disposed` is polled between texture passes to bail early on dispose.
2143
+ */
2144
+ finalizeAsync(loader: GLTFLoader): Promise<void>;
2145
+ private copySurfaceToCoatAsync;
2098
2146
  }
2099
2147
 
2100
2148
  }
@@ -2103,6 +2151,7 @@ import { Material } from "babylonjs/Materials/material";
2103
2151
  import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
2104
2152
  import { Nullable } from "babylonjs/types";
2105
2153
  import { Color3 } from "babylonjs/Maths/math.color";
2154
+ import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
2106
2155
  /**
2107
2156
  * Interface for material loading adapters that provides a unified OpenPBR-like interface
2108
2157
  * for both OpenPBR and PBR materials, eliminating conditional branches in extensions.
@@ -2113,9 +2162,16 @@ export interface IMaterialLoadingAdapter {
2113
2162
  */
2114
2163
  readonly material: Material;
2115
2164
  /**
2116
- * Finalizes material properties after loading is complete.
2165
+ * Finalizes material properties after all loading is complete.
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.
2169
+ *
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.
2117
2173
  */
2118
- finalize?(): void;
2174
+ finalizeAsync(loader: GLTFLoader): Promise<void>;
2119
2175
  /**
2120
2176
  * Whether the material should be treated as unlit
2121
2177
  */
@@ -2177,6 +2233,10 @@ export interface IMaterialLoadingAdapter {
2177
2233
  * @param enableEdgeColor - Whether to enable edge color support
2178
2234
  */
2179
2235
  enableSpecularEdgeColor(enableEdgeColor?: boolean): void;
2236
+ /**
2237
+ * Enable the specular/glossiness workflow and disable metallic/roughness.
2238
+ */
2239
+ configureSpecularGlossiness(): void;
2180
2240
  /**
2181
2241
  * Sets/gets the specular weight
2182
2242
  */
@@ -2205,6 +2265,11 @@ export interface IMaterialLoadingAdapter {
2205
2265
  * Sets/gets the specular IOR
2206
2266
  */
2207
2267
  specularIor: number;
2268
+ /**
2269
+ * Sets/gets the glossiness (inverted roughness)
2270
+ * ONLY used for specular/glossiness workflow; has no effect when metallic/roughness workflow is active
2271
+ */
2272
+ glossiness: number;
2208
2273
  /**
2209
2274
  * Sets/gets the emissive color
2210
2275
  */
@@ -2321,6 +2386,9 @@ export interface IMaterialLoadingAdapter {
2321
2386
  * Configures transmission for thin-surface transmission (KHR_materials_transmission)
2322
2387
  */
2323
2388
  configureTransmission(): void;
2389
+ /**
2390
+ * Configures volume properties for volumetric transmission (KHR_materials_volume)
2391
+ */
2324
2392
  configureVolume(): void;
2325
2393
  /**
2326
2394
  * Sets whether the material is thin-walled (i.e. non-volumetric) or not.
@@ -3080,7 +3148,8 @@ export class GLTFLoader implements IGLTFLoader {
3080
3148
  _skipStartAnimationStep: boolean;
3081
3149
  private readonly _parent;
3082
3150
  private readonly _extensions;
3083
- private _disposed;
3151
+ /** @internal */
3152
+ _disposed: boolean;
3084
3153
  private _rootUrl;
3085
3154
  private _fileName;
3086
3155
  private _uniqueRootUrl;
@@ -8543,6 +8612,7 @@ declare namespace BABYLON.GLTF2 {
8543
8612
  */
8544
8613
  export class PBRMaterialLoadingAdapter implements BABYLON.GLTF2.IMaterialLoadingAdapter {
8545
8614
  private _material;
8615
+ private _specWorkflow;
8546
8616
  /**
8547
8617
  * Creates a new instance of the PBRMaterialLoadingAdapter.
8548
8618
  * @param material - The PBR material to adapt.
@@ -8552,6 +8622,11 @@ declare namespace BABYLON.GLTF2 {
8552
8622
  * Gets the underlying material
8553
8623
  */
8554
8624
  get material(): PBRMaterial;
8625
+ /**
8626
+ * No-op: PBRMaterial has no deferred finalization.
8627
+ * @param _loader Unused.
8628
+ */
8629
+ finalizeAsync(_loader: BABYLON.GLTF2.GLTFLoader): Promise<void>;
8555
8630
  /**
8556
8631
  * Whether the material should be treated as unlit
8557
8632
  */
@@ -8684,6 +8759,10 @@ declare namespace BABYLON.GLTF2 {
8684
8759
  * @param enableEdgeColor Whether to enable OpenPBR BRDF models for edge color support
8685
8760
  */
8686
8761
  enableSpecularEdgeColor(enableEdgeColor?: boolean): void;
8762
+ /**
8763
+ * Enable the specular/glossiness workflow and disable metallic/roughness.
8764
+ */
8765
+ configureSpecularGlossiness(): void;
8687
8766
  /**
8688
8767
  * Sets the specular weight (mapped to PBR metallicF0Factor).
8689
8768
  * @param value The specular weight value
@@ -8757,6 +8836,16 @@ declare namespace BABYLON.GLTF2 {
8757
8836
  * @returns The IOR value
8758
8837
  */
8759
8838
  get specularIor(): number;
8839
+ /**
8840
+ * Sets/gets the glossiness (inverted roughness)
8841
+ * ONLY used for specular/glossiness workflow; has no effect when metallic/roughness workflow is active
8842
+ */
8843
+ get glossiness(): number;
8844
+ /**
8845
+ * Sets/gets the glossiness (inverted roughness)
8846
+ * ONLY used for specular/glossiness workflow; has no effect when metallic/roughness workflow is active
8847
+ */
8848
+ set glossiness(value: number);
8760
8849
  /**
8761
8850
  * Sets the emission color (mapped to PBR emissiveColor).
8762
8851
  * @param value The emission color as a Color3
@@ -8990,6 +9079,9 @@ declare namespace BABYLON.GLTF2 {
8990
9079
  * Sets up the material for proper thin-surface transmission behavior.
8991
9080
  */
8992
9081
  configureTransmission(): void;
9082
+ /**
9083
+ * Configures volume properties for PBR material. Nothing to do for PBRMaterial.
9084
+ */
8993
9085
  configureVolume(): void;
8994
9086
  /**
8995
9087
  * Sets whether the material is thin-walled (i.e. non-volumetric) or not.
@@ -9255,6 +9347,7 @@ declare namespace BABYLON.GLTF2 {
9255
9347
  */
9256
9348
  export class OpenPBRMaterialLoadingAdapter implements BABYLON.GLTF2.IMaterialLoadingAdapter {
9257
9349
  private _material;
9350
+ private _specWorkflow;
9258
9351
  /**
9259
9352
  * Creates a new instance of the OpenPBRMaterialLoadingAdapter.
9260
9353
  * @param material - The OpenPBR material to adapt.
@@ -9397,6 +9490,7 @@ declare namespace BABYLON.GLTF2 {
9397
9490
  * @param _enableEdgeColor Whether to enable edge color support (ignored for OpenPBR)
9398
9491
  */
9399
9492
  enableSpecularEdgeColor(_enableEdgeColor?: boolean): void;
9493
+ configureSpecularGlossiness(): void;
9400
9494
  /**
9401
9495
  * Sets the specular weight of the OpenPBR material.
9402
9496
  * @param value The specular weight value (0-1)
@@ -9469,6 +9563,11 @@ declare namespace BABYLON.GLTF2 {
9469
9563
  * @returns The IOR value
9470
9564
  */
9471
9565
  get specularIor(): number;
9566
+ /**
9567
+ * Sets the glossiness (inverted roughness) of the OpenPBR material.
9568
+ */
9569
+ set glossiness(value: number);
9570
+ get glossiness(): number;
9472
9571
  /**
9473
9572
  * Sets the emission color of the OpenPBR material.
9474
9573
  * @param value The emission color as a Color3
@@ -9549,6 +9648,10 @@ declare namespace BABYLON.GLTF2 {
9549
9648
  * @param value The coat color as a Color3
9550
9649
  */
9551
9650
  set coatColor(value: Color3);
9651
+ /**
9652
+ * Gets the coat color of the OpenPBR material.
9653
+ */
9654
+ get coatColor(): Color3;
9552
9655
  /**
9553
9656
  * Sets the coat color texture of the OpenPBR material.
9554
9657
  * @param value The coat color texture or null
@@ -9578,11 +9681,13 @@ declare namespace BABYLON.GLTF2 {
9578
9681
  * Sets the coat index of refraction (IOR) of the OpenPBR material.
9579
9682
  */
9580
9683
  set coatIor(value: number);
9684
+ get coatIor(): number;
9581
9685
  /**
9582
9686
  * Sets the coat darkening value of the OpenPBR material.
9583
9687
  * @param value The coat darkening value
9584
9688
  */
9585
9689
  set coatDarkening(value: number);
9690
+ get coatDarkening(): number;
9586
9691
  /**
9587
9692
  * Sets the coat darkening texture (OpenPBR: coatDarkeningTexture, no PBR equivalent)
9588
9693
  */
@@ -9631,6 +9736,7 @@ declare namespace BABYLON.GLTF2 {
9631
9736
  * @param value The transmission weight texture or null
9632
9737
  */
9633
9738
  set transmissionWeightTexture(value: Nullable<BaseTexture>);
9739
+ get transmissionWeightTexture(): Nullable<BaseTexture>;
9634
9740
  /**
9635
9741
  * Gets the transmission weight.
9636
9742
  * @returns Currently returns 0 as transmission is not yet available
@@ -9699,6 +9805,9 @@ declare namespace BABYLON.GLTF2 {
9699
9805
  * @param value The refraction background texture or null
9700
9806
  */
9701
9807
  set refractionBackgroundTexture(value: Nullable<BaseTexture>);
9808
+ /**
9809
+ * Configures volume properties for OpenPBR material.
9810
+ */
9702
9811
  configureVolume(): void;
9703
9812
  /**
9704
9813
  * Sets whether the material is thin-walled (i.e. non-volumetric) or not.
@@ -9731,6 +9840,7 @@ declare namespace BABYLON.GLTF2 {
9731
9840
  * Sets the subsurface weight texture
9732
9841
  */
9733
9842
  set subsurfaceWeightTexture(value: Nullable<BaseTexture>);
9843
+ get subsurfaceWeightTexture(): Nullable<BaseTexture>;
9734
9844
  /**
9735
9845
  * Sets the subsurface color.
9736
9846
  * @param value The subsurface tint color as a Color3
@@ -9930,7 +10040,12 @@ declare namespace BABYLON.GLTF2 {
9930
10040
  * @param value The scale value for the coat normal texture
9931
10041
  */
9932
10042
  set geometryCoatNormalTextureScale(value: number);
9933
- finalize(): void;
10043
+ /**
10044
+ * Finalizes material properties after all loading is complete.
10045
+ * @param loader The glTF loader; `loader._disposed` is polled between texture passes to bail early on dispose.
10046
+ */
10047
+ finalizeAsync(loader: BABYLON.GLTF2.GLTFLoader): Promise<void>;
10048
+ private copySurfaceToCoatAsync;
9934
10049
  }
9935
10050
 
9936
10051
 
@@ -9951,9 +10066,16 @@ declare namespace BABYLON.GLTF2 {
9951
10066
  */
9952
10067
  readonly material: Material;
9953
10068
  /**
9954
- * Finalizes material properties after loading is complete.
10069
+ * Finalizes material properties after all loading is complete.
10070
+ * May do async work (e.g. GPU texture processing); the returned Promise is tracked
10071
+ * by the loader and awaited before the COMPLETE state is reached, so callers can rely
10072
+ * on onCompleteObservable for fully processed materials.
10073
+ *
10074
+ * Implementations should check `loader._disposed` between awaits to bail out early
10075
+ * when the loader is disposed mid-flight.
10076
+ * @param loader The glTF loader driving the finalize step.
9955
10077
  */
9956
- finalize?(): void;
10078
+ finalizeAsync(loader: BABYLON.GLTF2.GLTFLoader): Promise<void>;
9957
10079
  /**
9958
10080
  * Whether the material should be treated as unlit
9959
10081
  */
@@ -10015,6 +10137,10 @@ declare namespace BABYLON.GLTF2 {
10015
10137
  * @param enableEdgeColor - Whether to enable edge color support
10016
10138
  */
10017
10139
  enableSpecularEdgeColor(enableEdgeColor?: boolean): void;
10140
+ /**
10141
+ * Enable the specular/glossiness workflow and disable metallic/roughness.
10142
+ */
10143
+ configureSpecularGlossiness(): void;
10018
10144
  /**
10019
10145
  * Sets/gets the specular weight
10020
10146
  */
@@ -10043,6 +10169,11 @@ declare namespace BABYLON.GLTF2 {
10043
10169
  * Sets/gets the specular IOR
10044
10170
  */
10045
10171
  specularIor: number;
10172
+ /**
10173
+ * Sets/gets the glossiness (inverted roughness)
10174
+ * ONLY used for specular/glossiness workflow; has no effect when metallic/roughness workflow is active
10175
+ */
10176
+ glossiness: number;
10046
10177
  /**
10047
10178
  * Sets/gets the emissive color
10048
10179
  */
@@ -10159,6 +10290,9 @@ declare namespace BABYLON.GLTF2 {
10159
10290
  * Configures transmission for thin-surface transmission (KHR_materials_transmission)
10160
10291
  */
10161
10292
  configureTransmission(): void;
10293
+ /**
10294
+ * Configures volume properties for volumetric transmission (KHR_materials_volume)
10295
+ */
10162
10296
  configureVolume(): void;
10163
10297
  /**
10164
10298
  * Sets whether the material is thin-walled (i.e. non-volumetric) or not.
@@ -10888,7 +11022,8 @@ declare namespace BABYLON.GLTF2 {
10888
11022
  _skipStartAnimationStep: boolean;
10889
11023
  private readonly _parent;
10890
11024
  private readonly _extensions;
10891
- private _disposed;
11025
+ /** @internal */
11026
+ _disposed: boolean;
10892
11027
  private _rootUrl;
10893
11028
  private _fileName;
10894
11029
  private _uniqueRootUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babylonjs-loaders",
3
- "version": "9.6.2",
3
+ "version": "9.8.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.6.2",
20
- "babylonjs-gltf2interface": "9.6.2"
19
+ "babylonjs": "9.8.0",
20
+ "babylonjs-gltf2interface": "9.8.0"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@dev/build-tools": "1.0.0",