babylonjs-loaders 9.6.2 → 9.7.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.
@@ -707,6 +707,7 @@ import { IMaterialLoadingAdapter } from "babylonjs-loaders/glTF/2.0/materialLoad
707
707
  */
708
708
  export class PBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
709
709
  private _material;
710
+ private _specWorkflow;
710
711
  /**
711
712
  * Creates a new instance of the PBRMaterialLoadingAdapter.
712
713
  * @param material - The PBR material to adapt.
@@ -848,6 +849,10 @@ export class PBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
848
849
  * @param enableEdgeColor Whether to enable OpenPBR BRDF models for edge color support
849
850
  */
850
851
  enableSpecularEdgeColor(enableEdgeColor?: boolean): void;
852
+ /**
853
+ * Enable the specular/glossiness workflow and disable metallic/roughness.
854
+ */
855
+ configureSpecularGlossiness(): void;
851
856
  /**
852
857
  * Sets the specular weight (mapped to PBR metallicF0Factor).
853
858
  * @param value The specular weight value
@@ -921,6 +926,16 @@ export class PBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
921
926
  * @returns The IOR value
922
927
  */
923
928
  get specularIor(): number;
929
+ /**
930
+ * Sets/gets the glossiness (inverted roughness)
931
+ * ONLY used for specular/glossiness workflow; has no effect when metallic/roughness workflow is active
932
+ */
933
+ get glossiness(): number;
934
+ /**
935
+ * Sets/gets the glossiness (inverted roughness)
936
+ * ONLY used for specular/glossiness workflow; has no effect when metallic/roughness workflow is active
937
+ */
938
+ set glossiness(value: number);
924
939
  /**
925
940
  * Sets the emission color (mapped to PBR emissiveColor).
926
941
  * @param value The emission color as a Color3
@@ -1154,6 +1169,9 @@ export class PBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
1154
1169
  * Sets up the material for proper thin-surface transmission behavior.
1155
1170
  */
1156
1171
  configureTransmission(): void;
1172
+ /**
1173
+ * Configures volume properties for PBR material. Nothing to do for PBRMaterial.
1174
+ */
1157
1175
  configureVolume(): void;
1158
1176
  /**
1159
1177
  * Sets whether the material is thin-walled (i.e. non-volumetric) or not.
@@ -1419,6 +1437,7 @@ import { IMaterialLoadingAdapter } from "babylonjs-loaders/glTF/2.0/materialLoad
1419
1437
  */
1420
1438
  export class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
1421
1439
  private _material;
1440
+ private _specWorkflow;
1422
1441
  /**
1423
1442
  * Creates a new instance of the OpenPBRMaterialLoadingAdapter.
1424
1443
  * @param material - The OpenPBR material to adapt.
@@ -1561,6 +1580,7 @@ export class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
1561
1580
  * @param _enableEdgeColor Whether to enable edge color support (ignored for OpenPBR)
1562
1581
  */
1563
1582
  enableSpecularEdgeColor(_enableEdgeColor?: boolean): void;
1583
+ configureSpecularGlossiness(): void;
1564
1584
  /**
1565
1585
  * Sets the specular weight of the OpenPBR material.
1566
1586
  * @param value The specular weight value (0-1)
@@ -1633,6 +1653,11 @@ export class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
1633
1653
  * @returns The IOR value
1634
1654
  */
1635
1655
  get specularIor(): number;
1656
+ /**
1657
+ * Sets the glossiness (inverted roughness) of the OpenPBR material.
1658
+ */
1659
+ set glossiness(value: number);
1660
+ get glossiness(): number;
1636
1661
  /**
1637
1662
  * Sets the emission color of the OpenPBR material.
1638
1663
  * @param value The emission color as a Color3
@@ -1713,6 +1738,10 @@ export class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
1713
1738
  * @param value The coat color as a Color3
1714
1739
  */
1715
1740
  set coatColor(value: Color3);
1741
+ /**
1742
+ * Gets the coat color of the OpenPBR material.
1743
+ */
1744
+ get coatColor(): Color3;
1716
1745
  /**
1717
1746
  * Sets the coat color texture of the OpenPBR material.
1718
1747
  * @param value The coat color texture or null
@@ -1742,11 +1771,13 @@ export class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
1742
1771
  * Sets the coat index of refraction (IOR) of the OpenPBR material.
1743
1772
  */
1744
1773
  set coatIor(value: number);
1774
+ get coatIor(): number;
1745
1775
  /**
1746
1776
  * Sets the coat darkening value of the OpenPBR material.
1747
1777
  * @param value The coat darkening value
1748
1778
  */
1749
1779
  set coatDarkening(value: number);
1780
+ get coatDarkening(): number;
1750
1781
  /**
1751
1782
  * Sets the coat darkening texture (OpenPBR: coatDarkeningTexture, no PBR equivalent)
1752
1783
  */
@@ -1795,6 +1826,7 @@ export class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
1795
1826
  * @param value The transmission weight texture or null
1796
1827
  */
1797
1828
  set transmissionWeightTexture(value: Nullable<BaseTexture>);
1829
+ get transmissionWeightTexture(): Nullable<BaseTexture>;
1798
1830
  /**
1799
1831
  * Gets the transmission weight.
1800
1832
  * @returns Currently returns 0 as transmission is not yet available
@@ -1863,6 +1895,9 @@ export class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
1863
1895
  * @param value The refraction background texture or null
1864
1896
  */
1865
1897
  set refractionBackgroundTexture(value: Nullable<BaseTexture>);
1898
+ /**
1899
+ * Configures volume properties for OpenPBR material.
1900
+ */
1866
1901
  configureVolume(): void;
1867
1902
  /**
1868
1903
  * Sets whether the material is thin-walled (i.e. non-volumetric) or not.
@@ -1895,6 +1930,7 @@ export class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
1895
1930
  * Sets the subsurface weight texture
1896
1931
  */
1897
1932
  set subsurfaceWeightTexture(value: Nullable<BaseTexture>);
1933
+ get subsurfaceWeightTexture(): Nullable<BaseTexture>;
1898
1934
  /**
1899
1935
  * Sets the subsurface color.
1900
1936
  * @param value The subsurface tint color as a Color3
@@ -2094,7 +2130,13 @@ export class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
2094
2130
  * @param value The scale value for the coat normal texture
2095
2131
  */
2096
2132
  set geometryCoatNormalTextureScale(value: number);
2097
- finalize(): void;
2133
+ /**
2134
+ * 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.
2137
+ */
2138
+ finalizeAsync(signal: AbortSignal): Promise<void>;
2139
+ private copySurfaceToCoatAsync;
2098
2140
  }
2099
2141
 
2100
2142
  }
@@ -2112,10 +2154,20 @@ export interface IMaterialLoadingAdapter {
2112
2154
  * Gets the underlying material
2113
2155
  */
2114
2156
  readonly material: Material;
2157
+ /** @deprecated Use finalizeAsync instead. */
2158
+ finalize?(): void;
2115
2159
  /**
2116
- * Finalizes material properties after loading is complete.
2160
+ * 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.
2164
+ *
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.
2117
2169
  */
2118
- finalize?(): void;
2170
+ finalizeAsync?(signal: AbortSignal): Promise<void> | void;
2119
2171
  /**
2120
2172
  * Whether the material should be treated as unlit
2121
2173
  */
@@ -2177,6 +2229,10 @@ export interface IMaterialLoadingAdapter {
2177
2229
  * @param enableEdgeColor - Whether to enable edge color support
2178
2230
  */
2179
2231
  enableSpecularEdgeColor(enableEdgeColor?: boolean): void;
2232
+ /**
2233
+ * Enable the specular/glossiness workflow and disable metallic/roughness.
2234
+ */
2235
+ configureSpecularGlossiness(): void;
2180
2236
  /**
2181
2237
  * Sets/gets the specular weight
2182
2238
  */
@@ -2205,6 +2261,11 @@ export interface IMaterialLoadingAdapter {
2205
2261
  * Sets/gets the specular IOR
2206
2262
  */
2207
2263
  specularIor: number;
2264
+ /**
2265
+ * Sets/gets the glossiness (inverted roughness)
2266
+ * ONLY used for specular/glossiness workflow; has no effect when metallic/roughness workflow is active
2267
+ */
2268
+ glossiness: number;
2208
2269
  /**
2209
2270
  * Sets/gets the emissive color
2210
2271
  */
@@ -2321,6 +2382,9 @@ export interface IMaterialLoadingAdapter {
2321
2382
  * Configures transmission for thin-surface transmission (KHR_materials_transmission)
2322
2383
  */
2323
2384
  configureTransmission(): void;
2385
+ /**
2386
+ * Configures volume properties for volumetric transmission (KHR_materials_volume)
2387
+ */
2324
2388
  configureVolume(): void;
2325
2389
  /**
2326
2390
  * Sets whether the material is thin-walled (i.e. non-volumetric) or not.
@@ -3068,6 +3132,8 @@ type PBRMaterialImplementation = {
3068
3132
  export class GLTFLoader implements IGLTFLoader {
3069
3133
  /** @internal */
3070
3134
  readonly _completePromises: Promise<unknown>[];
3135
+ /** AbortController used to cancel in-flight finalizeAsync() calls when dispose() is called. */
3136
+ private _finalizeController;
3071
3137
  /** @internal */
3072
3138
  _assetContainer: Nullable<AssetContainer>;
3073
3139
  /** Storage */
@@ -8543,6 +8609,7 @@ declare namespace BABYLON.GLTF2 {
8543
8609
  */
8544
8610
  export class PBRMaterialLoadingAdapter implements BABYLON.GLTF2.IMaterialLoadingAdapter {
8545
8611
  private _material;
8612
+ private _specWorkflow;
8546
8613
  /**
8547
8614
  * Creates a new instance of the PBRMaterialLoadingAdapter.
8548
8615
  * @param material - The PBR material to adapt.
@@ -8684,6 +8751,10 @@ declare namespace BABYLON.GLTF2 {
8684
8751
  * @param enableEdgeColor Whether to enable OpenPBR BRDF models for edge color support
8685
8752
  */
8686
8753
  enableSpecularEdgeColor(enableEdgeColor?: boolean): void;
8754
+ /**
8755
+ * Enable the specular/glossiness workflow and disable metallic/roughness.
8756
+ */
8757
+ configureSpecularGlossiness(): void;
8687
8758
  /**
8688
8759
  * Sets the specular weight (mapped to PBR metallicF0Factor).
8689
8760
  * @param value The specular weight value
@@ -8757,6 +8828,16 @@ declare namespace BABYLON.GLTF2 {
8757
8828
  * @returns The IOR value
8758
8829
  */
8759
8830
  get specularIor(): number;
8831
+ /**
8832
+ * Sets/gets the glossiness (inverted roughness)
8833
+ * ONLY used for specular/glossiness workflow; has no effect when metallic/roughness workflow is active
8834
+ */
8835
+ get glossiness(): number;
8836
+ /**
8837
+ * Sets/gets the glossiness (inverted roughness)
8838
+ * ONLY used for specular/glossiness workflow; has no effect when metallic/roughness workflow is active
8839
+ */
8840
+ set glossiness(value: number);
8760
8841
  /**
8761
8842
  * Sets the emission color (mapped to PBR emissiveColor).
8762
8843
  * @param value The emission color as a Color3
@@ -8990,6 +9071,9 @@ declare namespace BABYLON.GLTF2 {
8990
9071
  * Sets up the material for proper thin-surface transmission behavior.
8991
9072
  */
8992
9073
  configureTransmission(): void;
9074
+ /**
9075
+ * Configures volume properties for PBR material. Nothing to do for PBRMaterial.
9076
+ */
8993
9077
  configureVolume(): void;
8994
9078
  /**
8995
9079
  * Sets whether the material is thin-walled (i.e. non-volumetric) or not.
@@ -9255,6 +9339,7 @@ declare namespace BABYLON.GLTF2 {
9255
9339
  */
9256
9340
  export class OpenPBRMaterialLoadingAdapter implements BABYLON.GLTF2.IMaterialLoadingAdapter {
9257
9341
  private _material;
9342
+ private _specWorkflow;
9258
9343
  /**
9259
9344
  * Creates a new instance of the OpenPBRMaterialLoadingAdapter.
9260
9345
  * @param material - The OpenPBR material to adapt.
@@ -9397,6 +9482,7 @@ declare namespace BABYLON.GLTF2 {
9397
9482
  * @param _enableEdgeColor Whether to enable edge color support (ignored for OpenPBR)
9398
9483
  */
9399
9484
  enableSpecularEdgeColor(_enableEdgeColor?: boolean): void;
9485
+ configureSpecularGlossiness(): void;
9400
9486
  /**
9401
9487
  * Sets the specular weight of the OpenPBR material.
9402
9488
  * @param value The specular weight value (0-1)
@@ -9469,6 +9555,11 @@ declare namespace BABYLON.GLTF2 {
9469
9555
  * @returns The IOR value
9470
9556
  */
9471
9557
  get specularIor(): number;
9558
+ /**
9559
+ * Sets the glossiness (inverted roughness) of the OpenPBR material.
9560
+ */
9561
+ set glossiness(value: number);
9562
+ get glossiness(): number;
9472
9563
  /**
9473
9564
  * Sets the emission color of the OpenPBR material.
9474
9565
  * @param value The emission color as a Color3
@@ -9549,6 +9640,10 @@ declare namespace BABYLON.GLTF2 {
9549
9640
  * @param value The coat color as a Color3
9550
9641
  */
9551
9642
  set coatColor(value: Color3);
9643
+ /**
9644
+ * Gets the coat color of the OpenPBR material.
9645
+ */
9646
+ get coatColor(): Color3;
9552
9647
  /**
9553
9648
  * Sets the coat color texture of the OpenPBR material.
9554
9649
  * @param value The coat color texture or null
@@ -9578,11 +9673,13 @@ declare namespace BABYLON.GLTF2 {
9578
9673
  * Sets the coat index of refraction (IOR) of the OpenPBR material.
9579
9674
  */
9580
9675
  set coatIor(value: number);
9676
+ get coatIor(): number;
9581
9677
  /**
9582
9678
  * Sets the coat darkening value of the OpenPBR material.
9583
9679
  * @param value The coat darkening value
9584
9680
  */
9585
9681
  set coatDarkening(value: number);
9682
+ get coatDarkening(): number;
9586
9683
  /**
9587
9684
  * Sets the coat darkening texture (OpenPBR: coatDarkeningTexture, no PBR equivalent)
9588
9685
  */
@@ -9631,6 +9728,7 @@ declare namespace BABYLON.GLTF2 {
9631
9728
  * @param value The transmission weight texture or null
9632
9729
  */
9633
9730
  set transmissionWeightTexture(value: Nullable<BaseTexture>);
9731
+ get transmissionWeightTexture(): Nullable<BaseTexture>;
9634
9732
  /**
9635
9733
  * Gets the transmission weight.
9636
9734
  * @returns Currently returns 0 as transmission is not yet available
@@ -9699,6 +9797,9 @@ declare namespace BABYLON.GLTF2 {
9699
9797
  * @param value The refraction background texture or null
9700
9798
  */
9701
9799
  set refractionBackgroundTexture(value: Nullable<BaseTexture>);
9800
+ /**
9801
+ * Configures volume properties for OpenPBR material.
9802
+ */
9702
9803
  configureVolume(): void;
9703
9804
  /**
9704
9805
  * Sets whether the material is thin-walled (i.e. non-volumetric) or not.
@@ -9731,6 +9832,7 @@ declare namespace BABYLON.GLTF2 {
9731
9832
  * Sets the subsurface weight texture
9732
9833
  */
9733
9834
  set subsurfaceWeightTexture(value: Nullable<BaseTexture>);
9835
+ get subsurfaceWeightTexture(): Nullable<BaseTexture>;
9734
9836
  /**
9735
9837
  * Sets the subsurface color.
9736
9838
  * @param value The subsurface tint color as a Color3
@@ -9930,7 +10032,13 @@ declare namespace BABYLON.GLTF2 {
9930
10032
  * @param value The scale value for the coat normal texture
9931
10033
  */
9932
10034
  set geometryCoatNormalTextureScale(value: number);
9933
- finalize(): void;
10035
+ /**
10036
+ * 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.
10039
+ */
10040
+ finalizeAsync(signal: AbortSignal): Promise<void>;
10041
+ private copySurfaceToCoatAsync;
9934
10042
  }
9935
10043
 
9936
10044
 
@@ -9950,10 +10058,20 @@ declare namespace BABYLON.GLTF2 {
9950
10058
  * Gets the underlying material
9951
10059
  */
9952
10060
  readonly material: Material;
10061
+ /** @deprecated Use finalizeAsync instead. */
10062
+ finalize?(): void;
9953
10063
  /**
9954
- * Finalizes material properties after loading is complete.
10064
+ * 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.
10068
+ *
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.
9955
10073
  */
9956
- finalize?(): void;
10074
+ finalizeAsync?(signal: AbortSignal): Promise<void> | void;
9957
10075
  /**
9958
10076
  * Whether the material should be treated as unlit
9959
10077
  */
@@ -10015,6 +10133,10 @@ declare namespace BABYLON.GLTF2 {
10015
10133
  * @param enableEdgeColor - Whether to enable edge color support
10016
10134
  */
10017
10135
  enableSpecularEdgeColor(enableEdgeColor?: boolean): void;
10136
+ /**
10137
+ * Enable the specular/glossiness workflow and disable metallic/roughness.
10138
+ */
10139
+ configureSpecularGlossiness(): void;
10018
10140
  /**
10019
10141
  * Sets/gets the specular weight
10020
10142
  */
@@ -10043,6 +10165,11 @@ declare namespace BABYLON.GLTF2 {
10043
10165
  * Sets/gets the specular IOR
10044
10166
  */
10045
10167
  specularIor: number;
10168
+ /**
10169
+ * Sets/gets the glossiness (inverted roughness)
10170
+ * ONLY used for specular/glossiness workflow; has no effect when metallic/roughness workflow is active
10171
+ */
10172
+ glossiness: number;
10046
10173
  /**
10047
10174
  * Sets/gets the emissive color
10048
10175
  */
@@ -10159,6 +10286,9 @@ declare namespace BABYLON.GLTF2 {
10159
10286
  * Configures transmission for thin-surface transmission (KHR_materials_transmission)
10160
10287
  */
10161
10288
  configureTransmission(): void;
10289
+ /**
10290
+ * Configures volume properties for volumetric transmission (KHR_materials_volume)
10291
+ */
10162
10292
  configureVolume(): void;
10163
10293
  /**
10164
10294
  * Sets whether the material is thin-walled (i.e. non-volumetric) or not.
@@ -10876,6 +11006,8 @@ declare namespace BABYLON.GLTF2 {
10876
11006
  export class GLTFLoader implements IGLTFLoader {
10877
11007
  /** @internal */
10878
11008
  readonly _completePromises: Promise<unknown>[];
11009
+ /** AbortController used to cancel in-flight finalizeAsync() calls when dispose() is called. */
11010
+ private _finalizeController;
10879
11011
  /** @internal */
10880
11012
  _assetContainer: Nullable<AssetContainer>;
10881
11013
  /** Storage */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babylonjs-loaders",
3
- "version": "9.6.2",
3
+ "version": "9.7.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.7.0",
20
+ "babylonjs-gltf2interface": "9.7.0"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@dev/build-tools": "1.0.0",