@babylonjs/loaders 9.7.0 → 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.
@@ -2,6 +2,7 @@ import { type Material } from "@babylonjs/core/Materials/material.js";
2
2
  import { type BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
3
3
  import { type Nullable } from "@babylonjs/core/types.js";
4
4
  import { type Color3 } from "@babylonjs/core/Maths/math.color.js";
5
+ import { type GLTFLoader } from "./glTFLoader.js";
5
6
  /**
6
7
  * Interface for material loading adapters that provides a unified OpenPBR-like interface
7
8
  * for both OpenPBR and PBR materials, eliminating conditional branches in extensions.
@@ -11,20 +12,17 @@ export interface IMaterialLoadingAdapter {
11
12
  * Gets the underlying material
12
13
  */
13
14
  readonly material: Material;
14
- /** @deprecated Use finalizeAsync instead. */
15
- finalize?(): void;
16
15
  /**
17
16
  * Finalizes material properties after all loading is complete.
18
- * May return a Promise for async work (e.g. GPU texture processing). Any returned
19
- * Promise is tracked by the loader and awaited before the COMPLETE state is reached,
20
- * so callers can rely on onCompleteObservable for fully processed materials.
17
+ * May do async work (e.g. GPU texture processing); the returned Promise is tracked
18
+ * by the loader and awaited before the COMPLETE state is reached, so callers can rely
19
+ * on onCompleteObservable for fully processed materials.
21
20
  *
22
- * The loader passes an AbortSignal that is aborted when the loader is disposed.
23
- * Implementations should check `signal.aborted` after each await point and, if
24
- * aborted, release any intermediate resources and return early.
25
- * @param signal An AbortSignal that fires when the loader is disposed mid-flight.
21
+ * Implementations should check `loader._disposed` between awaits to bail out early
22
+ * when the loader is disposed mid-flight.
23
+ * @param loader The glTF loader driving the finalize step.
26
24
  */
27
- finalizeAsync?(signal: AbortSignal): Promise<void> | void;
25
+ finalizeAsync(loader: GLTFLoader): Promise<void>;
28
26
  /**
29
27
  * Whether the material should be treated as unlit
30
28
  */
@@ -1 +1 @@
1
- {"version":3,"file":"materialLoadingAdapter.js","sourceRoot":"","sources":["../../../../../dev/loaders/src/glTF/2.0/materialLoadingAdapter.ts"],"names":[],"mappings":"","sourcesContent":["import { type Material } from \"core/Materials/material\";\r\nimport { type BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { type Nullable } from \"core/types\";\r\nimport { type Color3 } from \"core/Maths/math.color\";\r\n\r\n/**\r\n * Interface for material loading adapters that provides a unified OpenPBR-like interface\r\n * for both OpenPBR and PBR materials, eliminating conditional branches in extensions.\r\n */\r\nexport interface IMaterialLoadingAdapter {\r\n /**\r\n * Gets the underlying material\r\n */\r\n readonly material: Material;\r\n\r\n /** @deprecated Use finalizeAsync instead. */\r\n finalize?(): void;\r\n\r\n /**\r\n * Finalizes material properties after all loading is complete.\r\n * May return a Promise for async work (e.g. GPU texture processing). Any returned\r\n * Promise is tracked by the loader and awaited before the COMPLETE state is reached,\r\n * so callers can rely on onCompleteObservable for fully processed materials.\r\n *\r\n * The loader passes an AbortSignal that is aborted when the loader is disposed.\r\n * Implementations should check `signal.aborted` after each await point and, if\r\n * aborted, release any intermediate resources and return early.\r\n * @param signal An AbortSignal that fires when the loader is disposed mid-flight.\r\n */\r\n finalizeAsync?(signal: AbortSignal): Promise<void> | void;\r\n\r\n /**\r\n * Whether the material should be treated as unlit\r\n */\r\n isUnlit: boolean;\r\n\r\n // ========================================\r\n // CULLING PROPERTIES\r\n // ========================================\r\n\r\n /**\r\n * Sets/gets the back face culling\r\n */\r\n backFaceCulling: boolean;\r\n\r\n /**\r\n * Sets/gets the two sided lighting\r\n */\r\n twoSidedLighting: boolean;\r\n\r\n // ========================================\r\n // ALPHA PROPERTIES\r\n // ========================================\r\n\r\n /**\r\n * Sets/gets the alpha cutoff value (used for alpha test mode)\r\n */\r\n alphaCutOff: number;\r\n\r\n /**\r\n * Sets/gets whether to use alpha from albedo/base color texture\r\n */\r\n useAlphaFromBaseColorTexture: boolean;\r\n\r\n /**\r\n * Sets/Gets whether the transparency is treated as alpha coverage\r\n */\r\n transparencyAsAlphaCoverage: boolean;\r\n\r\n // ========================================\r\n // BASE PARAMETERS\r\n // ========================================\r\n\r\n /**\r\n * Sets/gets the base color\r\n */\r\n baseColor: Color3;\r\n\r\n /**\r\n * Sets/gets the base color texture\r\n */\r\n baseColorTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the base diffuse roughness\r\n */\r\n baseDiffuseRoughness: number;\r\n\r\n /**\r\n * Sets/gets the base diffuse roughness texture\r\n */\r\n baseDiffuseRoughnessTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the base metalness\r\n */\r\n baseMetalness: number;\r\n\r\n /**\r\n * Sets/gets the base metalness texture\r\n */\r\n baseMetalnessTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets whether to use roughness from metallic texture green channel\r\n */\r\n useRoughnessFromMetallicTextureGreen: boolean;\r\n\r\n /**\r\n * Sets whether to use metallic from metallic texture blue channel\r\n */\r\n useMetallicFromMetallicTextureBlue: boolean;\r\n\r\n // ========================================\r\n // SPECULAR PARAMETERS\r\n // ========================================\r\n\r\n /**\r\n * Configures specular properties and enables OpenPBR BRDF model for edge color support\r\n * @param enableEdgeColor - Whether to enable edge color support\r\n */\r\n enableSpecularEdgeColor(enableEdgeColor?: boolean): void;\r\n\r\n /**\r\n * Enable the specular/glossiness workflow and disable metallic/roughness.\r\n */\r\n configureSpecularGlossiness(): void;\r\n\r\n /**\r\n * Sets/gets the specular weight\r\n */\r\n specularWeight: number;\r\n\r\n /**\r\n * Sets/gets the specular weight texture\r\n */\r\n specularWeightTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the specular color\r\n */\r\n specularColor: Color3;\r\n\r\n /**\r\n * Sets/gets the specular color texture\r\n */\r\n specularColorTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the specular roughness\r\n */\r\n specularRoughness: number;\r\n\r\n /**\r\n * Sets/gets the specular roughness texture\r\n */\r\n specularRoughnessTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the specular IOR\r\n */\r\n specularIor: number;\r\n\r\n /**\r\n * Sets/gets the glossiness (inverted roughness)\r\n * ONLY used for specular/glossiness workflow; has no effect when metallic/roughness workflow is active\r\n */\r\n glossiness: number;\r\n\r\n // ========================================\r\n // EMISSION PARAMETERS\r\n // ========================================\r\n\r\n /**\r\n * Sets/gets the emissive color\r\n */\r\n emissionColor: Color3;\r\n\r\n /**\r\n * Sets/gets the emissive luminance\r\n */\r\n emissionLuminance: number;\r\n\r\n /**\r\n * Sets/gets the emissive texture\r\n */\r\n emissionColorTexture: Nullable<BaseTexture>;\r\n\r\n // ========================================\r\n // AMBIENT OCCLUSION\r\n // ========================================\r\n\r\n /**\r\n * Sets/gets the ambient occlusion texture\r\n */\r\n ambientOcclusionTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the ambient occlusion texture strength/level\r\n */\r\n ambientOcclusionTextureStrength: number;\r\n\r\n // ========================================\r\n // COAT PARAMETERS\r\n // ========================================\r\n\r\n /**\r\n * Configures clear coat for PBR material\r\n */\r\n configureCoat(): void;\r\n\r\n /**\r\n * Sets/gets the coat weight\r\n */\r\n coatWeight: number;\r\n\r\n /**\r\n * Sets/gets the coat weight texture\r\n */\r\n coatWeightTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets the coat color\r\n */\r\n coatColor: Color3;\r\n\r\n /**\r\n * Sets the coat color texture\r\n */\r\n coatColorTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the coat roughness\r\n */\r\n coatRoughness: number;\r\n\r\n /**\r\n * Sets/gets the coat roughness texture\r\n */\r\n coatRoughnessTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets the coat index of refraction (IOR)\r\n */\r\n coatIor: number;\r\n\r\n /**\r\n * Sets the coat darkening\r\n */\r\n coatDarkening: number;\r\n\r\n /**\r\n * Sets the coat darkening texture\r\n */\r\n coatDarkeningTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the coat roughness anisotropy\r\n */\r\n coatRoughnessAnisotropy: number;\r\n\r\n /**\r\n * Sets the coat tangent angle for anisotropy\r\n */\r\n geometryCoatTangentAngle: number;\r\n\r\n /**\r\n * Sets the coat tangent texture for anisotropy\r\n */\r\n geometryCoatTangentTexture: Nullable<BaseTexture>;\r\n\r\n // ========================================\r\n // TRANSMISSION LAYER\r\n // ========================================\r\n\r\n /**\r\n * Sets the transmission weight\r\n */\r\n transmissionWeight: number;\r\n\r\n /**\r\n * Sets the transmission weight texture\r\n */\r\n transmissionWeightTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets the attenuation distance\r\n */\r\n transmissionDepth: number;\r\n\r\n /**\r\n * Sets the attenuation color\r\n */\r\n transmissionColor: Color3;\r\n\r\n /**\r\n * Sets the scattering coefficient\r\n */\r\n transmissionScatter: Color3;\r\n\r\n /**\r\n * Sets the transmission scatter texture\r\n */\r\n transmissionScatterTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets the scattering anisotropy (-1 to 1)\r\n */\r\n transmissionScatterAnisotropy: number;\r\n\r\n /**\r\n * Sets the dispersion Abbe number\r\n */\r\n transmissionDispersionAbbeNumber: number;\r\n\r\n /**\r\n * Sets the dispersion scale\r\n */\r\n transmissionDispersionScale: number;\r\n\r\n /**\r\n * The refraction background texture\r\n */\r\n refractionBackgroundTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Configures transmission for thin-surface transmission (KHR_materials_transmission)\r\n */\r\n configureTransmission(): void;\r\n\r\n // ========================================\r\n // VOLUME PROPERTIES\r\n // ========================================\r\n\r\n /**\r\n * Configures volume properties for volumetric transmission (KHR_materials_volume)\r\n */\r\n configureVolume(): void;\r\n\r\n /**\r\n * Sets whether the material is thin-walled (i.e. non-volumetric) or not.\r\n */\r\n geometryThinWalled: boolean;\r\n\r\n /**\r\n * Sets the thickness texture\r\n */\r\n volumeThicknessTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets the thickness factor\r\n */\r\n volumeThickness: number;\r\n\r\n // ========================================\r\n // SUBSURFACE PROPERTIES (Subsurface Scattering)\r\n // ========================================\r\n\r\n /**\r\n * Configures subsurface properties\r\n */\r\n configureSubsurface(): void;\r\n\r\n /**\r\n * Sets/gets the subsurface weight\r\n */\r\n subsurfaceWeight: number;\r\n\r\n /**\r\n * Sets/gets the subsurface weight texture\r\n */\r\n subsurfaceWeightTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the subsurface color\r\n */\r\n subsurfaceColor: Color3;\r\n\r\n /**\r\n * Sets/gets the subsurface color texture\r\n */\r\n subsurfaceColorTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the diffuse transmission tint of the material\r\n */\r\n diffuseTransmissionTint: Color3;\r\n\r\n /**\r\n * Sets/gets the diffuse transmission tint texture of the material\r\n */\r\n diffuseTransmissionTintTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the subsurface radius (used for subsurface scattering)\r\n */\r\n subsurfaceRadius: number;\r\n\r\n /**\r\n * Sets/gets the subsurface radius scale (used for subsurface scattering)\r\n */\r\n subsurfaceRadiusScale: Color3;\r\n\r\n /**\r\n * Sets/gets the subsurface scattering anisotropy\r\n */\r\n subsurfaceScatterAnisotropy: number;\r\n\r\n /**\r\n * Does this material have a translucent surface (i.e. either transmission or subsurface)?\r\n */\r\n isTranslucent(): boolean;\r\n\r\n // ========================================\r\n // FUZZ LAYER (Sheen)\r\n // ========================================\r\n\r\n /**\r\n * Configures initial settings for fuzz for material.\r\n */\r\n configureFuzz(): void;\r\n\r\n /**\r\n * Sets the fuzz weight\r\n */\r\n fuzzWeight: number;\r\n\r\n /**\r\n * Sets the fuzz weight texture\r\n */\r\n fuzzWeightTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets the fuzz color\r\n */\r\n fuzzColor: Color3;\r\n\r\n /**\r\n * Sets the fuzz color texture\r\n */\r\n fuzzColorTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets the fuzz roughness\r\n */\r\n fuzzRoughness: number;\r\n\r\n /**\r\n * Sets the fuzz roughness texture\r\n */\r\n fuzzRoughnessTexture: Nullable<BaseTexture>;\r\n\r\n // ========================================\r\n // ANISOTROPY\r\n // ========================================\r\n\r\n /**\r\n * Sets/gets the specular roughness anisotropy\r\n */\r\n specularRoughnessAnisotropy: number;\r\n\r\n /**\r\n * Sets the anisotropy rotation\r\n */\r\n geometryTangentAngle: number;\r\n\r\n /**\r\n * Sets/gets the anisotropy texture\r\n */\r\n geometryTangentTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Configures glTF-style anisotropy for OpenPBR materials\r\n * @param useGltfStyle - Whether to use glTF-style anisotropy (default: true)\r\n */\r\n configureGltfStyleAnisotropy(useGltfStyle?: boolean): void;\r\n\r\n // ========================================\r\n // THIN FILM IRIDESCENCE\r\n // ========================================\r\n\r\n /**\r\n * Sets the thin film weight\r\n */\r\n thinFilmWeight: number;\r\n\r\n /**\r\n * Sets the thin film IOR\r\n */\r\n thinFilmIor: number;\r\n\r\n /**\r\n * Sets the thin film thickness minimum\r\n */\r\n thinFilmThicknessMinimum: number;\r\n\r\n /**\r\n * Sets the thin film thickness maximum\r\n */\r\n thinFilmThicknessMaximum: number;\r\n\r\n /**\r\n * Sets the thin film iridescence texture\r\n */\r\n thinFilmWeightTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets the thin film thickness texture\r\n */\r\n thinFilmThicknessTexture: Nullable<BaseTexture>;\r\n\r\n // ========================================\r\n // UNLIT MATERIALS\r\n // ========================================\r\n\r\n /**\r\n * Sets the unlit flag\r\n */\r\n unlit: boolean;\r\n\r\n // ========================================\r\n // GEOMETRY PARAMETERS\r\n // ========================================\r\n\r\n /**\r\n * Sets/gets the geometry opacity\r\n */\r\n geometryOpacity: number;\r\n\r\n /**\r\n * Sets/gets the geometry normal texture\r\n */\r\n geometryNormalTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets the normal map inversions for PBR material only\r\n * @param invertX - Whether to invert the normal map on the X axis\r\n * @param invertY - Whether to invert the normal map on the Y axis\r\n */\r\n setNormalMapInversions(invertX: boolean, invertY: boolean): void;\r\n\r\n /**\r\n * Sets/gets the coat normal texture\r\n */\r\n geometryCoatNormalTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets the coat normal texture scale\r\n */\r\n geometryCoatNormalTextureScale: number;\r\n}\r\n"]}
1
+ {"version":3,"file":"materialLoadingAdapter.js","sourceRoot":"","sources":["../../../../../dev/loaders/src/glTF/2.0/materialLoadingAdapter.ts"],"names":[],"mappings":"","sourcesContent":["import { type Material } from \"core/Materials/material\";\r\nimport { type BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { type Nullable } from \"core/types\";\r\nimport { type Color3 } from \"core/Maths/math.color\";\r\nimport { type GLTFLoader } from \"./glTFLoader\";\r\n\r\n/**\r\n * Interface for material loading adapters that provides a unified OpenPBR-like interface\r\n * for both OpenPBR and PBR materials, eliminating conditional branches in extensions.\r\n */\r\nexport interface IMaterialLoadingAdapter {\r\n /**\r\n * Gets the underlying material\r\n */\r\n readonly material: Material;\r\n\r\n /**\r\n * Finalizes material properties after all loading is complete.\r\n * May do async work (e.g. GPU texture processing); the returned Promise is tracked\r\n * by the loader and awaited before the COMPLETE state is reached, so callers can rely\r\n * on onCompleteObservable for fully processed materials.\r\n *\r\n * Implementations should check `loader._disposed` between awaits to bail out early\r\n * when the loader is disposed mid-flight.\r\n * @param loader The glTF loader driving the finalize step.\r\n */\r\n finalizeAsync(loader: GLTFLoader): Promise<void>;\r\n\r\n /**\r\n * Whether the material should be treated as unlit\r\n */\r\n isUnlit: boolean;\r\n\r\n // ========================================\r\n // CULLING PROPERTIES\r\n // ========================================\r\n\r\n /**\r\n * Sets/gets the back face culling\r\n */\r\n backFaceCulling: boolean;\r\n\r\n /**\r\n * Sets/gets the two sided lighting\r\n */\r\n twoSidedLighting: boolean;\r\n\r\n // ========================================\r\n // ALPHA PROPERTIES\r\n // ========================================\r\n\r\n /**\r\n * Sets/gets the alpha cutoff value (used for alpha test mode)\r\n */\r\n alphaCutOff: number;\r\n\r\n /**\r\n * Sets/gets whether to use alpha from albedo/base color texture\r\n */\r\n useAlphaFromBaseColorTexture: boolean;\r\n\r\n /**\r\n * Sets/Gets whether the transparency is treated as alpha coverage\r\n */\r\n transparencyAsAlphaCoverage: boolean;\r\n\r\n // ========================================\r\n // BASE PARAMETERS\r\n // ========================================\r\n\r\n /**\r\n * Sets/gets the base color\r\n */\r\n baseColor: Color3;\r\n\r\n /**\r\n * Sets/gets the base color texture\r\n */\r\n baseColorTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the base diffuse roughness\r\n */\r\n baseDiffuseRoughness: number;\r\n\r\n /**\r\n * Sets/gets the base diffuse roughness texture\r\n */\r\n baseDiffuseRoughnessTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the base metalness\r\n */\r\n baseMetalness: number;\r\n\r\n /**\r\n * Sets/gets the base metalness texture\r\n */\r\n baseMetalnessTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets whether to use roughness from metallic texture green channel\r\n */\r\n useRoughnessFromMetallicTextureGreen: boolean;\r\n\r\n /**\r\n * Sets whether to use metallic from metallic texture blue channel\r\n */\r\n useMetallicFromMetallicTextureBlue: boolean;\r\n\r\n // ========================================\r\n // SPECULAR PARAMETERS\r\n // ========================================\r\n\r\n /**\r\n * Configures specular properties and enables OpenPBR BRDF model for edge color support\r\n * @param enableEdgeColor - Whether to enable edge color support\r\n */\r\n enableSpecularEdgeColor(enableEdgeColor?: boolean): void;\r\n\r\n /**\r\n * Enable the specular/glossiness workflow and disable metallic/roughness.\r\n */\r\n configureSpecularGlossiness(): void;\r\n\r\n /**\r\n * Sets/gets the specular weight\r\n */\r\n specularWeight: number;\r\n\r\n /**\r\n * Sets/gets the specular weight texture\r\n */\r\n specularWeightTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the specular color\r\n */\r\n specularColor: Color3;\r\n\r\n /**\r\n * Sets/gets the specular color texture\r\n */\r\n specularColorTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the specular roughness\r\n */\r\n specularRoughness: number;\r\n\r\n /**\r\n * Sets/gets the specular roughness texture\r\n */\r\n specularRoughnessTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the specular IOR\r\n */\r\n specularIor: number;\r\n\r\n /**\r\n * Sets/gets the glossiness (inverted roughness)\r\n * ONLY used for specular/glossiness workflow; has no effect when metallic/roughness workflow is active\r\n */\r\n glossiness: number;\r\n\r\n // ========================================\r\n // EMISSION PARAMETERS\r\n // ========================================\r\n\r\n /**\r\n * Sets/gets the emissive color\r\n */\r\n emissionColor: Color3;\r\n\r\n /**\r\n * Sets/gets the emissive luminance\r\n */\r\n emissionLuminance: number;\r\n\r\n /**\r\n * Sets/gets the emissive texture\r\n */\r\n emissionColorTexture: Nullable<BaseTexture>;\r\n\r\n // ========================================\r\n // AMBIENT OCCLUSION\r\n // ========================================\r\n\r\n /**\r\n * Sets/gets the ambient occlusion texture\r\n */\r\n ambientOcclusionTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the ambient occlusion texture strength/level\r\n */\r\n ambientOcclusionTextureStrength: number;\r\n\r\n // ========================================\r\n // COAT PARAMETERS\r\n // ========================================\r\n\r\n /**\r\n * Configures clear coat for PBR material\r\n */\r\n configureCoat(): void;\r\n\r\n /**\r\n * Sets/gets the coat weight\r\n */\r\n coatWeight: number;\r\n\r\n /**\r\n * Sets/gets the coat weight texture\r\n */\r\n coatWeightTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets the coat color\r\n */\r\n coatColor: Color3;\r\n\r\n /**\r\n * Sets the coat color texture\r\n */\r\n coatColorTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the coat roughness\r\n */\r\n coatRoughness: number;\r\n\r\n /**\r\n * Sets/gets the coat roughness texture\r\n */\r\n coatRoughnessTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets the coat index of refraction (IOR)\r\n */\r\n coatIor: number;\r\n\r\n /**\r\n * Sets the coat darkening\r\n */\r\n coatDarkening: number;\r\n\r\n /**\r\n * Sets the coat darkening texture\r\n */\r\n coatDarkeningTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the coat roughness anisotropy\r\n */\r\n coatRoughnessAnisotropy: number;\r\n\r\n /**\r\n * Sets the coat tangent angle for anisotropy\r\n */\r\n geometryCoatTangentAngle: number;\r\n\r\n /**\r\n * Sets the coat tangent texture for anisotropy\r\n */\r\n geometryCoatTangentTexture: Nullable<BaseTexture>;\r\n\r\n // ========================================\r\n // TRANSMISSION LAYER\r\n // ========================================\r\n\r\n /**\r\n * Sets the transmission weight\r\n */\r\n transmissionWeight: number;\r\n\r\n /**\r\n * Sets the transmission weight texture\r\n */\r\n transmissionWeightTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets the attenuation distance\r\n */\r\n transmissionDepth: number;\r\n\r\n /**\r\n * Sets the attenuation color\r\n */\r\n transmissionColor: Color3;\r\n\r\n /**\r\n * Sets the scattering coefficient\r\n */\r\n transmissionScatter: Color3;\r\n\r\n /**\r\n * Sets the transmission scatter texture\r\n */\r\n transmissionScatterTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets the scattering anisotropy (-1 to 1)\r\n */\r\n transmissionScatterAnisotropy: number;\r\n\r\n /**\r\n * Sets the dispersion Abbe number\r\n */\r\n transmissionDispersionAbbeNumber: number;\r\n\r\n /**\r\n * Sets the dispersion scale\r\n */\r\n transmissionDispersionScale: number;\r\n\r\n /**\r\n * The refraction background texture\r\n */\r\n refractionBackgroundTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Configures transmission for thin-surface transmission (KHR_materials_transmission)\r\n */\r\n configureTransmission(): void;\r\n\r\n // ========================================\r\n // VOLUME PROPERTIES\r\n // ========================================\r\n\r\n /**\r\n * Configures volume properties for volumetric transmission (KHR_materials_volume)\r\n */\r\n configureVolume(): void;\r\n\r\n /**\r\n * Sets whether the material is thin-walled (i.e. non-volumetric) or not.\r\n */\r\n geometryThinWalled: boolean;\r\n\r\n /**\r\n * Sets the thickness texture\r\n */\r\n volumeThicknessTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets the thickness factor\r\n */\r\n volumeThickness: number;\r\n\r\n // ========================================\r\n // SUBSURFACE PROPERTIES (Subsurface Scattering)\r\n // ========================================\r\n\r\n /**\r\n * Configures subsurface properties\r\n */\r\n configureSubsurface(): void;\r\n\r\n /**\r\n * Sets/gets the subsurface weight\r\n */\r\n subsurfaceWeight: number;\r\n\r\n /**\r\n * Sets/gets the subsurface weight texture\r\n */\r\n subsurfaceWeightTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the subsurface color\r\n */\r\n subsurfaceColor: Color3;\r\n\r\n /**\r\n * Sets/gets the subsurface color texture\r\n */\r\n subsurfaceColorTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the diffuse transmission tint of the material\r\n */\r\n diffuseTransmissionTint: Color3;\r\n\r\n /**\r\n * Sets/gets the diffuse transmission tint texture of the material\r\n */\r\n diffuseTransmissionTintTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets/gets the subsurface radius (used for subsurface scattering)\r\n */\r\n subsurfaceRadius: number;\r\n\r\n /**\r\n * Sets/gets the subsurface radius scale (used for subsurface scattering)\r\n */\r\n subsurfaceRadiusScale: Color3;\r\n\r\n /**\r\n * Sets/gets the subsurface scattering anisotropy\r\n */\r\n subsurfaceScatterAnisotropy: number;\r\n\r\n /**\r\n * Does this material have a translucent surface (i.e. either transmission or subsurface)?\r\n */\r\n isTranslucent(): boolean;\r\n\r\n // ========================================\r\n // FUZZ LAYER (Sheen)\r\n // ========================================\r\n\r\n /**\r\n * Configures initial settings for fuzz for material.\r\n */\r\n configureFuzz(): void;\r\n\r\n /**\r\n * Sets the fuzz weight\r\n */\r\n fuzzWeight: number;\r\n\r\n /**\r\n * Sets the fuzz weight texture\r\n */\r\n fuzzWeightTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets the fuzz color\r\n */\r\n fuzzColor: Color3;\r\n\r\n /**\r\n * Sets the fuzz color texture\r\n */\r\n fuzzColorTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets the fuzz roughness\r\n */\r\n fuzzRoughness: number;\r\n\r\n /**\r\n * Sets the fuzz roughness texture\r\n */\r\n fuzzRoughnessTexture: Nullable<BaseTexture>;\r\n\r\n // ========================================\r\n // ANISOTROPY\r\n // ========================================\r\n\r\n /**\r\n * Sets/gets the specular roughness anisotropy\r\n */\r\n specularRoughnessAnisotropy: number;\r\n\r\n /**\r\n * Sets the anisotropy rotation\r\n */\r\n geometryTangentAngle: number;\r\n\r\n /**\r\n * Sets/gets the anisotropy texture\r\n */\r\n geometryTangentTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Configures glTF-style anisotropy for OpenPBR materials\r\n * @param useGltfStyle - Whether to use glTF-style anisotropy (default: true)\r\n */\r\n configureGltfStyleAnisotropy(useGltfStyle?: boolean): void;\r\n\r\n // ========================================\r\n // THIN FILM IRIDESCENCE\r\n // ========================================\r\n\r\n /**\r\n * Sets the thin film weight\r\n */\r\n thinFilmWeight: number;\r\n\r\n /**\r\n * Sets the thin film IOR\r\n */\r\n thinFilmIor: number;\r\n\r\n /**\r\n * Sets the thin film thickness minimum\r\n */\r\n thinFilmThicknessMinimum: number;\r\n\r\n /**\r\n * Sets the thin film thickness maximum\r\n */\r\n thinFilmThicknessMaximum: number;\r\n\r\n /**\r\n * Sets the thin film iridescence texture\r\n */\r\n thinFilmWeightTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets the thin film thickness texture\r\n */\r\n thinFilmThicknessTexture: Nullable<BaseTexture>;\r\n\r\n // ========================================\r\n // UNLIT MATERIALS\r\n // ========================================\r\n\r\n /**\r\n * Sets the unlit flag\r\n */\r\n unlit: boolean;\r\n\r\n // ========================================\r\n // GEOMETRY PARAMETERS\r\n // ========================================\r\n\r\n /**\r\n * Sets/gets the geometry opacity\r\n */\r\n geometryOpacity: number;\r\n\r\n /**\r\n * Sets/gets the geometry normal texture\r\n */\r\n geometryNormalTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets the normal map inversions for PBR material only\r\n * @param invertX - Whether to invert the normal map on the X axis\r\n * @param invertY - Whether to invert the normal map on the Y axis\r\n */\r\n setNormalMapInversions(invertX: boolean, invertY: boolean): void;\r\n\r\n /**\r\n * Sets/gets the coat normal texture\r\n */\r\n geometryCoatNormalTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Sets the coat normal texture scale\r\n */\r\n geometryCoatNormalTextureScale: number;\r\n}\r\n"]}
@@ -4,6 +4,7 @@ import { type BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture
4
4
  import { type Nullable } from "@babylonjs/core/types.js";
5
5
  import { Color3 } from "@babylonjs/core/Maths/math.color.js";
6
6
  import { type IMaterialLoadingAdapter } from "./materialLoadingAdapter.js";
7
+ import { type GLTFLoader } from "./glTFLoader.js";
7
8
  /**
8
9
  * Material Loading Adapter for OpenPBR materials that provides a unified OpenPBR-like interface.
9
10
  */
@@ -704,9 +705,8 @@ export declare class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAd
704
705
  set geometryCoatNormalTextureScale(value: number);
705
706
  /**
706
707
  * Finalizes material properties after all loading is complete.
707
- * @param signal An AbortSignal that fires when the loader is disposed. Intermediate
708
- * textures are disposed and the method returns early when aborted.
708
+ * @param loader The glTF loader; `loader._disposed` is polled between texture passes to bail early on dispose.
709
709
  */
710
- finalizeAsync(signal: AbortSignal): Promise<void>;
710
+ finalizeAsync(loader: GLTFLoader): Promise<void>;
711
711
  private copySurfaceToCoatAsync;
712
712
  }
@@ -1082,10 +1082,9 @@ export class OpenPBRMaterialLoadingAdapter {
1082
1082
  }
1083
1083
  /**
1084
1084
  * Finalizes material properties after all loading is complete.
1085
- * @param signal An AbortSignal that fires when the loader is disposed. Intermediate
1086
- * textures are disposed and the method returns early when aborted.
1085
+ * @param loader The glTF loader; `loader._disposed` is polled between texture passes to bail early on dispose.
1087
1086
  */
1088
- async finalizeAsync(signal) {
1087
+ async finalizeAsync(loader) {
1089
1088
  // Do final configuration for the material to handle any interactions/dependencies between properties that we had to defer until all properties were loaded.
1090
1089
  // If the material is volumetric, we may need to create a coat layer to handle the surface tint.
1091
1090
  if ((this._diffuseTransmissionTint && !this._diffuseTransmissionTint.equals(Color3.White())) || this._diffuseTransmissionTintTexture) {
@@ -1096,8 +1095,8 @@ export class OpenPBRMaterialLoadingAdapter {
1096
1095
  }
1097
1096
  else {
1098
1097
  // Otherwise, we have volumetric attenuation so we need to use the coat layer to preserve the base color tinting of glTF.
1099
- await this.copySurfaceToCoatAsync(this.subsurfaceWeight, this.subsurfaceWeightTexture, TextureChannel.A, this._diffuseTransmissionTint, this._diffuseTransmissionTintTexture, true, signal);
1100
- if (signal.aborted) {
1098
+ await this.copySurfaceToCoatAsync(loader, this.subsurfaceWeight, this.subsurfaceWeightTexture, TextureChannel.A, this._diffuseTransmissionTint, this._diffuseTransmissionTintTexture, true);
1099
+ if (loader._disposed) {
1101
1100
  return;
1102
1101
  }
1103
1102
  }
@@ -1111,8 +1110,8 @@ export class OpenPBRMaterialLoadingAdapter {
1111
1110
  }
1112
1111
  else if (!this.baseColor.equals(Color3.White()) || this.baseColorTexture !== null) {
1113
1112
  // Otherwise, we have volumetric attenuation so we need to use the coat layer to preserve the base color tinting of glTF.
1114
- await this.copySurfaceToCoatAsync(this.transmissionWeight, this.transmissionWeightTexture, TextureChannel.R, this.baseColor, this.baseColorTexture, false, signal);
1115
- if (signal.aborted) {
1113
+ await this.copySurfaceToCoatAsync(loader, this.transmissionWeight, this.transmissionWeightTexture, TextureChannel.R, this.baseColor, this.baseColorTexture, false);
1114
+ if (loader._disposed) {
1116
1115
  return;
1117
1116
  }
1118
1117
  }
@@ -1121,7 +1120,7 @@ export class OpenPBRMaterialLoadingAdapter {
1121
1120
  // To convert from spec-gloss to OpenPBR, we'll grab the specular color's alpha channel (which contains glossiness) and
1122
1121
  // invert it to get roughness.
1123
1122
  const newRoughnessTexture = await InvertTextureAsync("newRoughnessTexture (" + this._material.name + ")", await ExtractChannelAsync("glossiness (" + this._material.name + ")", CreateTextureWithFactorOperand(this.specularColorTexture, new Color4(this.specularColor.r, this.specularColor.g, this.specularColor.b, this.glossiness), TextureChannel.A, TextureColorSpace.Linear), TextureChannel.A, this._material.getScene(), TextureColorSpace.Linear, ChannelMask.R), this._material.getScene(), ChannelMask.R, TextureColorSpace.Linear, ChannelMask.R);
1124
- if (signal.aborted) {
1123
+ if (loader._disposed) {
1125
1124
  newRoughnessTexture.texture?.dispose();
1126
1125
  return;
1127
1126
  }
@@ -1132,7 +1131,7 @@ export class OpenPBRMaterialLoadingAdapter {
1132
1131
  // We store metallic as linear (no outputColorSpace) because it is a data/scalar value;
1133
1132
  // encoding it as sRGB would corrupt it when it is used as the lerp t below.
1134
1133
  const newMetallic = await ExtractMaxChannelAsync("metallicTexture (" + this._material.name + ")", CreateTextureWithFactorOperand(this.specularColorTexture, this.specularColor.toColor4(), TextureChannel.RGBA, TextureColorSpace.Linear), this._material.getScene(), false, TextureColorSpace.SRGB, ChannelMask.RGB);
1135
- if (signal.aborted) {
1134
+ if (loader._disposed) {
1136
1135
  newMetallic.texture?.dispose();
1137
1136
  return;
1138
1137
  }
@@ -1142,7 +1141,7 @@ export class OpenPBRMaterialLoadingAdapter {
1142
1141
  // Strip dispose before passing newMetallic as t — its texture is already owned by the
1143
1142
  // material (baseMetalnessTexture) and must not be released after the lerp pass.
1144
1143
  const newBaseColor = await LerpTexturesAsync("newBaseColor (" + this._material.name + ")", CreateTextureWithFactorOperand(this.baseColorTexture, this.baseColor.toColor4(), TextureChannel.RGBA, TextureColorSpace.Linear), CreateTextureWithFactorOperand(this.specularColorTexture, this.specularColor.toColor4(), TextureChannel.RGBA, TextureColorSpace.Linear), { ...newMetallic, dispose: undefined, colorSpace: TextureColorSpace.Linear }, this._material.getScene(), TextureColorSpace.SRGB, ChannelMask.RGB);
1145
- if (signal.aborted) {
1144
+ if (loader._disposed) {
1146
1145
  newBaseColor.texture?.dispose();
1147
1146
  return;
1148
1147
  }
@@ -1155,7 +1154,7 @@ export class OpenPBRMaterialLoadingAdapter {
1155
1154
  this.specularColorTexture = null;
1156
1155
  }
1157
1156
  }
1158
- async copySurfaceToCoatAsync(weight, weightTexture, weightTextureChannel, color, colorTexture, diffuseTransmission = false, signal = new AbortController().signal) {
1157
+ async copySurfaceToCoatAsync(loader, weight, weightTexture, weightTextureChannel, color, colorTexture, diffuseTransmission = false) {
1159
1158
  // Blend coat properties using:
1160
1159
  // New coat will cover all areas that previously had coat or transmission.
1161
1160
  // new_coat_weight = max(weight, existing_coat_weight)
@@ -1188,13 +1187,13 @@ export class OpenPBRMaterialLoadingAdapter {
1188
1187
  throw rejected.reason;
1189
1188
  }
1190
1189
  const [lerpCoatColor, lerpSurfaceColor] = results.map((r) => r.value);
1191
- if (signal.aborted) {
1190
+ if (loader._disposed) {
1192
1191
  lerpCoatColor.texture?.dispose();
1193
1192
  lerpSurfaceColor.texture?.dispose();
1194
1193
  return;
1195
1194
  }
1196
1195
  const newCoatColor = await MultiplyTexturesAsync("newCoatColor (" + this._material.name + ")", lerpCoatColor, lerpSurfaceColor, this._material.getScene(), TextureColorSpace.SRGB);
1197
- if (signal.aborted) {
1196
+ if (loader._disposed) {
1198
1197
  newCoatColor.texture?.dispose();
1199
1198
  return;
1200
1199
  }
@@ -1207,27 +1206,27 @@ export class OpenPBRMaterialLoadingAdapter {
1207
1206
  this.coatColor.fromArray([newCoatColor.factor.r, newCoatColor.factor.g, newCoatColor.factor.b]);
1208
1207
  }
1209
1208
  const newCoatIor = await LerpTexturesAsync("newCoatIor (" + this._material.name + ")", CreateTextureWithFactorOperand(null, new Color4(this._material.specularIor, this._material.specularIor, this._material.specularIor, 1.0), TextureChannel.R), CreateTextureWithFactorOperand(null, new Color4(this.coatIor, this.coatIor, this.coatIor, 1.0), TextureChannel.R), CreateTextureWithFactorOperand(origCoatWeightTexture, origCoatWeightCol4, TextureChannel.R), this._material.getScene());
1210
- if (signal.aborted) {
1209
+ if (loader._disposed) {
1211
1210
  newCoatIor.texture?.dispose();
1212
1211
  return;
1213
1212
  }
1214
1213
  this.coatIor = newCoatIor.factor ? newCoatIor.factor.r : this.coatIor;
1215
1214
  const newCoatRoughness = await LerpTexturesAsync("newCoatRoughness (" + this._material.name + ")", CreateTextureWithFactorOperand(this.specularRoughnessTexture, new Color4(this.specularRoughness, this.specularRoughness, this.specularRoughness, 1.0), TextureChannel.G), CreateTextureWithFactorOperand(this.coatRoughnessTexture, new Color4(this.coatRoughness, this.coatRoughness, this.coatRoughness, 1.0), TextureChannel.G), CreateTextureWithFactorOperand(origCoatWeightTexture, origCoatWeightCol4, TextureChannel.R), this._material.getScene());
1216
- if (signal.aborted) {
1215
+ if (loader._disposed) {
1217
1216
  newCoatRoughness.texture?.dispose();
1218
1217
  return;
1219
1218
  }
1220
1219
  this.coatRoughness = newCoatRoughness.factor ? newCoatRoughness.factor.r : 1.0;
1221
1220
  this.coatRoughnessTexture = newCoatRoughness.texture;
1222
1221
  const newCoatDarkening = await LerpTexturesAsync("newCoatDarkening (" + this._material.name + ")", CreateTextureWithFactorOperand(null, new Color4(0, 0, 0, 1.0), TextureChannel.R), CreateTextureWithFactorOperand(null, new Color4(this.coatDarkening, this.coatDarkening, this.coatDarkening, 1.0), TextureChannel.R), CreateTextureWithFactorOperand(origCoatWeightTexture, origCoatWeightCol4, TextureChannel.R), this._material.getScene());
1223
- if (signal.aborted) {
1222
+ if (loader._disposed) {
1224
1223
  newCoatDarkening.texture?.dispose();
1225
1224
  return;
1226
1225
  }
1227
1226
  this.coatDarkening = newCoatDarkening.factor ? newCoatDarkening.factor.r : this.coatDarkening;
1228
1227
  if (diffuseTransmission) {
1229
1228
  const newSpecularRoughness = await LerpTexturesAsync("newSpecularRoughness (" + this._material.name + ")", CreateTextureWithFactorOperand(this.specularRoughnessTexture, new Color4(this._material.specularRoughness, this._material.specularRoughness, this._material.specularRoughness, 1.0), TextureChannel.G), CreateTextureWithFactorOperand(null, new Color4(1, 1, 1, 1.0), TextureChannel.R), CreateTextureWithFactorOperand(weightTexture, weightCol4, weightTextureChannel), this._material.getScene());
1230
- if (signal.aborted) {
1229
+ if (loader._disposed) {
1231
1230
  newSpecularRoughness.texture?.dispose();
1232
1231
  return;
1233
1232
  }
@@ -1236,7 +1235,7 @@ export class OpenPBRMaterialLoadingAdapter {
1236
1235
  }
1237
1236
  if (origCoatNormalTexture || this.geometryNormalTexture) {
1238
1237
  const newCoatNormal = await LerpTexturesAsync("newCoatNormal (" + this._material.name + ")", CreateTextureWithFactorOperand(this.geometryNormalTexture, this.geometryNormalTexture ? new Color4(1, 1, 1, 1) : new Color4(0.5, 0.5, 1.0, 1.0), TextureChannel.RGBA), CreateTextureWithFactorOperand(origCoatNormalTexture, origCoatNormalTexture ? new Color4(1, 1, 1, 1) : new Color4(0.5, 0.5, 1.0, 1.0), TextureChannel.RGBA), CreateTextureWithFactorOperand(origCoatWeightTexture, origCoatWeightCol4, TextureChannel.R), this._material.getScene());
1239
- if (signal.aborted) {
1238
+ if (loader._disposed) {
1240
1239
  newCoatNormal.texture?.dispose();
1241
1240
  return;
1242
1241
  }