@onerjs/loaders 8.36.4 → 8.36.6

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.
Files changed (37) hide show
  1. package/glTF/2.0/Extensions/KHR_materials_coat.d.ts +2 -2
  2. package/glTF/2.0/Extensions/KHR_materials_coat.js +2 -2
  3. package/glTF/2.0/Extensions/KHR_materials_coat.js.map +1 -1
  4. package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.d.ts +1 -1
  5. package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.js +1 -1
  6. package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.js.map +1 -1
  7. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js +2 -2
  8. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js.map +1 -1
  9. package/glTF/2.0/Extensions/KHR_materials_dispersion.js +3 -2
  10. package/glTF/2.0/Extensions/KHR_materials_dispersion.js.map +1 -1
  11. package/glTF/2.0/Extensions/KHR_materials_fuzz.d.ts +2 -1
  12. package/glTF/2.0/Extensions/KHR_materials_fuzz.js +2 -1
  13. package/glTF/2.0/Extensions/KHR_materials_fuzz.js.map +1 -1
  14. package/glTF/2.0/Extensions/KHR_materials_transmission.js +25 -22
  15. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
  16. package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
  17. package/glTF/2.0/Extensions/KHR_materials_volume.js +9 -3
  18. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
  19. package/glTF/2.0/Extensions/KHR_materials_volume_scatter.d.ts +45 -0
  20. package/glTF/2.0/Extensions/KHR_materials_volume_scatter.js +110 -0
  21. package/glTF/2.0/Extensions/KHR_materials_volume_scatter.js.map +1 -0
  22. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
  23. package/glTF/2.0/Extensions/index.d.ts +1 -0
  24. package/glTF/2.0/Extensions/index.js +1 -0
  25. package/glTF/2.0/Extensions/index.js.map +1 -1
  26. package/glTF/2.0/materialLoadingAdapter.d.ts +43 -1
  27. package/glTF/2.0/materialLoadingAdapter.js.map +1 -1
  28. package/glTF/2.0/openpbrMaterialLoadingAdapter.d.ts +98 -16
  29. package/glTF/2.0/openpbrMaterialLoadingAdapter.js +172 -35
  30. package/glTF/2.0/openpbrMaterialLoadingAdapter.js.map +1 -1
  31. package/glTF/2.0/pbrMaterialLoadingAdapter.d.ts +97 -8
  32. package/glTF/2.0/pbrMaterialLoadingAdapter.js +165 -19
  33. package/glTF/2.0/pbrMaterialLoadingAdapter.js.map +1 -1
  34. package/glTF/glTFValidation.d.ts +6 -0
  35. package/glTF/glTFValidation.js +6 -0
  36. package/glTF/glTFValidation.js.map +1 -1
  37. package/package.json +3 -3
@@ -1,6 +1,7 @@
1
1
  import { Color3 } from "@onerjs/core/Maths/math.color.js";
2
2
  import { GLTFLoader } from "../glTFLoader.js";
3
3
  import { registerGLTFExtension, unregisterGLTFExtension } from "../glTFLoaderExtensionRegistry.js";
4
+ import { Vector3 } from "@onerjs/core/Maths/math.vector.js";
4
5
  const NAME = "KHR_materials_volume";
5
6
  /**
6
7
  * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_volume/README.md)
@@ -55,9 +56,14 @@ export class KHR_materials_volume {
55
56
  if ((adapter.transmissionWeight === 0 && adapter.subsurfaceWeight === 0) || !extension.thicknessFactor) {
56
57
  return Promise.resolve();
57
58
  }
58
- adapter.transmissionDepth = extension.attenuationDistance !== undefined ? extension.attenuationDistance : Number.MAX_VALUE;
59
- adapter.transmissionColor =
60
- extension.attenuationColor !== undefined && extension.attenuationColor.length == 3 ? Color3.FromArray(extension.attenuationColor) : Color3.White();
59
+ const attenuationDistance = extension.attenuationDistance !== undefined ? extension.attenuationDistance : Number.MAX_VALUE;
60
+ const attenuationColor = extension.attenuationColor !== undefined && extension.attenuationColor.length == 3 ? Color3.FromArray(extension.attenuationColor) : Color3.White();
61
+ // Calculate the attenuation coefficient (i.e. extinction coefficient)
62
+ const extinctionCoefficient = new Vector3(-Math.log(attenuationColor.r), -Math.log(attenuationColor.g), -Math.log(attenuationColor.b));
63
+ extinctionCoefficient.scaleInPlace(1 / Math.max(attenuationDistance, 0.001));
64
+ adapter.extinctionCoefficient = extinctionCoefficient;
65
+ adapter.transmissionDepth = attenuationDistance;
66
+ adapter.transmissionColor = attenuationColor;
61
67
  adapter.volumeThickness = extension.thicknessFactor ?? 0;
62
68
  const promises = new Array();
63
69
  if (extension.thicknessTexture) {
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_materials_volume.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_volume.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,yCAA8B;AAI/C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEhG,MAAM,IAAI,GAAG,sBAAsB,CAAC;AAapC;;;GAGG;AACH,gEAAgE;AAChE,MAAM,OAAO,oBAAoB;IAkB7B;;OAEG;IACH,YAAY,MAAkB;QApB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QAQf,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,qHAAqH;YACrH,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC;QACzC,CAAC;IACL,CAAC;IAED,gBAAgB;IACT,OAAO;QACV,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC;QACzC,CAAC;QACA,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C,SAAS,CAAC;QAC3H,OAAO,CAAC,iBAAiB;YACrB,SAAS,CAAC,gBAAgB,KAAK,SAAS,IAAI,SAAS,CAAC,gBAAgB,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACvJ,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,eAAe,IAAI,CAAC,CAAC;QAEzD,MAAM,QAAQ,GAAG,IAAI,KAAK,EAAgB,CAAC;QAE3C,IAAI,SAAS,CAAC,gBAAgB,EAAE,CAAC;YAC5B,SAAS,CAAC,gBAAiC,CAAC,YAAY,GAAG,IAAI,CAAC;YACjE,0CAA0C;YAC1C,QAAQ,CAAC,IAAI,CACT,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,GAAG,OAAO,mBAAmB,EAAE,SAAS,CAAC,gBAAgB,EAAE,CAAC,OAAoB,EAAE,EAAE;gBAClH,OAAO,CAAC,IAAI,GAAG,GAAG,eAAe,CAAC,IAAI,cAAc,CAAC;gBACrD,OAAO,CAAC,sBAAsB,GAAG,OAAO,CAAC;YAC7C,CAAC,CAAC,CACL,CAAC;QACN,CAAC;QAED,0CAA0C;QAC1C,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAChD,CAAC;CACJ;AAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"core/types\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRMaterialsVolume } from \"babylonjs-gltf2interface\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"KHR_materials_volume\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc, @typescript-eslint/naming-convention\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_materials_volume extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_materials_volume\"]: {};\r\n }\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_volume/README.md)\r\n * @since 5.0.0\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_volume implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 173;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n if (this.enabled) {\r\n // We need to disable instance usage because the attenuation factor depends on the node scale of each individual mesh\r\n this._loader._disableInstancedMesh++;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n if (this.enabled) {\r\n this._loader._disableInstancedMesh--;\r\n }\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n // eslint-disable-next-line no-restricted-syntax\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsVolume>(context, material, this.name, async (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loadVolumePropertiesAsync(extensionContext, material, babylonMaterial, extension));\r\n // eslint-disable-next-line github/no-then\r\n return await Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\r\n private _loadVolumePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material, extension: IKHRMaterialsVolume): Promise<void> {\r\n const adapter = this._loader._getOrCreateMaterialAdapter(babylonMaterial);\r\n\r\n // If transparency isn't enabled already, this extension shouldn't do anything.\r\n // i.e. it requires either the KHR_materials_transmission or KHR_materials_diffuse_transmission extensions.\r\n if ((adapter.transmissionWeight === 0 && adapter.subsurfaceWeight === 0) || !extension.thicknessFactor) {\r\n return Promise.resolve();\r\n }\r\n\r\n adapter.transmissionDepth = extension.attenuationDistance !== undefined ? extension.attenuationDistance : Number.MAX_VALUE;\r\n adapter.transmissionColor =\r\n extension.attenuationColor !== undefined && extension.attenuationColor.length == 3 ? Color3.FromArray(extension.attenuationColor) : Color3.White();\r\n adapter.volumeThickness = extension.thicknessFactor ?? 0;\r\n\r\n const promises = new Array<Promise<any>>();\r\n\r\n if (extension.thicknessTexture) {\r\n (extension.thicknessTexture as ITextureInfo).nonColorData = true;\r\n // eslint-disable-next-line github/no-then\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/thicknessTexture`, extension.thicknessTexture, (texture: BaseTexture) => {\r\n texture.name = `${babylonMaterial.name} (Thickness)`;\r\n adapter.volumeThicknessTexture = texture;\r\n })\r\n );\r\n }\r\n\r\n // eslint-disable-next-line github/no-then\r\n return Promise.all(promises).then(() => {});\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new KHR_materials_volume(loader));\r\n"]}
1
+ {"version":3,"file":"KHR_materials_volume.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_volume.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,yCAA8B;AAI/C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAChG,OAAO,EAAE,OAAO,EAAE,0CAA+B;AAEjD,MAAM,IAAI,GAAG,sBAAsB,CAAC;AAapC;;;GAGG;AACH,gEAAgE;AAChE,MAAM,OAAO,oBAAoB;IAkB7B;;OAEG;IACH,YAAY,MAAkB;QApB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QAQf,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,qHAAqH;YACrH,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC;QACzC,CAAC;IACL,CAAC;IAED,gBAAgB;IACT,OAAO;QACV,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC;QACzC,CAAC;QACA,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,gDAAgD;IACzC,2BAA2B,CAAC,OAAe,EAAE,QAAmB,EAAE,eAAyB;QAC9F,OAAO,UAAU,CAAC,kBAAkB,CAAsB,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,EAA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,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"core/types\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRMaterialsVolume } from \"babylonjs-gltf2interface\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\n\r\nconst NAME = \"KHR_materials_volume\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc, @typescript-eslint/naming-convention\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_materials_volume extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_materials_volume\"]: {};\r\n }\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_volume/README.md)\r\n * @since 5.0.0\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_volume implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 173;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n if (this.enabled) {\r\n // We need to disable instance usage because the attenuation factor depends on the node scale of each individual mesh\r\n this._loader._disableInstancedMesh++;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n if (this.enabled) {\r\n this._loader._disableInstancedMesh--;\r\n }\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n // eslint-disable-next-line no-restricted-syntax\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsVolume>(context, material, this.name, async (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loadVolumePropertiesAsync(extensionContext, material, babylonMaterial, extension));\r\n // eslint-disable-next-line github/no-then\r\n return await Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\r\n private _loadVolumePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material, extension: IKHRMaterialsVolume): Promise<void> {\r\n const adapter = this._loader._getOrCreateMaterialAdapter(babylonMaterial);\r\n\r\n // If transparency isn't enabled already, this extension shouldn't do anything.\r\n // i.e. it requires either the KHR_materials_transmission or KHR_materials_diffuse_transmission extensions.\r\n if ((adapter.transmissionWeight === 0 && adapter.subsurfaceWeight === 0) || !extension.thicknessFactor) {\r\n return Promise.resolve();\r\n }\r\n\r\n const attenuationDistance = extension.attenuationDistance !== undefined ? extension.attenuationDistance : Number.MAX_VALUE;\r\n const attenuationColor = extension.attenuationColor !== undefined && extension.attenuationColor.length == 3 ? Color3.FromArray(extension.attenuationColor) : Color3.White();\r\n // Calculate the attenuation coefficient (i.e. extinction coefficient)\r\n const extinctionCoefficient = new Vector3(-Math.log(attenuationColor.r), -Math.log(attenuationColor.g), -Math.log(attenuationColor.b));\r\n extinctionCoefficient.scaleInPlace(1 / Math.max(attenuationDistance, 0.001));\r\n adapter.extinctionCoefficient = extinctionCoefficient;\r\n\r\n adapter.transmissionDepth = attenuationDistance;\r\n adapter.transmissionColor = attenuationColor;\r\n\r\n adapter.volumeThickness = extension.thicknessFactor ?? 0;\r\n\r\n const promises = new Array<Promise<any>>();\r\n\r\n if (extension.thicknessTexture) {\r\n (extension.thicknessTexture as ITextureInfo).nonColorData = true;\r\n // eslint-disable-next-line github/no-then\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/thicknessTexture`, extension.thicknessTexture, (texture: BaseTexture) => {\r\n texture.name = `${babylonMaterial.name} (Thickness)`;\r\n adapter.volumeThicknessTexture = texture;\r\n })\r\n );\r\n }\r\n\r\n // eslint-disable-next-line github/no-then\r\n return Promise.all(promises).then(() => {});\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new KHR_materials_volume(loader));\r\n"]}
@@ -0,0 +1,45 @@
1
+ import type { Nullable } from "@onerjs/core/types.js";
2
+ import type { Material } from "@onerjs/core/Materials/material.js";
3
+ import type { IMaterial } from "../glTFLoaderInterfaces.js";
4
+ import type { IGLTFLoaderExtension } from "../glTFLoaderExtension.js";
5
+ import { GLTFLoader } from "../glTFLoader.js";
6
+ declare module "../../glTFFileLoader.js" {
7
+ interface GLTFLoaderExtensionOptions {
8
+ /**
9
+ * Defines options for the KHR_materials_volume_scatter extension.
10
+ */
11
+ ["KHR_materials_volume_scatter"]: {};
12
+ }
13
+ }
14
+ /**
15
+ * TODO: In-progress specification
16
+ * [Specification](https://github.com/KhronosGroup/glTF/blob/7ea427ed55d44427e83c0a6d1c87068b1a4151c5/extensions/2.0/Khronos/KHR_materials_volume_scatter/README.md)
17
+ * @experimental
18
+ * @since 9.0.0
19
+ */
20
+ export declare class KHR_materials_volume_scatter implements IGLTFLoaderExtension {
21
+ /**
22
+ * The name of this extension.
23
+ */
24
+ readonly name = "KHR_materials_volume_scatter";
25
+ /**
26
+ * Defines whether this extension is enabled.
27
+ */
28
+ enabled: boolean;
29
+ /**
30
+ * Defines a number that determines the order the extensions are applied.
31
+ */
32
+ order: number;
33
+ private _loader;
34
+ /**
35
+ * @internal
36
+ */
37
+ constructor(loader: GLTFLoader);
38
+ /** @internal */
39
+ dispose(): void;
40
+ /**
41
+ * @internal
42
+ */
43
+ loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
44
+ private _loadVolumePropertiesAsync;
45
+ }
@@ -0,0 +1,110 @@
1
+ import { Color3 } from "@onerjs/core/Maths/math.color.js";
2
+ import { Vector3 } from "@onerjs/core/Maths/math.vector.js";
3
+ import { GLTFLoader } from "../glTFLoader.js";
4
+ import { registerGLTFExtension, unregisterGLTFExtension } from "../glTFLoaderExtensionRegistry.js";
5
+ const NAME = "KHR_materials_volume_scatter";
6
+ function multiScatterToSingleScatterAlbedo(multiScatter) {
7
+ const multiScatterAlbedo = new Vector3(multiScatter.r, multiScatter.g, multiScatter.b);
8
+ const s = new Vector3(4.09712, 4.09712, 4.09712);
9
+ s.multiplyInPlace(multiScatterAlbedo);
10
+ s.addInPlace(new Vector3(4.20863, 4.20863, 4.20863));
11
+ const p = new Vector3(9.59217, 9.59217, 9.59217);
12
+ p.addInPlace(new Vector3(41.6808, 41.6808, 41.6808).multiplyInPlace(multiScatterAlbedo));
13
+ p.addInPlace(new Vector3(17.7126, 17.7126, 17.7126).multiplyInPlace(multiScatterAlbedo.multiply(multiScatterAlbedo)));
14
+ s.subtractInPlace(new Vector3(Math.sqrt(p.x), Math.sqrt(p.y), Math.sqrt(p.z)));
15
+ return new Vector3(1.0, 1.0, 1.0).subtract(s.multiply(s));
16
+ }
17
+ /**
18
+ * TODO: In-progress specification
19
+ * [Specification](https://github.com/KhronosGroup/glTF/blob/7ea427ed55d44427e83c0a6d1c87068b1a4151c5/extensions/2.0/Khronos/KHR_materials_volume_scatter/README.md)
20
+ * @experimental
21
+ * @since 9.0.0
22
+ */
23
+ // eslint-disable-next-line @typescript-eslint/naming-convention
24
+ export class KHR_materials_volume_scatter {
25
+ /**
26
+ * @internal
27
+ */
28
+ constructor(loader) {
29
+ /**
30
+ * The name of this extension.
31
+ */
32
+ this.name = NAME;
33
+ /**
34
+ * Defines a number that determines the order the extensions are applied.
35
+ */
36
+ this.order = 172;
37
+ this._loader = loader;
38
+ this.enabled = this._loader.isExtensionUsed(NAME);
39
+ if (this.enabled) {
40
+ // We need to disable instance usage because the attenuation factor depends on the node scale of each individual mesh
41
+ this._loader._disableInstancedMesh++;
42
+ }
43
+ }
44
+ /** @internal */
45
+ dispose() {
46
+ if (this.enabled) {
47
+ this._loader._disableInstancedMesh--;
48
+ }
49
+ this._loader = null;
50
+ }
51
+ /**
52
+ * @internal
53
+ */
54
+ // eslint-disable-next-line no-restricted-syntax
55
+ loadMaterialPropertiesAsync(context, material, babylonMaterial) {
56
+ return GLTFLoader.LoadExtensionAsync(context, material, this.name, async (extensionContext, extension) => {
57
+ const promises = new Array();
58
+ promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
59
+ promises.push(this._loadVolumePropertiesAsync(extensionContext, material, babylonMaterial, extension));
60
+ // eslint-disable-next-line github/no-then
61
+ return await Promise.all(promises).then(() => { });
62
+ });
63
+ }
64
+ // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax
65
+ _loadVolumePropertiesAsync(context, material, babylonMaterial, extension) {
66
+ const adapter = this._loader._getOrCreateMaterialAdapter(babylonMaterial);
67
+ // If transparency isn't enabled already, this extension shouldn't do anything.
68
+ // i.e. it requires either the KHR_materials_transmission or KHR_materials_diffuse_transmission extensions.
69
+ if (adapter.transmissionWeight === 0 && adapter.subsurfaceWeight === 0) {
70
+ return Promise.resolve();
71
+ }
72
+ const scatterColor = extension.multiscatterColor !== undefined && extension.multiscatterColor.length == 3 ? Color3.FromArray(extension.multiscatterColor) : Color3.Black();
73
+ const scatterAnisotropy = extension.scatterAnisotropy !== undefined ? extension.scatterAnisotropy : 0;
74
+ // In glTF, both the translucency volume and subsurface volume use the same input parameters.
75
+ // We'll apply them to both, as appropriate.
76
+ if (adapter.transmissionWeight > 0) {
77
+ const singleScatterAlbedo = multiScatterToSingleScatterAlbedo(scatterColor);
78
+ const extinctionCoefficient = new Vector3(-Math.log(adapter.transmissionColor.r), -Math.log(adapter.transmissionColor.g), -Math.log(adapter.transmissionColor.b));
79
+ extinctionCoefficient.scaleInPlace(1 / Math.max(adapter.transmissionDepth, 0.001));
80
+ const scatteringCoefficient = extinctionCoefficient.multiply(singleScatterAlbedo);
81
+ // The scattering coefficient in OpenPBR is defined as per unit distance, so we need to scale it back up by the depth.
82
+ scatteringCoefficient.scaleInPlace(adapter.transmissionDepth);
83
+ adapter.transmissionScatter.set(scatteringCoefficient.x, scatteringCoefficient.y, scatteringCoefficient.z);
84
+ // Load texture if present
85
+ let texturePromise = Promise.resolve(null);
86
+ if (extension.multiscatterColorTexture) {
87
+ extension.multiscatterColorTexture.nonColorData = true;
88
+ texturePromise = this._loader.loadTextureInfoAsync(`${context}/multiscatterColorTexture`, extension.multiscatterColorTexture, (texture) => {
89
+ texture.name = `${babylonMaterial.name} (Transmission)`;
90
+ adapter.transmissionWeightTexture = texture;
91
+ });
92
+ }
93
+ adapter.transmissionScatterAnisotropy = scatterAnisotropy;
94
+ // eslint-disable-next-line github/no-then
95
+ return texturePromise.then(() => { });
96
+ }
97
+ // Subsurface volume
98
+ if (adapter.subsurfaceWeight > 0) {
99
+ adapter.subsurfaceScatterAnisotropy = scatterAnisotropy;
100
+ adapter.subsurfaceColor = scatterColor;
101
+ const mfp = new Vector3(adapter.extinctionCoefficient.x !== 0 ? 1.0 / adapter.extinctionCoefficient.x : 1.0, adapter.extinctionCoefficient.y !== 0 ? 1.0 / adapter.extinctionCoefficient.y : 1.0, adapter.extinctionCoefficient.z !== 0 ? 1.0 / adapter.extinctionCoefficient.z : 1.0);
102
+ adapter.subsurfaceRadius = Math.max(mfp.x, mfp.y, mfp.z);
103
+ adapter.subsurfaceRadiusScale = new Color3(mfp.x / adapter.subsurfaceRadius, mfp.y / adapter.subsurfaceRadius, mfp.z / adapter.subsurfaceRadius);
104
+ }
105
+ return Promise.resolve();
106
+ }
107
+ }
108
+ unregisterGLTFExtension(NAME);
109
+ registerGLTFExtension(NAME, true, (loader) => new KHR_materials_volume_scatter(loader));
110
+ //# sourceMappingURL=KHR_materials_volume_scatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KHR_materials_volume_scatter.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_volume_scatter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,yCAA8B;AAC/C,OAAO,EAAE,OAAO,EAAE,0CAA+B;AAIjD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEhG,MAAM,IAAI,GAAG,8BAA8B,CAAC;AAa5C,SAAS,iCAAiC,CAAC,YAAoB;IAC3D,MAAM,kBAAkB,GAAG,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IACvF,MAAM,CAAC,GAAY,IAAI,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC;IACtC,CAAC,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAErD,MAAM,CAAC,GAAY,IAAI,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,eAAe,CAAC,kBAAkB,CAAC,C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AC;QACrJ,CAAC;QAED,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ;AAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,4BAA4B,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"core/types\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRMaterialsVolumeScatter } from \"babylonjs-gltf2interface\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"KHR_materials_volume_scatter\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc, @typescript-eslint/naming-convention\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the KHR_materials_volume_scatter extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"KHR_materials_volume_scatter\"]: {};\r\n }\r\n}\r\n\r\nfunction multiScatterToSingleScatterAlbedo(multiScatter: Color3): Vector3 {\r\n const multiScatterAlbedo = new Vector3(multiScatter.r, multiScatter.g, multiScatter.b);\r\n const s: Vector3 = new Vector3(4.09712, 4.09712, 4.09712);\r\n s.multiplyInPlace(multiScatterAlbedo);\r\n s.addInPlace(new Vector3(4.20863, 4.20863, 4.20863));\r\n\r\n const p: Vector3 = new Vector3(9.59217, 9.59217, 9.59217);\r\n p.addInPlace(new Vector3(41.6808, 41.6808, 41.6808).multiplyInPlace(multiScatterAlbedo));\r\n p.addInPlace(new Vector3(17.7126, 17.7126, 17.7126).multiplyInPlace(multiScatterAlbedo.multiply(multiScatterAlbedo)));\r\n s.subtractInPlace(new Vector3(Math.sqrt(p.x), Math.sqrt(p.y), Math.sqrt(p.z)));\r\n return new Vector3(1.0, 1.0, 1.0).subtract(s.multiply(s));\r\n}\r\n\r\n/**\r\n * TODO: In-progress specification\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/7ea427ed55d44427e83c0a6d1c87068b1a4151c5/extensions/2.0/Khronos/KHR_materials_volume_scatter/README.md)\r\n * @experimental\r\n * @since 9.0.0\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_volume_scatter implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 172;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n if (this.enabled) {\r\n // We need to disable instance usage because the attenuation factor depends on the node scale of each individual mesh\r\n this._loader._disableInstancedMesh++;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n if (this.enabled) {\r\n this._loader._disableInstancedMesh--;\r\n }\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n // eslint-disable-next-line no-restricted-syntax\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsVolumeScatter>(context, material, this.name, async (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loadVolumePropertiesAsync(extensionContext, material, babylonMaterial, extension));\r\n // eslint-disable-next-line github/no-then\r\n return await Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\r\n private _loadVolumePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material, extension: IKHRMaterialsVolumeScatter): Promise<void> {\r\n const adapter = this._loader._getOrCreateMaterialAdapter(babylonMaterial);\r\n\r\n // If transparency isn't enabled already, this extension shouldn't do anything.\r\n // i.e. it requires either the KHR_materials_transmission or KHR_materials_diffuse_transmission extensions.\r\n if (adapter.transmissionWeight === 0 && adapter.subsurfaceWeight === 0) {\r\n return Promise.resolve();\r\n }\r\n\r\n const scatterColor = extension.multiscatterColor !== undefined && extension.multiscatterColor.length == 3 ? Color3.FromArray(extension.multiscatterColor) : Color3.Black();\r\n const scatterAnisotropy = extension.scatterAnisotropy !== undefined ? extension.scatterAnisotropy : 0;\r\n\r\n // In glTF, both the translucency volume and subsurface volume use the same input parameters.\r\n // We'll apply them to both, as appropriate.\r\n if (adapter.transmissionWeight > 0) {\r\n const singleScatterAlbedo = multiScatterToSingleScatterAlbedo(scatterColor);\r\n\r\n const extinctionCoefficient = new Vector3(-Math.log(adapter.transmissionColor.r), -Math.log(adapter.transmissionColor.g), -Math.log(adapter.transmissionColor.b));\r\n extinctionCoefficient.scaleInPlace(1 / Math.max(adapter.transmissionDepth, 0.001));\r\n\r\n const scatteringCoefficient = extinctionCoefficient.multiply(singleScatterAlbedo);\r\n\r\n // The scattering coefficient in OpenPBR is defined as per unit distance, so we need to scale it back up by the depth.\r\n scatteringCoefficient.scaleInPlace(adapter.transmissionDepth);\r\n adapter.transmissionScatter.set(scatteringCoefficient.x, scatteringCoefficient.y, scatteringCoefficient.z);\r\n\r\n // Load texture if present\r\n let texturePromise: Promise<Nullable<BaseTexture>> = Promise.resolve(null);\r\n if (extension.multiscatterColorTexture) {\r\n (extension.multiscatterColorTexture as ITextureInfo).nonColorData = true;\r\n texturePromise = this._loader.loadTextureInfoAsync(`${context}/multiscatterColorTexture`, extension.multiscatterColorTexture, (texture: BaseTexture) => {\r\n texture.name = `${babylonMaterial.name} (Transmission)`;\r\n adapter.transmissionWeightTexture = texture;\r\n });\r\n }\r\n adapter.transmissionScatterAnisotropy = scatterAnisotropy;\r\n // eslint-disable-next-line github/no-then\r\n return texturePromise.then(() => {});\r\n }\r\n // Subsurface volume\r\n if (adapter.subsurfaceWeight > 0) {\r\n adapter.subsurfaceScatterAnisotropy = scatterAnisotropy;\r\n adapter.subsurfaceColor = scatterColor;\r\n\r\n const mfp = new Vector3(\r\n adapter.extinctionCoefficient.x !== 0 ? 1.0 / adapter.extinctionCoefficient.x : 1.0,\r\n adapter.extinctionCoefficient.y !== 0 ? 1.0 / adapter.extinctionCoefficient.y : 1.0,\r\n adapter.extinctionCoefficient.z !== 0 ? 1.0 / adapter.extinctionCoefficient.z : 1.0\r\n );\r\n\r\n adapter.subsurfaceRadius = Math.max(mfp.x, mfp.y, mfp.z);\r\n adapter.subsurfaceRadiusScale = new Color3(mfp.x / adapter.subsurfaceRadius, mfp.y / adapter.subsurfaceRadius, mfp.z / adapter.subsurfaceRadius);\r\n }\r\n\r\n return Promise.resolve();\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new KHR_materials_volume_scatter(loader));\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"MSFT_sRGBFactors.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_sRGBFactors.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEhG,MAAM,IAAI,GAAG,kBAAkB,CAAC;AAahC,gBAAgB;AAChB,gEAAgE;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AAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { IMaterial } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"MSFT_sRGBFactors\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc, @typescript-eslint/naming-convention\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the MSFT_sRGBFactors extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"MSFT_sRGBFactors\"]: {};\r\n }\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class MSFT_sRGBFactors implements IGLTFLoaderExtension {\r\n /** @internal */\r\n public readonly name = NAME;\r\n\r\n /** @internal */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /** @internal */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /** @internal*/\r\n // eslint-disable-next-line no-restricted-syntax\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtraAsync<boolean>(context, material, this.name, async (extraContext, extra) => {\r\n if (extra) {\r\n const adapter = this._loader._getOrCreateMaterialAdapter(babylonMaterial);\r\n const promise = this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial);\r\n\r\n const useExactSrgbConversions = babylonMaterial.getScene().getEngine().useExactSrgbConversions;\r\n if (!adapter.baseColorTexture) {\r\n adapter.baseColor.toLinearSpaceToRef(adapter.baseColor, useExactSrgbConversions);\r\n }\r\n if (!adapter.specularColorTexture) {\r\n adapter.specularColor.toLinearSpaceToRef(adapter.specularColor, useExactSrgbConversions);\r\n }\r\n\r\n return await promise;\r\n }\r\n });\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new MSFT_sRGBFactors(loader));\r\n"]}
1
+ {"version":3,"file":"MSFT_sRGBFactors.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_sRGBFactors.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEhG,MAAM,IAAI,GAAG,kBAAkB,CAAC;AAahC,gBAAgB;AAChB,gEAAgE;AAChE,MAAM,OAAO,gBAAgB;IASzB,gBAAgB;IAChB,YAAY,MAAkB;QAT9B,gBAAgB;QACA,SAAI,GAAG,IAAI,CAAC;QASxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,gBAAgB;IACT,OAAO;QACT,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED,eAAe;IACf,gDAAgD;IACzC,2BAA2B,CAAC,OAAe,EAAE,QAAmB,EAAE,eAAyB;QAC9F,OAAO,UAAU,CAAC,cAAc,CAAU,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE;YAClG,IAAI,KAAK,EAAE,CAAC;gBACR,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,eAAe,CAAE,CAAC;gBAC3E,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC;gBAE7F,MAAM,uBAAuB,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,CAAC,uBAAuB,CAAC;gBAC/F,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;oBAC5B,OAAO,CAAC,SAAS,CAAC,kBAAkB,CAAC,OAAO,CAAC,SAAS,EAAE,uBAAuB,CAAC,CAAC;gBACrF,CAAC;gBACD,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,CAAC;oBAChC,OAAO,CAAC,aAAa,CAAC,kBAAkB,CAAC,OAAO,CAAC,aAAa,EAAE,uBAAuB,CAAC,CAAC;gBAC7F,CAAC;gBAED,OAAO,MAAM,OAAO,CAAC;YACzB,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAC9B,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { IMaterial } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport { registerGLTFExtension, unregisterGLTFExtension } from \"../glTFLoaderExtensionRegistry\";\r\n\r\nconst NAME = \"MSFT_sRGBFactors\";\r\n\r\ndeclare module \"../../glTFFileLoader\" {\r\n // eslint-disable-next-line jsdoc/require-jsdoc, @typescript-eslint/naming-convention\r\n export interface GLTFLoaderExtensionOptions {\r\n /**\r\n * Defines options for the MSFT_sRGBFactors extension.\r\n */\r\n // NOTE: Don't use NAME here as it will break the UMD type declarations.\r\n [\"MSFT_sRGBFactors\"]: {};\r\n }\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class MSFT_sRGBFactors implements IGLTFLoaderExtension {\r\n /** @internal */\r\n public readonly name = NAME;\r\n\r\n /** @internal */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /** @internal */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /** @internal*/\r\n // eslint-disable-next-line no-restricted-syntax\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtraAsync<boolean>(context, material, this.name, async (extraContext, extra) => {\r\n if (extra) {\r\n const adapter = this._loader._getOrCreateMaterialAdapter(babylonMaterial)!;\r\n const promise = this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial);\r\n\r\n const useExactSrgbConversions = babylonMaterial.getScene().getEngine().useExactSrgbConversions;\r\n if (!adapter.baseColorTexture) {\r\n adapter.baseColor.toLinearSpaceToRef(adapter.baseColor, useExactSrgbConversions);\r\n }\r\n if (!adapter.specularColorTexture) {\r\n adapter.specularColor.toLinearSpaceToRef(adapter.specularColor, useExactSrgbConversions);\r\n }\r\n\r\n return await promise;\r\n }\r\n });\r\n }\r\n}\r\n\r\nunregisterGLTFExtension(NAME);\r\nregisterGLTFExtension(NAME, true, (loader) => new MSFT_sRGBFactors(loader));\r\n"]}
@@ -23,6 +23,7 @@ export * from "./KHR_materials_variants.js";
23
23
  export * from "./KHR_materials_transmission.js";
24
24
  export * from "./KHR_materials_diffuse_transmission.js";
25
25
  export * from "./KHR_materials_volume.js";
26
+ export * from "./KHR_materials_volume_scatter.js";
26
27
  export * from "./KHR_materials_dispersion.js";
27
28
  export * from "./KHR_materials_diffuse_roughness.js";
28
29
  export * from "./KHR_mesh_quantization.js";
@@ -24,6 +24,7 @@ export * from "./KHR_materials_variants.js";
24
24
  export * from "./KHR_materials_transmission.js";
25
25
  export * from "./KHR_materials_diffuse_transmission.js";
26
26
  export * from "./KHR_materials_volume.js";
27
+ export * from "./KHR_materials_volume_scatter.js";
27
28
  export * from "./KHR_materials_dispersion.js";
28
29
  export * from "./KHR_materials_diffuse_roughness.js";
29
30
  export * from "./KHR_mesh_quantization.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uCAAuC,CAAC;AACtD,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mCAAmC,CAAC;AAClD,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sCAAsC,CAAC;AACrD,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mCAAmC,CAAC;AAClD,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nexport * from \"./objectModelMapping\";\r\nexport * from \"./EXT_lights_image_based\";\r\nexport * from \"./EXT_mesh_gpu_instancing\";\r\nexport * from \"./EXT_meshopt_compression\";\r\nexport * from \"./EXT_texture_webp\";\r\nexport * from \"./EXT_texture_avif\";\r\nexport * from \"./EXT_lights_ies\";\r\nexport * from \"./KHR_draco_mesh_compression\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./EXT_lights_area\";\r\nexport * from \"./KHR_materials_pbrSpecularGlossiness\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_coat\";\r\nexport * from \"./KHR_materials_iridescence\";\r\nexport * from \"./KHR_materials_anisotropy\";\r\nexport * from \"./KHR_materials_emissive_strength\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_fuzz\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_variants\";\r\nexport * from \"./KHR_materials_transmission\";\r\nexport * from \"./KHR_materials_diffuse_transmission\";\r\nexport * from \"./KHR_materials_volume\";\r\nexport * from \"./KHR_materials_dispersion\";\r\nexport * from \"./KHR_materials_diffuse_roughness\";\r\nexport * from \"./KHR_mesh_quantization\";\r\nexport * from \"./KHR_texture_basisu\";\r\nexport * from \"./KHR_texture_transform\";\r\nexport * from \"./KHR_xmp_json_ld\";\r\nexport * from \"./KHR_animation_pointer\";\r\nexport * from \"./MSFT_audio_emitter\";\r\nexport * from \"./MSFT_lod\";\r\nexport * from \"./MSFT_minecraftMesh\";\r\nexport * from \"./MSFT_sRGBFactors\";\r\nexport * from \"./KHR_interactivity\";\r\nexport * from \"./KHR_node_visibility\";\r\nexport * from \"./KHR_node_selectability\";\r\nexport * from \"./KHR_node_hoverability\";\r\nexport * from \"./ExtrasAsMetadata\";\r\nexport * from \"./KHR_interactivity/index\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uCAAuC,CAAC;AACtD,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mCAAmC,CAAC;AAClD,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sCAAsC,CAAC;AACrD,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mCAAmC,CAAC;AAClD,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nexport * from \"./objectModelMapping\";\r\nexport * from \"./EXT_lights_image_based\";\r\nexport * from \"./EXT_mesh_gpu_instancing\";\r\nexport * from \"./EXT_meshopt_compression\";\r\nexport * from \"./EXT_texture_webp\";\r\nexport * from \"./EXT_texture_avif\";\r\nexport * from \"./EXT_lights_ies\";\r\nexport * from \"./KHR_draco_mesh_compression\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./EXT_lights_area\";\r\nexport * from \"./KHR_materials_pbrSpecularGlossiness\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_coat\";\r\nexport * from \"./KHR_materials_iridescence\";\r\nexport * from \"./KHR_materials_anisotropy\";\r\nexport * from \"./KHR_materials_emissive_strength\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_fuzz\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_variants\";\r\nexport * from \"./KHR_materials_transmission\";\r\nexport * from \"./KHR_materials_diffuse_transmission\";\r\nexport * from \"./KHR_materials_volume\";\r\nexport * from \"./KHR_materials_volume_scatter\";\r\nexport * from \"./KHR_materials_dispersion\";\r\nexport * from \"./KHR_materials_diffuse_roughness\";\r\nexport * from \"./KHR_mesh_quantization\";\r\nexport * from \"./KHR_texture_basisu\";\r\nexport * from \"./KHR_texture_transform\";\r\nexport * from \"./KHR_xmp_json_ld\";\r\nexport * from \"./KHR_animation_pointer\";\r\nexport * from \"./MSFT_audio_emitter\";\r\nexport * from \"./MSFT_lod\";\r\nexport * from \"./MSFT_minecraftMesh\";\r\nexport * from \"./MSFT_sRGBFactors\";\r\nexport * from \"./KHR_interactivity\";\r\nexport * from \"./KHR_node_visibility\";\r\nexport * from \"./KHR_node_selectability\";\r\nexport * from \"./KHR_node_hoverability\";\r\nexport * from \"./ExtrasAsMetadata\";\r\nexport * from \"./KHR_interactivity/index\";\r\n"]}
@@ -2,6 +2,7 @@ import type { Material } from "@onerjs/core/Materials/material.js";
2
2
  import type { BaseTexture } from "@onerjs/core/Materials/Textures/baseTexture.js";
3
3
  import type { Nullable } from "@onerjs/core/types.js";
4
4
  import type { Color3 } from "@onerjs/core/Maths/math.color.js";
5
+ import type { Vector3 } from "@onerjs/core/Maths/math.vector.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.
@@ -188,10 +189,26 @@ export interface IMaterialLoadingAdapter {
188
189
  * Sets the attenuation color
189
190
  */
190
191
  transmissionColor: Color3;
192
+ /**
193
+ * Sets the scattering coefficient
194
+ */
195
+ transmissionScatter: Color3;
196
+ /**
197
+ * Sets the scattering anisotropy (-1 to 1)
198
+ */
199
+ transmissionScatterAnisotropy: number;
191
200
  /**
192
201
  * Sets the dispersion Abbe number
193
202
  */
194
203
  transmissionDispersionAbbeNumber: number;
204
+ /**
205
+ * Sets the dispersion scale
206
+ */
207
+ transmissionDispersionScale: number;
208
+ /**
209
+ * The refraction background texture
210
+ */
211
+ refractionBackgroundTexture: Nullable<BaseTexture>;
195
212
  /**
196
213
  * Configures transmission for thin-surface transmission (KHR_materials_transmission)
197
214
  */
@@ -205,9 +222,14 @@ export interface IMaterialLoadingAdapter {
205
222
  */
206
223
  volumeThickness: number;
207
224
  /**
208
- * Configures subsurface properties for PBR material
225
+ * Configures subsurface properties
209
226
  */
210
227
  configureSubsurface(): void;
228
+ /**
229
+ * @internal
230
+ * Sets/gets the extinction coefficient
231
+ */
232
+ extinctionCoefficient: Vector3;
211
233
  /**
212
234
  * Sets/gets the subsurface weight
213
235
  */
@@ -224,6 +246,26 @@ export interface IMaterialLoadingAdapter {
224
246
  * Sets/gets the subsurface color texture
225
247
  */
226
248
  subsurfaceColorTexture: Nullable<BaseTexture>;
249
+ /**
250
+ * Sets/gets the surface tint of the material (when using subsurface scattering)
251
+ */
252
+ subsurfaceConstantTint: Color3;
253
+ /**
254
+ * Sets/gets the surface tint texture of the material (when using subsurface scattering)
255
+ */
256
+ subsurfaceConstantTintTexture: Nullable<BaseTexture>;
257
+ /**
258
+ * Sets/gets the subsurface radius (used for subsurface scattering)
259
+ */
260
+ subsurfaceRadius: number;
261
+ /**
262
+ * Sets/gets the subsurface radius scale (used for subsurface scattering)
263
+ */
264
+ subsurfaceRadiusScale: Color3;
265
+ /**
266
+ * Sets/gets the subsurface scattering anisotropy
267
+ */
268
+ subsurfaceScatterAnisotropy: number;
227
269
  /**
228
270
  * Configures initial settings for fuzz for material.
229
271
  */
@@ -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 /**\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 * 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 // 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 dispersion Abbe number\r\n */\r\n transmissionDispersionAbbeNumber: number;\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 * 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 for PBR material\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 // 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 { Vector3 } from \"core/Maths/math.vector\";\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 * 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 * 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 // 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 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 * 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 * @internal\r\n * Sets/gets the extinction coefficient\r\n */\r\n extinctionCoefficient: Vector3;\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 surface tint of the material (when using subsurface scattering)\r\n */\r\n subsurfaceConstantTint: Color3;\r\n\r\n /**\r\n * Sets/gets the surface tint texture of the material (when using subsurface scattering)\r\n */\r\n subsurfaceConstantTintTexture: 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 // 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"]}