@babylonjs/loaders 5.0.0-rc.3 → 5.0.0-rc.6
Sign up to get free protection for your applications and to get access to all the features.
- package/OBJ/index.js.map +1 -1
- package/OBJ/mtlFileLoader.d.ts +7 -6
- package/OBJ/mtlFileLoader.js +15 -14
- package/OBJ/mtlFileLoader.js.map +1 -1
- package/OBJ/objFileLoader.d.ts +11 -18
- package/OBJ/objFileLoader.js +19 -23
- package/OBJ/objFileLoader.js.map +1 -1
- package/OBJ/objLoadingOptions.d.ts +1 -1
- package/OBJ/objLoadingOptions.js.map +1 -1
- package/OBJ/solidParser.d.ts +6 -5
- package/OBJ/solidParser.js +15 -21
- package/OBJ/solidParser.js.map +1 -1
- package/STL/index.js.map +1 -1
- package/STL/stlFileLoader.d.ts +7 -14
- package/STL/stlFileLoader.js +15 -21
- package/STL/stlFileLoader.js.map +1 -1
- package/glTF/1.0/glTFBinaryExtension.d.ts +4 -4
- package/glTF/1.0/glTFBinaryExtension.js +4 -5
- package/glTF/1.0/glTFBinaryExtension.js.map +1 -1
- package/glTF/1.0/glTFLoader.d.ts +80 -50
- package/glTF/1.0/glTFLoader.js +265 -146
- package/glTF/1.0/glTFLoader.js.map +1 -1
- package/glTF/1.0/glTFLoaderInterfaces.d.ts +10 -10
- package/glTF/1.0/glTFLoaderInterfaces.js +3 -3
- package/glTF/1.0/glTFLoaderInterfaces.js.map +1 -1
- package/glTF/1.0/glTFLoaderUtils.d.ts +25 -25
- package/glTF/1.0/glTFLoaderUtils.js +70 -52
- package/glTF/1.0/glTFLoaderUtils.js.map +1 -1
- package/glTF/1.0/glTFMaterialsCommonExtension.d.ts +2 -2
- package/glTF/1.0/glTFMaterialsCommonExtension.js +13 -11
- package/glTF/1.0/glTFMaterialsCommonExtension.js.map +1 -1
- package/glTF/1.0/index.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_lights_image_based.d.ts +11 -4
- package/glTF/2.0/Extensions/EXT_lights_image_based.js +9 -2
- package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +13 -5
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +12 -4
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_meshopt_compression.d.ts +10 -3
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js +10 -3
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_texture_webp.d.ts +12 -4
- package/glTF/2.0/Extensions/EXT_texture_webp.js +11 -3
- package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
- package/glTF/2.0/Extensions/ExtrasAsMetadata.d.ts +26 -8
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js +22 -4
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.d.ts +14 -6
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +17 -6
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_lights_punctual.js +11 -3
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_ior.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +11 -3
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_specular.js +11 -3
- package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_translucency.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_translucency.js +11 -4
- package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_transmission.js +24 -13
- package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_unlit.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_variants.d.ts +17 -6
- package/glTF/2.0/Extensions/KHR_materials_variants.js +19 -8
- package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_volume.js +12 -5
- package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_mesh_quantization.d.ts +4 -1
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js +5 -3
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_texture_basisu.js +11 -3
- package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_texture_transform.js +10 -2
- package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.d.ts +4 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +4 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_audio_emitter.d.ts +23 -7
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js +38 -14
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_lod.d.ts +45 -11
- package/glTF/2.0/Extensions/MSFT_lod.js +44 -8
- package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.d.ts +2 -2
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.d.ts +2 -2
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
- package/glTF/2.0/Extensions/index.js.map +1 -1
- package/glTF/2.0/glTFLoader.d.ts +70 -22
- package/glTF/2.0/glTFLoader.js +180 -93
- package/glTF/2.0/glTFLoader.js.map +1 -1
- package/glTF/2.0/glTFLoaderExtension.d.ts +11 -11
- package/glTF/2.0/glTFLoaderExtension.js.map +1 -1
- package/glTF/2.0/glTFLoaderInterfaces.d.ts +7 -7
- package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -1
- package/glTF/2.0/index.js.map +1 -1
- package/glTF/glTFFileLoader.d.ts +87 -27
- package/glTF/glTFFileLoader.js +102 -45
- package/glTF/glTFFileLoader.js.map +1 -1
- package/glTF/glTFValidation.d.ts +1 -1
- package/glTF/glTFValidation.js +12 -12
- package/glTF/glTFValidation.js.map +1 -1
- package/glTF/index.js.map +1 -1
- package/index.js.map +1 -1
- package/legacy/legacy-glTF.d.ts +2 -2
- package/legacy/legacy-glTF.js +5 -5
- package/legacy/legacy-glTF.js.map +1 -1
- package/legacy/legacy-glTF1.d.ts +1 -1
- package/legacy/legacy-glTF1.js +2 -2
- package/legacy/legacy-glTF1.js.map +1 -1
- package/legacy/legacy-glTF1FileLoader.js +1 -0
- package/legacy/legacy-glTF1FileLoader.js.map +1 -1
- package/legacy/legacy-glTF2.d.ts +1 -1
- package/legacy/legacy-glTF2.js +11 -11
- package/legacy/legacy-glTF2.js.map +1 -1
- package/legacy/legacy-glTF2FileLoader.js +1 -0
- package/legacy/legacy-glTF2FileLoader.js.map +1 -1
- package/legacy/legacy-glTFFileLoader.js +1 -0
- package/legacy/legacy-glTFFileLoader.js.map +1 -1
- package/legacy/legacy-objFileLoader.d.ts +1 -1
- package/legacy/legacy-objFileLoader.js +3 -3
- package/legacy/legacy-objFileLoader.js.map +1 -1
- package/legacy/legacy-stlFileLoader.d.ts +1 -1
- package/legacy/legacy-stlFileLoader.js +3 -3
- package/legacy/legacy-stlFileLoader.js.map +1 -1
- package/legacy/legacy.d.ts +1 -1
- package/legacy/legacy.js +2 -1
- package/legacy/legacy.js.map +1 -1
- package/package.json +23 -198
- package/readme.md +2 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"KHR_materials_pbrSpecularGlossiness.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"KHR_materials_pbrSpecularGlossiness.js","sourceRoot":"","sources":["../../../../../../../lts/loaders/generated/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAC/C,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,IAAM,IAAI,GAAG,qCAAqC,CAAC;AAEnD;;GAEG;AACH;IAkBI;;;OAGG;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AAG,eAAe,CAAC,IAAI,2BAAwB,CAAC;gBAC/D,eAAe,CAAC,mBAAmB,GAAG,OAAO,CAAC;YAClD,CAAC,CAAC,CACL,CAAC;YAEF,eAAe,CAAC,mBAAmB,CAAC,QAAQ,GAAG,IAAI,CAAC;YACpD,eAAe,CAAC,uCAAuC,GAAG,IAAI,CAAC;SAClE;QAED,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,cAAO,CAAC,CAAC,CAAC;IAChD,CAAC;IACL,0CAAC;AAAD,CAAC,AA3FD,IA2FC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,mCAAmC,CAAC,MAAM,CAAC,EAA/C,CAA+C,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Nullable } from \"core/types\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport { Material } from \"core/Materials/material\";\r\n\r\nimport { IMaterial } from \"../glTFLoaderInterfaces\";\r\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport { IKHRMaterialsPbrSpecularGlossiness } from \"babylonjs-gltf2interface\";\r\n\r\nconst NAME = \"KHR_materials_pbrSpecularGlossiness\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)\r\n */\r\nexport class KHR_materials_pbrSpecularGlossiness 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 = 200;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @param loader\r\n * @hidden\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @hidden */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @param context\r\n * @param material\r\n * @param babylonMaterial\r\n * @hidden\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsPbrSpecularGlossiness>(context, material, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loadSpecularGlossinessPropertiesAsync(extensionContext, material, extension, babylonMaterial));\r\n this._loader.loadMaterialAlphaProperties(context, material, babylonMaterial);\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadSpecularGlossinessPropertiesAsync(context: string, material: IMaterial, properties: IKHRMaterialsPbrSpecularGlossiness, babylonMaterial: Material): Promise<void> {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${context}: Material type not supported`);\r\n }\r\n\r\n const promises = new Array<Promise<any>>();\r\n\r\n babylonMaterial.metallic = null;\r\n babylonMaterial.roughness = null;\r\n\r\n if (properties.diffuseFactor) {\r\n babylonMaterial.albedoColor = Color3.FromArray(properties.diffuseFactor);\r\n babylonMaterial.alpha = properties.diffuseFactor[3];\r\n } else {\r\n babylonMaterial.albedoColor = Color3.White();\r\n }\r\n\r\n babylonMaterial.reflectivityColor = properties.specularFactor ? Color3.FromArray(properties.specularFactor) : Color3.White();\r\n babylonMaterial.microSurface = properties.glossinessFactor == undefined ? 1 : properties.glossinessFactor;\r\n\r\n if (properties.diffuseTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/diffuseTexture`, properties.diffuseTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Diffuse)`;\r\n babylonMaterial.albedoTexture = texture;\r\n })\r\n );\r\n }\r\n\r\n if (properties.specularGlossinessTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/specularGlossinessTexture`, properties.specularGlossinessTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Specular Glossiness)`;\r\n babylonMaterial.reflectivityTexture = texture;\r\n })\r\n );\r\n\r\n babylonMaterial.reflectivityTexture.hasAlpha = true;\r\n babylonMaterial.useMicroSurfaceFromReflectivityMapAlpha = true;\r\n }\r\n\r\n return Promise.all(promises).then(() => {});\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_pbrSpecularGlossiness(loader));\r\n"]}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Nullable } from "@babylonjs/core/types";
|
2
|
-
import { Material } from "@babylonjs/core/Materials/material";
|
1
|
+
import { Nullable } from "@babylonjs/core/types.js";
|
2
|
+
import { Material } from "@babylonjs/core/Materials/material.js";
|
3
3
|
import { IMaterial } from "../glTFLoaderInterfaces";
|
4
4
|
import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
|
5
5
|
import { GLTFLoader } from "../glTFLoader";
|
@@ -21,11 +21,19 @@ export declare class KHR_materials_sheen implements IGLTFLoaderExtension {
|
|
21
21
|
*/
|
22
22
|
order: number;
|
23
23
|
private _loader;
|
24
|
-
/**
|
24
|
+
/**
|
25
|
+
* @param loader
|
26
|
+
* @hidden
|
27
|
+
*/
|
25
28
|
constructor(loader: GLTFLoader);
|
26
29
|
/** @hidden */
|
27
30
|
dispose(): void;
|
28
|
-
/**
|
31
|
+
/**
|
32
|
+
* @param context
|
33
|
+
* @param material
|
34
|
+
* @param babylonMaterial
|
35
|
+
* @hidden
|
36
|
+
*/
|
29
37
|
loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
|
30
38
|
private _loadSheenPropertiesAsync;
|
31
39
|
}
|
@@ -1,13 +1,16 @@
|
|
1
1
|
import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
|
2
2
|
import { GLTFLoader } from "../glTFLoader.js";
|
3
|
-
import { Color3 } from
|
3
|
+
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
4
4
|
var NAME = "KHR_materials_sheen";
|
5
5
|
/**
|
6
6
|
* [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
|
7
7
|
* [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
|
8
8
|
*/
|
9
9
|
var KHR_materials_sheen = /** @class */ (function () {
|
10
|
-
/**
|
10
|
+
/**
|
11
|
+
* @param loader
|
12
|
+
* @hidden
|
13
|
+
*/
|
11
14
|
function KHR_materials_sheen(loader) {
|
12
15
|
/**
|
13
16
|
* The name of this extension.
|
@@ -24,7 +27,12 @@ var KHR_materials_sheen = /** @class */ (function () {
|
|
24
27
|
KHR_materials_sheen.prototype.dispose = function () {
|
25
28
|
this._loader = null;
|
26
29
|
};
|
27
|
-
/**
|
30
|
+
/**
|
31
|
+
* @param context
|
32
|
+
* @param material
|
33
|
+
* @param babylonMaterial
|
34
|
+
* @hidden
|
35
|
+
*/
|
28
36
|
KHR_materials_sheen.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
|
29
37
|
var _this = this;
|
30
38
|
return GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"KHR_materials_sheen.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"KHR_materials_sheen.js","sourceRoot":"","sources":["../../../../../../../lts/loaders/generated/glTF/2.0/Extensions/KHR_materials_sheen.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAG/C,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AO,CAAC;YACrD,CAAC,CAAC,CACL,CAAC;SACL;QAED,eAAe,CAAC,KAAK,CAAC,aAAa,GAAG,IAAI,CAAC;QAC3C,eAAe,CAAC,KAAK,CAAC,2BAA2B,GAAG,KAAK,CAAC;QAE1D,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,cAAO,CAAC,CAAC,CAAC;IAChD,CAAC;IACL,0BAAC;AAAD,CAAC,AA7FD,IA6FC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,mBAAmB,CAAC,MAAM,CAAC,EAA/B,CAA+B,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Nullable } from \"core/types\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport { Material } from \"core/Materials/material\";\r\n\r\nimport { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\r\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { IKHRMaterialsSheen } from \"babylonjs-gltf2interface\";\r\n\r\nconst NAME = \"KHR_materials_sheen\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)\r\n * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)\r\n */\r\nexport class KHR_materials_sheen 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 = 190;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @param loader\r\n * @hidden\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @hidden */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @param context\r\n * @param material\r\n * @param babylonMaterial\r\n * @hidden\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsSheen>(context, material, this.name, (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._loadSheenPropertiesAsync(extensionContext, extension, babylonMaterial));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadSheenPropertiesAsync(context: string, properties: IKHRMaterialsSheen, babylonMaterial: Material): Promise<void> {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${context}: Material type not supported`);\r\n }\r\n\r\n const promises = new Array<Promise<any>>();\r\n\r\n babylonMaterial.sheen.isEnabled = true;\r\n babylonMaterial.sheen.intensity = 1;\r\n\r\n if (properties.sheenColorFactor != undefined) {\r\n babylonMaterial.sheen.color = Color3.FromArray(properties.sheenColorFactor);\r\n } else {\r\n babylonMaterial.sheen.color = Color3.Black();\r\n }\r\n\r\n if (properties.sheenColorTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/sheenColorTexture`, properties.sheenColorTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Sheen Color)`;\r\n babylonMaterial.sheen.texture = texture;\r\n })\r\n );\r\n }\r\n\r\n if (properties.sheenRoughnessFactor !== undefined) {\r\n babylonMaterial.sheen.roughness = properties.sheenRoughnessFactor;\r\n } else {\r\n babylonMaterial.sheen.roughness = 0;\r\n }\r\n\r\n if (properties.sheenRoughnessTexture) {\r\n (properties.sheenRoughnessTexture as ITextureInfo).nonColorData = true;\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/sheenRoughnessTexture`, properties.sheenRoughnessTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Sheen Roughness)`;\r\n babylonMaterial.sheen.textureRoughness = texture;\r\n })\r\n );\r\n }\r\n\r\n babylonMaterial.sheen.albedoScaling = true;\r\n babylonMaterial.sheen.useRoughnessFromMainTexture = false;\r\n\r\n return Promise.all(promises).then(() => {});\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_sheen(loader));\r\n"]}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Nullable } from "@babylonjs/core/types";
|
2
|
-
import { Material } from "@babylonjs/core/Materials/material";
|
1
|
+
import { Nullable } from "@babylonjs/core/types.js";
|
2
|
+
import { Material } from "@babylonjs/core/Materials/material.js";
|
3
3
|
import { IMaterial } from "../glTFLoaderInterfaces";
|
4
4
|
import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
|
5
5
|
import { GLTFLoader } from "../glTFLoader";
|
@@ -20,11 +20,19 @@ export declare class KHR_materials_specular implements IGLTFLoaderExtension {
|
|
20
20
|
*/
|
21
21
|
order: number;
|
22
22
|
private _loader;
|
23
|
-
/**
|
23
|
+
/**
|
24
|
+
* @param loader
|
25
|
+
* @hidden
|
26
|
+
*/
|
24
27
|
constructor(loader: GLTFLoader);
|
25
28
|
/** @hidden */
|
26
29
|
dispose(): void;
|
27
|
-
/**
|
30
|
+
/**
|
31
|
+
* @param context
|
32
|
+
* @param material
|
33
|
+
* @param babylonMaterial
|
34
|
+
* @hidden
|
35
|
+
*/
|
28
36
|
loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
|
29
37
|
private _loadSpecularPropertiesAsync;
|
30
38
|
}
|
@@ -1,12 +1,15 @@
|
|
1
1
|
import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
|
2
2
|
import { GLTFLoader } from "../glTFLoader.js";
|
3
|
-
import { Color3 } from
|
3
|
+
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
4
4
|
var NAME = "KHR_materials_specular";
|
5
5
|
/**
|
6
6
|
* [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_specular)
|
7
7
|
*/
|
8
8
|
var KHR_materials_specular = /** @class */ (function () {
|
9
|
-
/**
|
9
|
+
/**
|
10
|
+
* @param loader
|
11
|
+
* @hidden
|
12
|
+
*/
|
10
13
|
function KHR_materials_specular(loader) {
|
11
14
|
/**
|
12
15
|
* The name of this extension.
|
@@ -23,7 +26,12 @@ var KHR_materials_specular = /** @class */ (function () {
|
|
23
26
|
KHR_materials_specular.prototype.dispose = function () {
|
24
27
|
this._loader = null;
|
25
28
|
};
|
26
|
-
/**
|
29
|
+
/**
|
30
|
+
* @param context
|
31
|
+
* @param material
|
32
|
+
* @param babylonMaterial
|
33
|
+
* @hidden
|
34
|
+
*/
|
27
35
|
KHR_materials_specular.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
|
28
36
|
var _this = this;
|
29
37
|
return GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"KHR_materials_specular.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"KHR_materials_specular.js","sourceRoot":"","sources":["../../../../../../../lts/loaders/generated/glTF/2.0/Extensions/KHR_materials_specular.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,4CAA8B;AAG/C,IAAM,IAAI,GAAG,wBAAwB,CAAC;AAEtC;;GAEG;AACH;IAkBI;;;OAGG;IACH,gCAAY,MAAkB;QArB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QASf,IAAI,CAAC,OAAO,GA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AAG,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;SAC/F;QAED,IAAI,UAAU,CAAC,eAAe,EAAE;YAC3B,UAAU,CAAC,eAAgC,CAAC,YAAY,GAAG,IAAI,CAAC;YACjE,QAAQ,CAAC,IAAI,CACT,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,UAAG,OAAO,qBAAkB,EAAE,UAAU,CAAC,eAAe,EAAE,UAAC,OAAO;gBAChG,OAAO,CAAC,IAAI,GAAG,UAAG,eAAe,CAAC,IAAI,4BAAyB,CAAC;gBAChE,eAAe,CAAC,0BAA0B,GAAG,OAAO,CAAC;gBACrD,eAAe,CAAC,6CAA6C,GAAG,IAAI,CAAC;YACzE,CAAC,CAAC,CACL,CAAC;SACL;QAED,IAAI,UAAU,CAAC,oBAAoB,EAAE;YACjC,QAAQ,CAAC,IAAI,CACT,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,UAAG,OAAO,0BAAuB,EAAE,UAAU,CAAC,oBAAoB,EAAE,UAAC,OAAO;gBAC1G,OAAO,CAAC,IAAI,GAAG,UAAG,eAAe,CAAC,IAAI,yBAAsB,CAAC;gBAC7D,eAAe,CAAC,kBAAkB,GAAG,OAAO,CAAC;YACjD,CAAC,CAAC,CACL,CAAC;SACL;QAED,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,cAAO,CAAC,CAAC,CAAC;IAChD,CAAC;IACL,6BAAC;AAAD,CAAC,AApFD,IAoFC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,sBAAsB,CAAC,MAAM,CAAC,EAAlC,CAAkC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Nullable } from \"core/types\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport { Material } from \"core/Materials/material\";\r\n\r\nimport { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\r\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { IKHRMaterialsSpecular } from \"babylonjs-gltf2interface\";\r\n\r\nconst NAME = \"KHR_materials_specular\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_specular)\r\n */\r\nexport class KHR_materials_specular 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 = 190;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @param loader\r\n * @hidden\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @hidden */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @param context\r\n * @param material\r\n * @param babylonMaterial\r\n * @hidden\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsSpecular>(context, material, this.name, (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._loadSpecularPropertiesAsync(extensionContext, extension, babylonMaterial));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadSpecularPropertiesAsync(context: string, properties: IKHRMaterialsSpecular, babylonMaterial: Material): Promise<void> {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${context}: Material type not supported`);\r\n }\r\n\r\n const promises = new Array<Promise<any>>();\r\n\r\n if (properties.specularFactor !== undefined) {\r\n babylonMaterial.metallicF0Factor = properties.specularFactor;\r\n }\r\n\r\n if (properties.specularColorFactor !== undefined) {\r\n babylonMaterial.metallicReflectanceColor = Color3.FromArray(properties.specularColorFactor);\r\n }\r\n\r\n if (properties.specularTexture) {\r\n (properties.specularTexture as ITextureInfo).nonColorData = true;\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/specularTexture`, properties.specularTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Specular F0 Strength)`;\r\n babylonMaterial.metallicReflectanceTexture = texture;\r\n babylonMaterial.useOnlyMetallicFromMetallicReflectanceTexture = true;\r\n })\r\n );\r\n }\r\n\r\n if (properties.specularColorTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/specularColorTexture`, properties.specularColorTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Specular F0 Color)`;\r\n babylonMaterial.reflectanceTexture = texture;\r\n })\r\n );\r\n }\r\n\r\n return Promise.all(promises).then(() => {});\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_specular(loader));\r\n"]}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Nullable } from "@babylonjs/core/types";
|
2
|
-
import { Material } from "@babylonjs/core/Materials/material";
|
1
|
+
import { Nullable } from "@babylonjs/core/types.js";
|
2
|
+
import { Material } from "@babylonjs/core/Materials/material.js";
|
3
3
|
import { IMaterial } from "../glTFLoaderInterfaces";
|
4
4
|
import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
|
5
5
|
import { GLTFLoader } from "../glTFLoader";
|
@@ -21,11 +21,19 @@ export declare class KHR_materials_translucency implements IGLTFLoaderExtension
|
|
21
21
|
*/
|
22
22
|
order: number;
|
23
23
|
private _loader;
|
24
|
-
/**
|
24
|
+
/**
|
25
|
+
* @param loader
|
26
|
+
* @hidden
|
27
|
+
*/
|
25
28
|
constructor(loader: GLTFLoader);
|
26
29
|
/** @hidden */
|
27
30
|
dispose(): void;
|
28
|
-
/**
|
31
|
+
/**
|
32
|
+
* @param context
|
33
|
+
* @param material
|
34
|
+
* @param babylonMaterial
|
35
|
+
* @hidden
|
36
|
+
*/
|
29
37
|
loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
|
30
38
|
private _loadTranslucentPropertiesAsync;
|
31
39
|
}
|
@@ -6,7 +6,10 @@ var NAME = "KHR_materials_translucency";
|
|
6
6
|
* !!! Experimental Extension Subject to Changes !!!
|
7
7
|
*/
|
8
8
|
var KHR_materials_translucency = /** @class */ (function () {
|
9
|
-
/**
|
9
|
+
/**
|
10
|
+
* @param loader
|
11
|
+
* @hidden
|
12
|
+
*/
|
10
13
|
function KHR_materials_translucency(loader) {
|
11
14
|
/**
|
12
15
|
* The name of this extension.
|
@@ -26,7 +29,12 @@ var KHR_materials_translucency = /** @class */ (function () {
|
|
26
29
|
KHR_materials_translucency.prototype.dispose = function () {
|
27
30
|
this._loader = null;
|
28
31
|
};
|
29
|
-
/**
|
32
|
+
/**
|
33
|
+
* @param context
|
34
|
+
* @param material
|
35
|
+
* @param babylonMaterial
|
36
|
+
* @hidden
|
37
|
+
*/
|
30
38
|
KHR_materials_translucency.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
|
31
39
|
var _this = this;
|
32
40
|
return GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
|
@@ -61,8 +69,7 @@ var KHR_materials_translucency = /** @class */ (function () {
|
|
61
69
|
}
|
62
70
|
if (extension.translucencyTexture) {
|
63
71
|
extension.translucencyTexture.nonColorData = true;
|
64
|
-
return this._loader.loadTextureInfoAsync("".concat(context, "/translucencyTexture"), extension.translucencyTexture)
|
65
|
-
.then(function (texture) {
|
72
|
+
return this._loader.loadTextureInfoAsync("".concat(context, "/translucencyTexture"), extension.translucencyTexture).then(function (texture) {
|
66
73
|
pbrMaterial.subSurface.translucencyIntensityTexture = texture;
|
67
74
|
});
|
68
75
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"KHR_materials_translucency.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"KHR_materials_translucency.js","sourceRoot":"","sources":["../../../../../../../lts/loaders/generated/glTF/2.0/Extensions/KHR_materials_translucency.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,IAAM,IAAI,GAAG,4BAA4B,CAAC;AAE1C;;;GAGG;AACH;IAkBI;;;OAGG;IACH,oCAAY,MAAkB;QArB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QASf,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;YACd,MAAM,CAAC,MAAM,CAAC,sBAAsB,GAAG,IAAI,CAAC;SAC/C;IACL,CAAC;IAED,cAAc;IACP,4CAAO,GAAd;QACK,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACI,gEAA2B,GAAlC,UAAmC,OAAe,EAAE,QAAmB,EAAE,eAAyB;QAAlG,iBAQC;QAPG,OAAO,UAAU,CAAC,kBAAkB,CAA4B,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,UAAC,gBAAgB,EAAE,SAAS;YACtH,IAAM,QAAQ,GAAG,IAAI,KAAK,EAAgB,CAAC;YAC3C,QAAQ,CAAC,IAAI,CAAC,KAAI,CAAC,OAAO,CAAC,+BAA+B,CAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC;YAChG,QAAQ,CAAC,IAAI,CAAC,KAAI,CAAC,OAAO,CAAC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E;YAC9B,SAAS,CAAC,mBAAoC,CAAC,YAAY,GAAG,IAAI,CAAC;YACpE,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,UAAG,OAAO,yBAAsB,EAAE,SAAS,CAAC,mBAAmB,CAAC,CAAC,IAAI,CAAC,UAAC,OAAoB;gBAChI,WAAW,CAAC,UAAU,CAAC,4BAA4B,GAAG,OAAO,CAAC;YAClE,CAAC,CAAC,CAAC;SACN;aAAM;YACH,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC5B;IACL,CAAC;IACL,iCAAC;AAAD,CAAC,AAtFD,IAsFC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,0BAA0B,CAAC,MAAM,CAAC,EAAtC,CAAsC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Nullable } from \"core/types\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport { Material } from \"core/Materials/material\";\r\nimport { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\r\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport { IKHRMaterialsTranslucency } from \"babylonjs-gltf2interface\";\r\n\r\nconst NAME = \"KHR_materials_translucency\";\r\n\r\n/**\r\n * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)\r\n * !!! Experimental Extension Subject to Changes !!!\r\n */\r\nexport class KHR_materials_translucency 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 = 174;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @param loader\r\n * @hidden\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 loader.parent.transparencyAsCoverage = true;\r\n }\r\n }\r\n\r\n /** @hidden */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @param context\r\n * @param material\r\n * @param babylonMaterial\r\n * @hidden\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsTranslucency>(context, material, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loadTranslucentPropertiesAsync(extensionContext, material, babylonMaterial, extension));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadTranslucentPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material, extension: IKHRMaterialsTranslucency): Promise<void> {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${context}: Material type not supported`);\r\n }\r\n const pbrMaterial = babylonMaterial as PBRMaterial;\r\n\r\n // Enables \"translucency\" texture which represents diffusely-transmitted light.\r\n pbrMaterial.subSurface.isTranslucencyEnabled = true;\r\n\r\n // Since this extension models thin-surface transmission only, we must make the\r\n // internal IOR == 1.0 and set the thickness to 0.\r\n pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0;\r\n pbrMaterial.subSurface.minimumThickness = 0.0;\r\n pbrMaterial.subSurface.maximumThickness = 0.0;\r\n\r\n // Albedo colour will tint transmission.\r\n pbrMaterial.subSurface.useAlbedoToTintTranslucency = true;\r\n\r\n if (extension.translucencyFactor !== undefined) {\r\n pbrMaterial.subSurface.translucencyIntensity = extension.translucencyFactor;\r\n } else {\r\n pbrMaterial.subSurface.translucencyIntensity = 0.0;\r\n pbrMaterial.subSurface.isTranslucencyEnabled = false;\r\n return Promise.resolve();\r\n }\r\n\r\n if (extension.translucencyTexture) {\r\n (extension.translucencyTexture as ITextureInfo).nonColorData = true;\r\n return this._loader.loadTextureInfoAsync(`${context}/translucencyTexture`, extension.translucencyTexture).then((texture: BaseTexture) => {\r\n pbrMaterial.subSurface.translucencyIntensityTexture = texture;\r\n });\r\n } else {\r\n return Promise.resolve();\r\n }\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_translucency(loader));\r\n"]}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Nullable } from "@babylonjs/core/types";
|
2
|
-
import { Material } from "@babylonjs/core/Materials/material";
|
1
|
+
import { Nullable } from "@babylonjs/core/types.js";
|
2
|
+
import { Material } from "@babylonjs/core/Materials/material.js";
|
3
3
|
import { IMaterial } from "../glTFLoaderInterfaces";
|
4
4
|
import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
|
5
5
|
import { GLTFLoader } from "../glTFLoader";
|
@@ -20,11 +20,19 @@ export declare class KHR_materials_transmission implements IGLTFLoaderExtension
|
|
20
20
|
*/
|
21
21
|
order: number;
|
22
22
|
private _loader;
|
23
|
-
/**
|
23
|
+
/**
|
24
|
+
* @param loader
|
25
|
+
* @hidden
|
26
|
+
*/
|
24
27
|
constructor(loader: GLTFLoader);
|
25
28
|
/** @hidden */
|
26
29
|
dispose(): void;
|
27
|
-
/**
|
30
|
+
/**
|
31
|
+
* @param context
|
32
|
+
* @param material
|
33
|
+
* @param babylonMaterial
|
34
|
+
* @hidden
|
35
|
+
*/
|
28
36
|
loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
|
29
37
|
private _loadTransparentPropertiesAsync;
|
30
38
|
}
|
@@ -20,11 +20,11 @@ var TransmissionHelper = /** @class */ (function () {
|
|
20
20
|
this._opaqueMeshesCache = [];
|
21
21
|
this._transparentMeshesCache = [];
|
22
22
|
this._materialObservers = {};
|
23
|
-
this._options = __assign(__assign({}, TransmissionHelper.
|
23
|
+
this._options = __assign(__assign({}, TransmissionHelper._GetDefaultOptions()), options);
|
24
24
|
this._scene = scene;
|
25
25
|
this._scene._transmissionHelper = this;
|
26
26
|
this.onErrorObservable = new Observable();
|
27
|
-
this._scene.onDisposeObservable.addOnce(function (
|
27
|
+
this._scene.onDisposeObservable.addOnce(function () {
|
28
28
|
_this.dispose();
|
29
29
|
});
|
30
30
|
this._parseScene();
|
@@ -33,7 +33,7 @@ var TransmissionHelper = /** @class */ (function () {
|
|
33
33
|
/**
|
34
34
|
* Creates the default options for the helper.
|
35
35
|
*/
|
36
|
-
TransmissionHelper.
|
36
|
+
TransmissionHelper._GetDefaultOptions = function () {
|
37
37
|
return {
|
38
38
|
renderSize: 1024,
|
39
39
|
samples: 4,
|
@@ -58,7 +58,10 @@ var TransmissionHelper = /** @class */ (function () {
|
|
58
58
|
var oldOptions = this._options;
|
59
59
|
this._options = newOptions;
|
60
60
|
// If size changes, recreate everything
|
61
|
-
if (newOptions.renderSize !== oldOptions.renderSize ||
|
61
|
+
if (newOptions.renderSize !== oldOptions.renderSize ||
|
62
|
+
newOptions.renderTargetTextureType !== oldOptions.renderTargetTextureType ||
|
63
|
+
newOptions.generateMipmaps !== oldOptions.generateMipmaps ||
|
64
|
+
!this._opaqueRenderTarget) {
|
62
65
|
this._setupRenderTargets();
|
63
66
|
}
|
64
67
|
else {
|
@@ -70,11 +73,11 @@ var TransmissionHelper = /** @class */ (function () {
|
|
70
73
|
TransmissionHelper.prototype.getOpaqueTarget = function () {
|
71
74
|
return this._opaqueRenderTarget;
|
72
75
|
};
|
73
|
-
TransmissionHelper.prototype.
|
76
|
+
TransmissionHelper.prototype._shouldRenderAsTransmission = function (material) {
|
74
77
|
if (!material) {
|
75
78
|
return false;
|
76
79
|
}
|
77
|
-
if (material instanceof PBRMaterial &&
|
80
|
+
if (material instanceof PBRMaterial && material.subSurface.isRefractionEnabled) {
|
78
81
|
return true;
|
79
82
|
}
|
80
83
|
return false;
|
@@ -85,7 +88,7 @@ var TransmissionHelper = /** @class */ (function () {
|
|
85
88
|
// we need to defer the processing because _addMesh may be called as part as an instance mesh creation, in which case some
|
86
89
|
// internal properties are not setup yet, like _sourceMesh (needed when doing mesh.material below)
|
87
90
|
Tools.SetImmediate(function () {
|
88
|
-
if (_this.
|
91
|
+
if (_this._shouldRenderAsTransmission(mesh.material)) {
|
89
92
|
mesh.material.refractionTexture = _this._opaqueRenderTarget;
|
90
93
|
_this._transparentMeshesCache.push(mesh);
|
91
94
|
}
|
@@ -118,7 +121,7 @@ var TransmissionHelper = /** @class */ (function () {
|
|
118
121
|
var transparentIdx = this._transparentMeshesCache.indexOf(mesh);
|
119
122
|
var opaqueIdx = this._opaqueMeshesCache.indexOf(mesh);
|
120
123
|
// If the material is transparent, make sure that it's added to the transparent list and removed from the opaque list
|
121
|
-
var useTransmission = this.
|
124
|
+
var useTransmission = this._shouldRenderAsTransmission(mesh.material);
|
122
125
|
if (useTransmission) {
|
123
126
|
if (mesh.material instanceof PBRMaterial) {
|
124
127
|
mesh.material.subSurface.refractionTexture = this._opaqueRenderTarget;
|
@@ -179,7 +182,7 @@ var TransmissionHelper = /** @class */ (function () {
|
|
179
182
|
_this._scene.imageProcessingConfiguration._applyByPostProcess = sceneImageProcessingapplyByPostProcess;
|
180
183
|
});
|
181
184
|
this._transparentMeshesCache.forEach(function (mesh) {
|
182
|
-
if (_this.
|
185
|
+
if (_this._shouldRenderAsTransmission(mesh.material)) {
|
183
186
|
mesh.material.refractionTexture = _this._opaqueRenderTarget;
|
184
187
|
}
|
185
188
|
});
|
@@ -202,8 +205,12 @@ var NAME = "KHR_materials_transmission";
|
|
202
205
|
/**
|
203
206
|
* [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
|
204
207
|
*/
|
208
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
205
209
|
var KHR_materials_transmission = /** @class */ (function () {
|
206
|
-
/**
|
210
|
+
/**
|
211
|
+
* @param loader
|
212
|
+
* @hidden
|
213
|
+
*/
|
207
214
|
function KHR_materials_transmission(loader) {
|
208
215
|
/**
|
209
216
|
* The name of this extension.
|
@@ -223,7 +230,12 @@ var KHR_materials_transmission = /** @class */ (function () {
|
|
223
230
|
KHR_materials_transmission.prototype.dispose = function () {
|
224
231
|
this._loader = null;
|
225
232
|
};
|
226
|
-
/**
|
233
|
+
/**
|
234
|
+
* @param context
|
235
|
+
* @param material
|
236
|
+
* @param babylonMaterial
|
237
|
+
* @hidden
|
238
|
+
*/
|
227
239
|
KHR_materials_transmission.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
|
228
240
|
var _this = this;
|
229
241
|
return GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
|
@@ -261,8 +273,7 @@ var KHR_materials_transmission = /** @class */ (function () {
|
|
261
273
|
pbrMaterial.subSurface.maximumThickness = 0.0;
|
262
274
|
if (extension.transmissionTexture) {
|
263
275
|
extension.transmissionTexture.nonColorData = true;
|
264
|
-
return this._loader.loadTextureInfoAsync("".concat(context, "/transmissionTexture"), extension.transmissionTexture, undefined)
|
265
|
-
.then(function (texture) {
|
276
|
+
return this._loader.loadTextureInfoAsync("".concat(context, "/transmissionTexture"), extension.transmissionTexture, undefined).then(function (texture) {
|
266
277
|
pbrMaterial.subSurface.refractionIntensityTexture = texture;
|
267
278
|
pbrMaterial.subSurface.useGltfStyleTextures = true;
|
268
279
|
});
|