@babylonjs/loaders 5.0.0-beta.8 → 5.0.0-beta.8-snapshot
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +20 -198
- package/OBJ/index.d.ts +0 -4
- package/OBJ/index.js +0 -5
- package/OBJ/index.js.map +0 -1
- package/OBJ/mtlFileLoader.d.ts +0 -40
- package/OBJ/mtlFileLoader.js +0 -222
- package/OBJ/mtlFileLoader.js.map +0 -1
- package/OBJ/objFileLoader.d.ts +0 -133
- package/OBJ/objFileLoader.js +0 -301
- package/OBJ/objFileLoader.js.map +0 -1
- package/OBJ/objLoadingOptions.d.ts +0 -43
- package/OBJ/objLoadingOptions.js +0 -2
- package/OBJ/objLoadingOptions.js.map +0 -1
- package/OBJ/solidParser.d.ts +0 -153
- package/OBJ/solidParser.js +0 -700
- package/OBJ/solidParser.js.map +0 -1
- package/STL/index.d.ts +0 -1
- package/STL/index.js +0 -2
- package/STL/index.js.map +0 -1
- package/STL/stlFileLoader.d.ts +0 -71
- package/STL/stlFileLoader.js +0 -240
- package/STL/stlFileLoader.js.map +0 -1
- package/glTF/1.0/glTFBinaryExtension.d.ts +0 -13
- package/glTF/1.0/glTFBinaryExtension.js +0 -62
- package/glTF/1.0/glTFBinaryExtension.js.map +0 -1
- package/glTF/1.0/glTFLoader.d.ts +0 -106
- package/glTF/1.0/glTFLoader.js +0 -1697
- package/glTF/1.0/glTFLoader.js.map +0 -1
- package/glTF/1.0/glTFLoaderInterfaces.d.ts +0 -412
- package/glTF/1.0/glTFLoaderInterfaces.js +0 -96
- package/glTF/1.0/glTFLoaderInterfaces.js.map +0 -1
- package/glTF/1.0/glTFLoaderUtils.d.ts +0 -62
- package/glTF/1.0/glTFLoaderUtils.js +0 -233
- package/glTF/1.0/glTFLoaderUtils.js.map +0 -1
- package/glTF/1.0/glTFMaterialsCommonExtension.d.ts +0 -10
- package/glTF/1.0/glTFMaterialsCommonExtension.js +0 -128
- package/glTF/1.0/glTFMaterialsCommonExtension.js.map +0 -1
- package/glTF/1.0/index.d.ts +0 -5
- package/glTF/1.0/index.js +0 -6
- package/glTF/1.0/index.js.map +0 -1
- package/glTF/2.0/Extensions/EXT_lights_image_based.d.ts +0 -36
- package/glTF/2.0/Extensions/EXT_lights_image_based.js +0 -111
- package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +0 -1
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +0 -27
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +0 -80
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +0 -1
- package/glTF/2.0/Extensions/EXT_meshopt_compression.d.ts +0 -27
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js +0 -43
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +0 -1
- package/glTF/2.0/Extensions/EXT_texture_webp.d.ts +0 -21
- package/glTF/2.0/Extensions/EXT_texture_webp.js +0 -33
- package/glTF/2.0/Extensions/EXT_texture_webp.js.map +0 -1
- package/glTF/2.0/Extensions/ExtrasAsMetadata.d.ts +0 -32
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js +0 -56
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.d.ts +0 -31
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +0 -102
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +0 -28
- package/glTF/2.0/Extensions/KHR_lights_punctual.js +0 -82
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +0 -31
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +0 -87
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +0 -30
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +0 -46
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +0 -34
- package/glTF/2.0/Extensions/KHR_materials_ior.js +0 -55
- package/glTF/2.0/Extensions/KHR_materials_ior.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.d.ts +0 -30
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +0 -73
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +0 -31
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +0 -77
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +0 -30
- package/glTF/2.0/Extensions/KHR_materials_specular.js +0 -67
- package/glTF/2.0/Extensions/KHR_materials_specular.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_materials_translucency.d.ts +0 -31
- package/glTF/2.0/Extensions/KHR_materials_translucency.js +0 -77
- package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +0 -30
- package/glTF/2.0/Extensions/KHR_materials_transmission.js +0 -278
- package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +0 -30
- package/glTF/2.0/Extensions/KHR_materials_unlit.js +0 -66
- package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_materials_variants.d.ts +0 -76
- package/glTF/2.0/Extensions/KHR_materials_variants.js +0 -244
- package/glTF/2.0/Extensions/KHR_materials_variants.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +0 -31
- package/glTF/2.0/Extensions/KHR_materials_volume.js +0 -79
- package/glTF/2.0/Extensions/KHR_materials_volume.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_mesh_quantization.d.ts +0 -19
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js +0 -22
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +0 -21
- package/glTF/2.0/Extensions/KHR_texture_basisu.js +0 -33
- package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +0 -25
- package/glTF/2.0/Extensions/KHR_texture_transform.js +0 -54
- package/glTF/2.0/Extensions/KHR_texture_transform.js.map +0 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.d.ts +0 -29
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +0 -47
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +0 -1
- package/glTF/2.0/Extensions/MSFT_audio_emitter.d.ts +0 -38
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js +0 -217
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +0 -1
- package/glTF/2.0/Extensions/MSFT_lod.d.ts +0 -75
- package/glTF/2.0/Extensions/MSFT_lod.js +0 -334
- package/glTF/2.0/Extensions/MSFT_lod.js.map +0 -1
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.d.ts +0 -14
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +0 -37
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +0 -1
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.d.ts +0 -14
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +0 -37
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +0 -1
- package/glTF/2.0/Extensions/index.d.ts +0 -26
- package/glTF/2.0/Extensions/index.js +0 -27
- package/glTF/2.0/Extensions/index.js.map +0 -1
- package/glTF/2.0/glTFLoader.d.ts +0 -357
- package/glTF/2.0/glTFLoader.js +0 -2249
- package/glTF/2.0/glTFLoader.js.map +0 -1
- package/glTF/2.0/glTFLoaderExtension.d.ts +0 -152
- package/glTF/2.0/glTFLoaderExtension.js +0 -2
- package/glTF/2.0/glTFLoaderExtension.js.map +0 -1
- package/glTF/2.0/glTFLoaderInterfaces.d.ts +0 -209
- package/glTF/2.0/glTFLoaderInterfaces.js +0 -2
- package/glTF/2.0/glTFLoaderInterfaces.js.map +0 -1
- package/glTF/2.0/index.d.ts +0 -4
- package/glTF/2.0/index.js +0 -5
- package/glTF/2.0/index.js.map +0 -1
- package/glTF/glTFFileLoader.d.ts +0 -368
- package/glTF/glTFFileLoader.js +0 -869
- package/glTF/glTFFileLoader.js.map +0 -1
- package/glTF/glTFValidation.d.ts +0 -29
- package/glTF/glTFValidation.js +0 -122
- package/glTF/glTFValidation.js.map +0 -1
- package/glTF/index.d.ts +0 -5
- package/glTF/index.js +0 -6
- package/glTF/index.js.map +0 -1
- package/index.d.ts +0 -3
- package/index.js.map +0 -1
- package/legacy/legacy-glTF.d.ts +0 -2
- package/legacy/legacy-glTF.js +0 -19
- package/legacy/legacy-glTF.js.map +0 -1
- package/legacy/legacy-glTF1.d.ts +0 -2
- package/legacy/legacy-glTF1.js +0 -15
- package/legacy/legacy-glTF1.js.map +0 -1
- package/legacy/legacy-glTF1FileLoader.d.ts +0 -2
- package/legacy/legacy-glTF1FileLoader.js +0 -3
- package/legacy/legacy-glTF1FileLoader.js.map +0 -1
- package/legacy/legacy-glTF2.d.ts +0 -2
- package/legacy/legacy-glTF2.js +0 -33
- package/legacy/legacy-glTF2.js.map +0 -1
- package/legacy/legacy-glTF2FileLoader.d.ts +0 -2
- package/legacy/legacy-glTF2FileLoader.js +0 -3
- package/legacy/legacy-glTF2FileLoader.js.map +0 -1
- package/legacy/legacy-glTFFileLoader.d.ts +0 -3
- package/legacy/legacy-glTFFileLoader.js +0 -4
- package/legacy/legacy-glTFFileLoader.js.map +0 -1
- package/legacy/legacy-objFileLoader.d.ts +0 -1
- package/legacy/legacy-objFileLoader.js +0 -13
- package/legacy/legacy-objFileLoader.js.map +0 -1
- package/legacy/legacy-stlFileLoader.d.ts +0 -1
- package/legacy/legacy-stlFileLoader.js +0 -13
- package/legacy/legacy-stlFileLoader.js.map +0 -1
- package/legacy/legacy.d.ts +0 -6
- package/legacy/legacy.js +0 -7
- package/legacy/legacy.js.map +0 -1
- package/readme.md +0 -24
@@ -1,77 +0,0 @@
|
|
1
|
-
import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
|
2
|
-
import { GLTFLoader } from "../glTFLoader.js";
|
3
|
-
import { Color3 } from '@babylonjs/core/Maths/math.color.js';
|
4
|
-
var NAME = "KHR_materials_sheen";
|
5
|
-
/**
|
6
|
-
* [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
|
7
|
-
* [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
|
8
|
-
*/
|
9
|
-
var KHR_materials_sheen = /** @class */ (function () {
|
10
|
-
/** @hidden */
|
11
|
-
function KHR_materials_sheen(loader) {
|
12
|
-
/**
|
13
|
-
* The name of this extension.
|
14
|
-
*/
|
15
|
-
this.name = NAME;
|
16
|
-
/**
|
17
|
-
* Defines a number that determines the order the extensions are applied.
|
18
|
-
*/
|
19
|
-
this.order = 190;
|
20
|
-
this._loader = loader;
|
21
|
-
this.enabled = this._loader.isExtensionUsed(NAME);
|
22
|
-
}
|
23
|
-
/** @hidden */
|
24
|
-
KHR_materials_sheen.prototype.dispose = function () {
|
25
|
-
this._loader = null;
|
26
|
-
};
|
27
|
-
/** @hidden */
|
28
|
-
KHR_materials_sheen.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
|
29
|
-
var _this = this;
|
30
|
-
return GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
|
31
|
-
var promises = new Array();
|
32
|
-
promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
|
33
|
-
promises.push(_this._loadSheenPropertiesAsync(extensionContext, extension, babylonMaterial));
|
34
|
-
return Promise.all(promises).then(function () { });
|
35
|
-
});
|
36
|
-
};
|
37
|
-
KHR_materials_sheen.prototype._loadSheenPropertiesAsync = function (context, properties, babylonMaterial) {
|
38
|
-
if (!(babylonMaterial instanceof PBRMaterial)) {
|
39
|
-
throw new Error("".concat(context, ": Material type not supported"));
|
40
|
-
}
|
41
|
-
var promises = new Array();
|
42
|
-
babylonMaterial.sheen.isEnabled = true;
|
43
|
-
babylonMaterial.sheen.intensity = 1;
|
44
|
-
if (properties.sheenColorFactor != undefined) {
|
45
|
-
babylonMaterial.sheen.color = Color3.FromArray(properties.sheenColorFactor);
|
46
|
-
}
|
47
|
-
else {
|
48
|
-
babylonMaterial.sheen.color = Color3.Black();
|
49
|
-
}
|
50
|
-
if (properties.sheenColorTexture) {
|
51
|
-
promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/sheenColorTexture"), properties.sheenColorTexture, function (texture) {
|
52
|
-
texture.name = "".concat(babylonMaterial.name, " (Sheen Color)");
|
53
|
-
babylonMaterial.sheen.texture = texture;
|
54
|
-
}));
|
55
|
-
}
|
56
|
-
if (properties.sheenRoughnessFactor !== undefined) {
|
57
|
-
babylonMaterial.sheen.roughness = properties.sheenRoughnessFactor;
|
58
|
-
}
|
59
|
-
else {
|
60
|
-
babylonMaterial.sheen.roughness = 0;
|
61
|
-
}
|
62
|
-
if (properties.sheenRoughnessTexture) {
|
63
|
-
properties.sheenRoughnessTexture.nonColorData = true;
|
64
|
-
promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/sheenRoughnessTexture"), properties.sheenRoughnessTexture, function (texture) {
|
65
|
-
texture.name = "".concat(babylonMaterial.name, " (Sheen Roughness)");
|
66
|
-
babylonMaterial.sheen.textureRoughness = texture;
|
67
|
-
}));
|
68
|
-
}
|
69
|
-
babylonMaterial.sheen.albedoScaling = true;
|
70
|
-
babylonMaterial.sheen.useRoughnessFromMainTexture = false;
|
71
|
-
return Promise.all(promises).then(function () { });
|
72
|
-
};
|
73
|
-
return KHR_materials_sheen;
|
74
|
-
}());
|
75
|
-
export { KHR_materials_sheen };
|
76
|
-
GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_sheen(loader); });
|
77
|
-
//# sourceMappingURL=KHR_materials_sheen.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"KHR_materials_sheen.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/KHR_materials_sheen.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAKxE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAG1D,IAAM,IAAI,GAAG,qBAAqB,CAAC;AAEnC;;;GAGG;AACH;IAkBI,cAAc;IACd,6BAAY,MAAkB;QAlB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QAMf,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,cAAc;IACP,qCAAO,GAAd;QACK,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED,cAAc;IACP,yDAA2B,GAAlC,UAAmC,OAAe,EAAE,QAAmB,EAAE,eAAyB;QAAlG,iBAOC;QANG,OAAO,UAAU,CAAC,kBAAkB,CAAqB,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,UAAC,gBAAgB,EAAE,SAAS;YAC/G,IAAM,QAAQ,GAAG,IAAI,KAAK,EAAgB,CAAC;YAC3C,QAAQ,CAAC,IAAI,CAAC,KAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC;YA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AAC,SAAS,GAAG,UAAU,CAAC,oBAAoB,CAAC;SACrE;aAAM;YACH,eAAe,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;SACvC;QAED,IAAI,UAAU,CAAC,qBAAqB,EAAE;YACjC,UAAU,CAAC,qBAAsC,CAAC,YAAY,GAAG,IAAI,CAAC;YACvE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,UAAG,OAAO,2BAAwB,EAAE,UAAU,CAAC,qBAAqB,EAAE,UAAC,OAAO;gBAC1H,OAAO,CAAC,IAAI,GAAG,UAAG,eAAe,CAAC,IAAI,uBAAoB,CAAC;gBAC3D,eAAe,CAAC,KAAK,CAAC,gBAAgB,GAAG,OAAO,CAAC;YACrD,CAAC,CAAC,CAAC,CAAC;SACP;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,cAAQ,CAAC,CAAC,CAAC;IACjD,CAAC;IACL,0BAAC;AAAD,CAAC,AAlFD,IAkFC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,mBAAmB,CAAC,MAAM,CAAC,EAA/B,CAA+B,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { PBRMaterial } from \"@babylonjs/core/Materials/PBR/pbrMaterial\";\nimport { Material } from \"@babylonjs/core/Materials/material\";\n\nimport { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { GLTFLoader } from \"../glTFLoader\";\nimport { Color3 } from '@babylonjs/core/Maths/math.color';\nimport { IKHRMaterialsSheen } from 'babylonjs-gltf2interface';\n\nconst NAME = \"KHR_materials_sheen\";\n\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)\n * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)\n */\nexport class KHR_materials_sheen implements IGLTFLoaderExtension {\n /**\n * The name of this extension.\n */\n public readonly name = NAME;\n\n /**\n * Defines whether this extension is enabled.\n */\n public enabled: boolean;\n\n /**\n * Defines a number that determines the order the extensions are applied.\n */\n public order = 190;\n\n private _loader: GLTFLoader;\n\n /** @hidden */\n constructor(loader: GLTFLoader) {\n this._loader = loader;\n this.enabled = this._loader.isExtensionUsed(NAME);\n }\n\n /** @hidden */\n public dispose() {\n (this._loader as any) = null;\n }\n\n /** @hidden */\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsSheen>(context, material, this.name, (extensionContext, extension) => {\n const promises = new Array<Promise<any>>();\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\n promises.push(this._loadSheenPropertiesAsync(extensionContext, extension, babylonMaterial));\n return Promise.all(promises).then(() => { });\n });\n }\n\n private _loadSheenPropertiesAsync(context: string, properties: IKHRMaterialsSheen, babylonMaterial: Material): Promise<void> {\n if (!(babylonMaterial instanceof PBRMaterial)) {\n throw new Error(`${context}: Material type not supported`);\n }\n\n const promises = new Array<Promise<any>>();\n\n babylonMaterial.sheen.isEnabled = true;\n babylonMaterial.sheen.intensity = 1;\n\n if (properties.sheenColorFactor != undefined) {\n babylonMaterial.sheen.color = Color3.FromArray(properties.sheenColorFactor);\n }\n else {\n babylonMaterial.sheen.color = Color3.Black();\n }\n\n if (properties.sheenColorTexture) {\n promises.push(this._loader.loadTextureInfoAsync(`${context}/sheenColorTexture`, properties.sheenColorTexture, (texture) => {\n texture.name = `${babylonMaterial.name} (Sheen Color)`;\n babylonMaterial.sheen.texture = texture;\n }));\n }\n\n if (properties.sheenRoughnessFactor !== undefined) {\n babylonMaterial.sheen.roughness = properties.sheenRoughnessFactor;\n } else {\n babylonMaterial.sheen.roughness = 0;\n }\n\n if (properties.sheenRoughnessTexture) {\n (properties.sheenRoughnessTexture as ITextureInfo).nonColorData = true;\n promises.push(this._loader.loadTextureInfoAsync(`${context}/sheenRoughnessTexture`, properties.sheenRoughnessTexture, (texture) => {\n texture.name = `${babylonMaterial.name} (Sheen Roughness)`;\n babylonMaterial.sheen.textureRoughness = texture;\n }));\n }\n\n babylonMaterial.sheen.albedoScaling = true;\n babylonMaterial.sheen.useRoughnessFromMainTexture = false;\n\n return Promise.all(promises).then(() => { });\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_sheen(loader));"]}
|
@@ -1,30 +0,0 @@
|
|
1
|
-
import { Nullable } from "@babylonjs/core/types";
|
2
|
-
import { Material } from "@babylonjs/core/Materials/material";
|
3
|
-
import { IMaterial } from "../glTFLoaderInterfaces";
|
4
|
-
import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
|
5
|
-
import { GLTFLoader } from "../glTFLoader";
|
6
|
-
/**
|
7
|
-
* [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_specular)
|
8
|
-
*/
|
9
|
-
export declare class KHR_materials_specular implements IGLTFLoaderExtension {
|
10
|
-
/**
|
11
|
-
* The name of this extension.
|
12
|
-
*/
|
13
|
-
readonly name = "KHR_materials_specular";
|
14
|
-
/**
|
15
|
-
* Defines whether this extension is enabled.
|
16
|
-
*/
|
17
|
-
enabled: boolean;
|
18
|
-
/**
|
19
|
-
* Defines a number that determines the order the extensions are applied.
|
20
|
-
*/
|
21
|
-
order: number;
|
22
|
-
private _loader;
|
23
|
-
/** @hidden */
|
24
|
-
constructor(loader: GLTFLoader);
|
25
|
-
/** @hidden */
|
26
|
-
dispose(): void;
|
27
|
-
/** @hidden */
|
28
|
-
loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
|
29
|
-
private _loadSpecularPropertiesAsync;
|
30
|
-
}
|
@@ -1,67 +0,0 @@
|
|
1
|
-
import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
|
2
|
-
import { GLTFLoader } from "../glTFLoader.js";
|
3
|
-
import { Color3 } from '@babylonjs/core/Maths/math.color.js';
|
4
|
-
var NAME = "KHR_materials_specular";
|
5
|
-
/**
|
6
|
-
* [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_specular)
|
7
|
-
*/
|
8
|
-
var KHR_materials_specular = /** @class */ (function () {
|
9
|
-
/** @hidden */
|
10
|
-
function KHR_materials_specular(loader) {
|
11
|
-
/**
|
12
|
-
* The name of this extension.
|
13
|
-
*/
|
14
|
-
this.name = NAME;
|
15
|
-
/**
|
16
|
-
* Defines a number that determines the order the extensions are applied.
|
17
|
-
*/
|
18
|
-
this.order = 190;
|
19
|
-
this._loader = loader;
|
20
|
-
this.enabled = this._loader.isExtensionUsed(NAME);
|
21
|
-
}
|
22
|
-
/** @hidden */
|
23
|
-
KHR_materials_specular.prototype.dispose = function () {
|
24
|
-
this._loader = null;
|
25
|
-
};
|
26
|
-
/** @hidden */
|
27
|
-
KHR_materials_specular.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
|
28
|
-
var _this = this;
|
29
|
-
return GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
|
30
|
-
var promises = new Array();
|
31
|
-
promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
|
32
|
-
promises.push(_this._loadSpecularPropertiesAsync(extensionContext, extension, babylonMaterial));
|
33
|
-
return Promise.all(promises).then(function () { });
|
34
|
-
});
|
35
|
-
};
|
36
|
-
KHR_materials_specular.prototype._loadSpecularPropertiesAsync = function (context, properties, babylonMaterial) {
|
37
|
-
if (!(babylonMaterial instanceof PBRMaterial)) {
|
38
|
-
throw new Error("".concat(context, ": Material type not supported"));
|
39
|
-
}
|
40
|
-
var promises = new Array();
|
41
|
-
if (properties.specularFactor !== undefined) {
|
42
|
-
babylonMaterial.metallicF0Factor = properties.specularFactor;
|
43
|
-
}
|
44
|
-
if (properties.specularColorFactor !== undefined) {
|
45
|
-
babylonMaterial.metallicReflectanceColor = Color3.FromArray(properties.specularColorFactor);
|
46
|
-
}
|
47
|
-
if (properties.specularTexture) {
|
48
|
-
properties.specularTexture.nonColorData = true;
|
49
|
-
promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/specularTexture"), properties.specularTexture, function (texture) {
|
50
|
-
texture.name = "".concat(babylonMaterial.name, " (Specular F0 Strength)");
|
51
|
-
babylonMaterial.metallicReflectanceTexture = texture;
|
52
|
-
babylonMaterial.useOnlyMetallicFromMetallicReflectanceTexture = true;
|
53
|
-
}));
|
54
|
-
}
|
55
|
-
if (properties.specularColorTexture) {
|
56
|
-
promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/specularColorTexture"), properties.specularColorTexture, function (texture) {
|
57
|
-
texture.name = "".concat(babylonMaterial.name, " (Specular F0 Color)");
|
58
|
-
babylonMaterial.reflectanceTexture = texture;
|
59
|
-
}));
|
60
|
-
}
|
61
|
-
return Promise.all(promises).then(function () { });
|
62
|
-
};
|
63
|
-
return KHR_materials_specular;
|
64
|
-
}());
|
65
|
-
export { KHR_materials_specular };
|
66
|
-
GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_specular(loader); });
|
67
|
-
//# sourceMappingURL=KHR_materials_specular.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"KHR_materials_specular.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/KHR_materials_specular.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAKxE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAG1D,IAA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C,MAAM,CAAC,EAAlC,CAAkC,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { PBRMaterial } from \"@babylonjs/core/Materials/PBR/pbrMaterial\";\nimport { Material } from \"@babylonjs/core/Materials/material\";\n\nimport { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { GLTFLoader } from \"../glTFLoader\";\nimport { Color3 } from '@babylonjs/core/Maths/math.color';\nimport { IKHRMaterialsSpecular } from 'babylonjs-gltf2interface';\n\nconst NAME = \"KHR_materials_specular\";\n\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_specular)\n */\nexport class KHR_materials_specular implements IGLTFLoaderExtension {\n /**\n * The name of this extension.\n */\n public readonly name = NAME;\n\n /**\n * Defines whether this extension is enabled.\n */\n public enabled: boolean;\n\n /**\n * Defines a number that determines the order the extensions are applied.\n */\n public order = 190;\n\n private _loader: GLTFLoader;\n\n /** @hidden */\n constructor(loader: GLTFLoader) {\n this._loader = loader;\n this.enabled = this._loader.isExtensionUsed(NAME);\n }\n\n /** @hidden */\n public dispose() {\n (this._loader as any) = null;\n }\n\n /** @hidden */\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsSpecular>(context, material, this.name, (extensionContext, extension) => {\n const promises = new Array<Promise<any>>();\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\n promises.push(this._loadSpecularPropertiesAsync(extensionContext, extension, babylonMaterial));\n return Promise.all(promises).then(() => { });\n });\n }\n\n private _loadSpecularPropertiesAsync(context: string, properties: IKHRMaterialsSpecular, babylonMaterial: Material): Promise<void> {\n if (!(babylonMaterial instanceof PBRMaterial)) {\n throw new Error(`${context}: Material type not supported`);\n }\n\n const promises = new Array<Promise<any>>();\n\n if (properties.specularFactor !== undefined) {\n babylonMaterial.metallicF0Factor = properties.specularFactor;\n }\n\n if (properties.specularColorFactor !== undefined) {\n babylonMaterial.metallicReflectanceColor = Color3.FromArray(properties.specularColorFactor);\n }\n\n if (properties.specularTexture) {\n (properties.specularTexture as ITextureInfo).nonColorData = true;\n promises.push(this._loader.loadTextureInfoAsync(`${context}/specularTexture`, properties.specularTexture, (texture) => {\n texture.name = `${babylonMaterial.name} (Specular F0 Strength)`;\n babylonMaterial.metallicReflectanceTexture = texture;\n babylonMaterial.useOnlyMetallicFromMetallicReflectanceTexture = true;\n }));\n }\n\n if (properties.specularColorTexture) {\n promises.push(this._loader.loadTextureInfoAsync(`${context}/specularColorTexture`, properties.specularColorTexture, (texture) => {\n texture.name = `${babylonMaterial.name} (Specular F0 Color)`;\n babylonMaterial.reflectanceTexture = texture;\n }));\n }\n\n return Promise.all(promises).then(() => { });\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_specular(loader));"]}
|
@@ -1,31 +0,0 @@
|
|
1
|
-
import { Nullable } from "@babylonjs/core/types";
|
2
|
-
import { Material } from "@babylonjs/core/Materials/material";
|
3
|
-
import { IMaterial } from "../glTFLoaderInterfaces";
|
4
|
-
import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
|
5
|
-
import { GLTFLoader } from "../glTFLoader";
|
6
|
-
/**
|
7
|
-
* [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
|
8
|
-
* !!! Experimental Extension Subject to Changes !!!
|
9
|
-
*/
|
10
|
-
export declare class KHR_materials_translucency implements IGLTFLoaderExtension {
|
11
|
-
/**
|
12
|
-
* The name of this extension.
|
13
|
-
*/
|
14
|
-
readonly name = "KHR_materials_translucency";
|
15
|
-
/**
|
16
|
-
* Defines whether this extension is enabled.
|
17
|
-
*/
|
18
|
-
enabled: boolean;
|
19
|
-
/**
|
20
|
-
* Defines a number that determines the order the extensions are applied.
|
21
|
-
*/
|
22
|
-
order: number;
|
23
|
-
private _loader;
|
24
|
-
/** @hidden */
|
25
|
-
constructor(loader: GLTFLoader);
|
26
|
-
/** @hidden */
|
27
|
-
dispose(): void;
|
28
|
-
/** @hidden */
|
29
|
-
loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
|
30
|
-
private _loadTranslucentPropertiesAsync;
|
31
|
-
}
|
@@ -1,77 +0,0 @@
|
|
1
|
-
import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
|
2
|
-
import { GLTFLoader } from "../glTFLoader.js";
|
3
|
-
var NAME = "KHR_materials_translucency";
|
4
|
-
/**
|
5
|
-
* [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
|
6
|
-
* !!! Experimental Extension Subject to Changes !!!
|
7
|
-
*/
|
8
|
-
var KHR_materials_translucency = /** @class */ (function () {
|
9
|
-
/** @hidden */
|
10
|
-
function KHR_materials_translucency(loader) {
|
11
|
-
/**
|
12
|
-
* The name of this extension.
|
13
|
-
*/
|
14
|
-
this.name = NAME;
|
15
|
-
/**
|
16
|
-
* Defines a number that determines the order the extensions are applied.
|
17
|
-
*/
|
18
|
-
this.order = 174;
|
19
|
-
this._loader = loader;
|
20
|
-
this.enabled = this._loader.isExtensionUsed(NAME);
|
21
|
-
if (this.enabled) {
|
22
|
-
loader.parent.transparencyAsCoverage = true;
|
23
|
-
}
|
24
|
-
}
|
25
|
-
/** @hidden */
|
26
|
-
KHR_materials_translucency.prototype.dispose = function () {
|
27
|
-
this._loader = null;
|
28
|
-
};
|
29
|
-
/** @hidden */
|
30
|
-
KHR_materials_translucency.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
|
31
|
-
var _this = this;
|
32
|
-
return GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
|
33
|
-
var promises = new Array();
|
34
|
-
promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));
|
35
|
-
promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
|
36
|
-
promises.push(_this._loadTranslucentPropertiesAsync(extensionContext, material, babylonMaterial, extension));
|
37
|
-
return Promise.all(promises).then(function () { });
|
38
|
-
});
|
39
|
-
};
|
40
|
-
KHR_materials_translucency.prototype._loadTranslucentPropertiesAsync = function (context, material, babylonMaterial, extension) {
|
41
|
-
if (!(babylonMaterial instanceof PBRMaterial)) {
|
42
|
-
throw new Error("".concat(context, ": Material type not supported"));
|
43
|
-
}
|
44
|
-
var pbrMaterial = babylonMaterial;
|
45
|
-
// Enables "translucency" texture which represents diffusely-transmitted light.
|
46
|
-
pbrMaterial.subSurface.isTranslucencyEnabled = true;
|
47
|
-
// Since this extension models thin-surface transmission only, we must make the
|
48
|
-
// internal IOR == 1.0 and set the thickness to 0.
|
49
|
-
pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0;
|
50
|
-
pbrMaterial.subSurface.minimumThickness = 0.0;
|
51
|
-
pbrMaterial.subSurface.maximumThickness = 0.0;
|
52
|
-
// Albedo colour will tint transmission.
|
53
|
-
pbrMaterial.subSurface.useAlbedoToTintTranslucency = true;
|
54
|
-
if (extension.translucencyFactor !== undefined) {
|
55
|
-
pbrMaterial.subSurface.translucencyIntensity = extension.translucencyFactor;
|
56
|
-
}
|
57
|
-
else {
|
58
|
-
pbrMaterial.subSurface.translucencyIntensity = 0.0;
|
59
|
-
pbrMaterial.subSurface.isTranslucencyEnabled = false;
|
60
|
-
return Promise.resolve();
|
61
|
-
}
|
62
|
-
if (extension.translucencyTexture) {
|
63
|
-
extension.translucencyTexture.nonColorData = true;
|
64
|
-
return this._loader.loadTextureInfoAsync("".concat(context, "/translucencyTexture"), extension.translucencyTexture)
|
65
|
-
.then(function (texture) {
|
66
|
-
pbrMaterial.subSurface.translucencyIntensityTexture = texture;
|
67
|
-
});
|
68
|
-
}
|
69
|
-
else {
|
70
|
-
return Promise.resolve();
|
71
|
-
}
|
72
|
-
};
|
73
|
-
return KHR_materials_translucency;
|
74
|
-
}());
|
75
|
-
export { KHR_materials_translucency };
|
76
|
-
GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_translucency(loader); });
|
77
|
-
//# sourceMappingURL=KHR_materials_translucency.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"KHR_materials_translucency.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/KHR_materials_translucency.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAKxE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,IAAM,IAAI,GAAG,4BAA4B,CAAC;AAE1C;;;GAGG;AACH;IAkBI,cAAc;IACd,oCAAY,MAAkB;QAlB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QAMf,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,cAAc;IACP,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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O,EAAE,CAAC;SAC5B;QAED,IAAI,SAAS,CAAC,mBAAmB,EAAE;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;iBACpG,IAAI,CAAC,UAAC,OAAoB;gBACvB,WAAW,CAAC,UAAU,CAAC,4BAA4B,GAAG,OAAO,CAAC;YAClE,CAAC,CAAC,CAAC;SACV;aAAM;YACH,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC5B;IACL,CAAC;IACL,iCAAC;AAAD,CAAC,AA/ED,IA+EC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,0BAA0B,CAAC,MAAM,CAAC,EAAtC,CAAsC,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { PBRMaterial } from \"@babylonjs/core/Materials/PBR/pbrMaterial\";\nimport { Material } from \"@babylonjs/core/Materials/material\";\nimport { BaseTexture } from \"@babylonjs/core/Materials/Textures/baseTexture\";\nimport { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { GLTFLoader } from \"../glTFLoader\";\nimport { IKHRMaterialsTranslucency } from 'babylonjs-gltf2interface';\n\nconst NAME = \"KHR_materials_translucency\";\n\n/**\n * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)\n * !!! Experimental Extension Subject to Changes !!!\n */\nexport class KHR_materials_translucency implements IGLTFLoaderExtension {\n /**\n * The name of this extension.\n */\n public readonly name = NAME;\n\n /**\n * Defines whether this extension is enabled.\n */\n public enabled: boolean;\n\n /**\n * Defines a number that determines the order the extensions are applied.\n */\n public order = 174;\n\n private _loader: GLTFLoader;\n\n /** @hidden */\n constructor(loader: GLTFLoader) {\n this._loader = loader;\n this.enabled = this._loader.isExtensionUsed(NAME);\n if (this.enabled) {\n loader.parent.transparencyAsCoverage = true;\n }\n }\n\n /** @hidden */\n public dispose() {\n (this._loader as any) = null;\n }\n\n /** @hidden */\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsTranslucency>(context, material, this.name, (extensionContext, extension) => {\n const promises = new Array<Promise<any>>();\n promises.push(this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\n promises.push(this._loadTranslucentPropertiesAsync(extensionContext, material, babylonMaterial, extension));\n return Promise.all(promises).then(() => { });\n });\n }\n\n private _loadTranslucentPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material, extension: IKHRMaterialsTranslucency): Promise<void> {\n if (!(babylonMaterial instanceof PBRMaterial)) {\n throw new Error(`${context}: Material type not supported`);\n }\n const pbrMaterial = babylonMaterial as PBRMaterial;\n\n // Enables \"translucency\" texture which represents diffusely-transmitted light.\n pbrMaterial.subSurface.isTranslucencyEnabled = true;\n\n // Since this extension models thin-surface transmission only, we must make the\n // internal IOR == 1.0 and set the thickness to 0.\n pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0;\n pbrMaterial.subSurface.minimumThickness = 0.0;\n pbrMaterial.subSurface.maximumThickness = 0.0;\n\n // Albedo colour will tint transmission.\n pbrMaterial.subSurface.useAlbedoToTintTranslucency = true;\n\n if (extension.translucencyFactor !== undefined) {\n pbrMaterial.subSurface.translucencyIntensity = extension.translucencyFactor;\n } else {\n pbrMaterial.subSurface.translucencyIntensity = 0.0;\n pbrMaterial.subSurface.isTranslucencyEnabled = false;\n return Promise.resolve();\n }\n\n if (extension.translucencyTexture) {\n (extension.translucencyTexture as ITextureInfo).nonColorData = true;\n return this._loader.loadTextureInfoAsync(`${context}/translucencyTexture`, extension.translucencyTexture)\n .then((texture: BaseTexture) => {\n pbrMaterial.subSurface.translucencyIntensityTexture = texture;\n });\n } else {\n return Promise.resolve();\n }\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_translucency(loader));\n"]}
|
@@ -1,30 +0,0 @@
|
|
1
|
-
import { Nullable } from "@babylonjs/core/types";
|
2
|
-
import { Material } from "@babylonjs/core/Materials/material";
|
3
|
-
import { IMaterial } from "../glTFLoaderInterfaces";
|
4
|
-
import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
|
5
|
-
import { GLTFLoader } from "../glTFLoader";
|
6
|
-
/**
|
7
|
-
* [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
|
8
|
-
*/
|
9
|
-
export declare class KHR_materials_transmission implements IGLTFLoaderExtension {
|
10
|
-
/**
|
11
|
-
* The name of this extension.
|
12
|
-
*/
|
13
|
-
readonly name = "KHR_materials_transmission";
|
14
|
-
/**
|
15
|
-
* Defines whether this extension is enabled.
|
16
|
-
*/
|
17
|
-
enabled: boolean;
|
18
|
-
/**
|
19
|
-
* Defines a number that determines the order the extensions are applied.
|
20
|
-
*/
|
21
|
-
order: number;
|
22
|
-
private _loader;
|
23
|
-
/** @hidden */
|
24
|
-
constructor(loader: GLTFLoader);
|
25
|
-
/** @hidden */
|
26
|
-
dispose(): void;
|
27
|
-
/** @hidden */
|
28
|
-
loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
|
29
|
-
private _loadTransparentPropertiesAsync;
|
30
|
-
}
|
@@ -1,278 +0,0 @@
|
|
1
|
-
import { __assign } from "tslib";
|
2
|
-
import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
|
3
|
-
import { GLTFLoader } from "../glTFLoader.js";
|
4
|
-
import { RenderTargetTexture } from "@babylonjs/core/Materials/Textures/renderTargetTexture.js";
|
5
|
-
import { Observable } from "@babylonjs/core/Misc/observable.js";
|
6
|
-
import { Constants } from "@babylonjs/core/Engines/constants.js";
|
7
|
-
import { Tools } from "@babylonjs/core/Misc/tools.js";
|
8
|
-
/**
|
9
|
-
* A class to handle setting up the rendering of opaque objects to be shown through transmissive objects.
|
10
|
-
*/
|
11
|
-
var TransmissionHelper = /** @class */ (function () {
|
12
|
-
/**
|
13
|
-
* constructor
|
14
|
-
* @param options Defines the options we want to customize the helper
|
15
|
-
* @param scene The scene to add the material to
|
16
|
-
*/
|
17
|
-
function TransmissionHelper(options, scene) {
|
18
|
-
var _this = this;
|
19
|
-
this._opaqueRenderTarget = null;
|
20
|
-
this._opaqueMeshesCache = [];
|
21
|
-
this._transparentMeshesCache = [];
|
22
|
-
this._materialObservers = {};
|
23
|
-
this._options = __assign(__assign({}, TransmissionHelper._getDefaultOptions()), options);
|
24
|
-
this._scene = scene;
|
25
|
-
this._scene._transmissionHelper = this;
|
26
|
-
this.onErrorObservable = new Observable();
|
27
|
-
this._scene.onDisposeObservable.addOnce(function (scene) {
|
28
|
-
_this.dispose();
|
29
|
-
});
|
30
|
-
this._parseScene();
|
31
|
-
this._setupRenderTargets();
|
32
|
-
}
|
33
|
-
/**
|
34
|
-
* Creates the default options for the helper.
|
35
|
-
*/
|
36
|
-
TransmissionHelper._getDefaultOptions = function () {
|
37
|
-
return {
|
38
|
-
renderSize: 1024,
|
39
|
-
samples: 4,
|
40
|
-
lodGenerationScale: 1,
|
41
|
-
lodGenerationOffset: -4,
|
42
|
-
renderTargetTextureType: Constants.TEXTURETYPE_HALF_FLOAT,
|
43
|
-
generateMipmaps: true,
|
44
|
-
};
|
45
|
-
};
|
46
|
-
/**
|
47
|
-
* Updates the background according to the new options
|
48
|
-
* @param options
|
49
|
-
*/
|
50
|
-
TransmissionHelper.prototype.updateOptions = function (options) {
|
51
|
-
var _this = this;
|
52
|
-
// First check if any options are actually being changed. If not, exit.
|
53
|
-
var newValues = Object.keys(options).filter(function (key) { return _this._options[key] !== options[key]; });
|
54
|
-
if (!newValues.length) {
|
55
|
-
return;
|
56
|
-
}
|
57
|
-
var newOptions = __assign(__assign({}, this._options), options);
|
58
|
-
var oldOptions = this._options;
|
59
|
-
this._options = newOptions;
|
60
|
-
// If size changes, recreate everything
|
61
|
-
if (newOptions.renderSize !== oldOptions.renderSize || newOptions.renderTargetTextureType !== oldOptions.renderTargetTextureType || newOptions.generateMipmaps !== oldOptions.generateMipmaps || !this._opaqueRenderTarget) {
|
62
|
-
this._setupRenderTargets();
|
63
|
-
}
|
64
|
-
else {
|
65
|
-
this._opaqueRenderTarget.samples = newOptions.samples;
|
66
|
-
this._opaqueRenderTarget.lodGenerationScale = newOptions.lodGenerationScale;
|
67
|
-
this._opaqueRenderTarget.lodGenerationOffset = newOptions.lodGenerationOffset;
|
68
|
-
}
|
69
|
-
};
|
70
|
-
TransmissionHelper.prototype.getOpaqueTarget = function () {
|
71
|
-
return this._opaqueRenderTarget;
|
72
|
-
};
|
73
|
-
TransmissionHelper.prototype.shouldRenderAsTransmission = function (material) {
|
74
|
-
if (!material) {
|
75
|
-
return false;
|
76
|
-
}
|
77
|
-
if (material instanceof PBRMaterial && (material.subSurface.isRefractionEnabled)) {
|
78
|
-
return true;
|
79
|
-
}
|
80
|
-
return false;
|
81
|
-
};
|
82
|
-
TransmissionHelper.prototype._addMesh = function (mesh) {
|
83
|
-
var _this = this;
|
84
|
-
this._materialObservers[mesh.uniqueId] = mesh.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this));
|
85
|
-
// we need to defer the processing because _addMesh may be called as part as an instance mesh creation, in which case some
|
86
|
-
// internal properties are not setup yet, like _sourceMesh (needed when doing mesh.material below)
|
87
|
-
Tools.SetImmediate(function () {
|
88
|
-
if (_this.shouldRenderAsTransmission(mesh.material)) {
|
89
|
-
mesh.material.refractionTexture = _this._opaqueRenderTarget;
|
90
|
-
_this._transparentMeshesCache.push(mesh);
|
91
|
-
}
|
92
|
-
else {
|
93
|
-
_this._opaqueMeshesCache.push(mesh);
|
94
|
-
}
|
95
|
-
});
|
96
|
-
};
|
97
|
-
TransmissionHelper.prototype._removeMesh = function (mesh) {
|
98
|
-
mesh.onMaterialChangedObservable.remove(this._materialObservers[mesh.uniqueId]);
|
99
|
-
delete this._materialObservers[mesh.uniqueId];
|
100
|
-
var idx = this._transparentMeshesCache.indexOf(mesh);
|
101
|
-
if (idx !== -1) {
|
102
|
-
this._transparentMeshesCache.splice(idx, 1);
|
103
|
-
}
|
104
|
-
idx = this._opaqueMeshesCache.indexOf(mesh);
|
105
|
-
if (idx !== -1) {
|
106
|
-
this._opaqueMeshesCache.splice(idx, 1);
|
107
|
-
}
|
108
|
-
};
|
109
|
-
TransmissionHelper.prototype._parseScene = function () {
|
110
|
-
this._scene.meshes.forEach(this._addMesh.bind(this));
|
111
|
-
// Listen for when a mesh is added to the scene and add it to our cache lists.
|
112
|
-
this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this));
|
113
|
-
// Listen for when a mesh is removed from to the scene and remove it from our cache lists.
|
114
|
-
this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this));
|
115
|
-
};
|
116
|
-
// When one of the meshes in the scene has its material changed, make sure that it's in the correct cache list.
|
117
|
-
TransmissionHelper.prototype._onMeshMaterialChanged = function (mesh) {
|
118
|
-
var transparentIdx = this._transparentMeshesCache.indexOf(mesh);
|
119
|
-
var opaqueIdx = this._opaqueMeshesCache.indexOf(mesh);
|
120
|
-
// 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.shouldRenderAsTransmission(mesh.material);
|
122
|
-
if (useTransmission) {
|
123
|
-
if (mesh.material instanceof PBRMaterial) {
|
124
|
-
mesh.material.subSurface.refractionTexture = this._opaqueRenderTarget;
|
125
|
-
}
|
126
|
-
if (opaqueIdx !== -1) {
|
127
|
-
this._opaqueMeshesCache.splice(opaqueIdx, 1);
|
128
|
-
this._transparentMeshesCache.push(mesh);
|
129
|
-
}
|
130
|
-
else if (transparentIdx === -1) {
|
131
|
-
this._transparentMeshesCache.push(mesh);
|
132
|
-
}
|
133
|
-
// If the material is opaque, make sure that it's added to the opaque list and removed from the transparent list
|
134
|
-
}
|
135
|
-
else {
|
136
|
-
if (transparentIdx !== -1) {
|
137
|
-
this._transparentMeshesCache.splice(transparentIdx, 1);
|
138
|
-
this._opaqueMeshesCache.push(mesh);
|
139
|
-
}
|
140
|
-
else if (opaqueIdx === -1) {
|
141
|
-
this._opaqueMeshesCache.push(mesh);
|
142
|
-
}
|
143
|
-
}
|
144
|
-
};
|
145
|
-
/**
|
146
|
-
* Setup the render targets according to the specified options.
|
147
|
-
*/
|
148
|
-
TransmissionHelper.prototype._setupRenderTargets = function () {
|
149
|
-
var _this = this;
|
150
|
-
var _a, _b;
|
151
|
-
if (this._opaqueRenderTarget) {
|
152
|
-
this._opaqueRenderTarget.dispose();
|
153
|
-
}
|
154
|
-
this._opaqueRenderTarget = new RenderTargetTexture("opaqueSceneTexture", this._options.renderSize, this._scene, this._options.generateMipmaps, undefined, this._options.renderTargetTextureType);
|
155
|
-
this._opaqueRenderTarget.ignoreCameraViewport = true;
|
156
|
-
this._opaqueRenderTarget.renderList = this._opaqueMeshesCache;
|
157
|
-
this._opaqueRenderTarget.clearColor = (_b = (_a = this._options.clearColor) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : this._scene.clearColor.clone();
|
158
|
-
this._opaqueRenderTarget.gammaSpace = false;
|
159
|
-
this._opaqueRenderTarget.lodGenerationScale = this._options.lodGenerationScale;
|
160
|
-
this._opaqueRenderTarget.lodGenerationOffset = this._options.lodGenerationOffset;
|
161
|
-
this._opaqueRenderTarget.samples = this._options.samples;
|
162
|
-
var sceneImageProcessingapplyByPostProcess;
|
163
|
-
var saveSceneEnvIntensity;
|
164
|
-
this._opaqueRenderTarget.onBeforeBindObservable.add(function (opaqueRenderTarget) {
|
165
|
-
saveSceneEnvIntensity = _this._scene.environmentIntensity;
|
166
|
-
_this._scene.environmentIntensity = 1.0;
|
167
|
-
sceneImageProcessingapplyByPostProcess = _this._scene.imageProcessingConfiguration.applyByPostProcess;
|
168
|
-
if (!_this._options.clearColor) {
|
169
|
-
_this._scene.clearColor.toLinearSpaceToRef(opaqueRenderTarget.clearColor);
|
170
|
-
}
|
171
|
-
else {
|
172
|
-
opaqueRenderTarget.clearColor.copyFrom(_this._options.clearColor);
|
173
|
-
}
|
174
|
-
// we do not use the applyByPostProcess setter to avoid flagging all the materials as "image processing dirty"!
|
175
|
-
_this._scene.imageProcessingConfiguration._applyByPostProcess = true;
|
176
|
-
});
|
177
|
-
this._opaqueRenderTarget.onAfterUnbindObservable.add(function () {
|
178
|
-
_this._scene.environmentIntensity = saveSceneEnvIntensity;
|
179
|
-
_this._scene.imageProcessingConfiguration._applyByPostProcess = sceneImageProcessingapplyByPostProcess;
|
180
|
-
});
|
181
|
-
this._transparentMeshesCache.forEach(function (mesh) {
|
182
|
-
if (_this.shouldRenderAsTransmission(mesh.material)) {
|
183
|
-
mesh.material.refractionTexture = _this._opaqueRenderTarget;
|
184
|
-
}
|
185
|
-
});
|
186
|
-
};
|
187
|
-
/**
|
188
|
-
* Dispose all the elements created by the Helper.
|
189
|
-
*/
|
190
|
-
TransmissionHelper.prototype.dispose = function () {
|
191
|
-
this._scene._transmissionHelper = undefined;
|
192
|
-
if (this._opaqueRenderTarget) {
|
193
|
-
this._opaqueRenderTarget.dispose();
|
194
|
-
this._opaqueRenderTarget = null;
|
195
|
-
}
|
196
|
-
this._transparentMeshesCache = [];
|
197
|
-
this._opaqueMeshesCache = [];
|
198
|
-
};
|
199
|
-
return TransmissionHelper;
|
200
|
-
}());
|
201
|
-
var NAME = "KHR_materials_transmission";
|
202
|
-
/**
|
203
|
-
* [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
|
204
|
-
*/
|
205
|
-
var KHR_materials_transmission = /** @class */ (function () {
|
206
|
-
/** @hidden */
|
207
|
-
function KHR_materials_transmission(loader) {
|
208
|
-
/**
|
209
|
-
* The name of this extension.
|
210
|
-
*/
|
211
|
-
this.name = NAME;
|
212
|
-
/**
|
213
|
-
* Defines a number that determines the order the extensions are applied.
|
214
|
-
*/
|
215
|
-
this.order = 175;
|
216
|
-
this._loader = loader;
|
217
|
-
this.enabled = this._loader.isExtensionUsed(NAME);
|
218
|
-
if (this.enabled) {
|
219
|
-
loader.parent.transparencyAsCoverage = true;
|
220
|
-
}
|
221
|
-
}
|
222
|
-
/** @hidden */
|
223
|
-
KHR_materials_transmission.prototype.dispose = function () {
|
224
|
-
this._loader = null;
|
225
|
-
};
|
226
|
-
/** @hidden */
|
227
|
-
KHR_materials_transmission.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
|
228
|
-
var _this = this;
|
229
|
-
return GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
|
230
|
-
var promises = new Array();
|
231
|
-
promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));
|
232
|
-
promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
|
233
|
-
promises.push(_this._loadTransparentPropertiesAsync(extensionContext, material, babylonMaterial, extension));
|
234
|
-
return Promise.all(promises).then(function () { });
|
235
|
-
});
|
236
|
-
};
|
237
|
-
KHR_materials_transmission.prototype._loadTransparentPropertiesAsync = function (context, material, babylonMaterial, extension) {
|
238
|
-
if (!(babylonMaterial instanceof PBRMaterial)) {
|
239
|
-
throw new Error("".concat(context, ": Material type not supported"));
|
240
|
-
}
|
241
|
-
var pbrMaterial = babylonMaterial;
|
242
|
-
// Enables "refraction" texture which represents transmitted light.
|
243
|
-
pbrMaterial.subSurface.isRefractionEnabled = true;
|
244
|
-
// Since this extension models thin-surface transmission only, we must make IOR = 1.0
|
245
|
-
pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0;
|
246
|
-
// Albedo colour will tint transmission.
|
247
|
-
pbrMaterial.subSurface.useAlbedoToTintRefraction = true;
|
248
|
-
if (extension.transmissionFactor !== undefined) {
|
249
|
-
pbrMaterial.subSurface.refractionIntensity = extension.transmissionFactor;
|
250
|
-
var scene = pbrMaterial.getScene();
|
251
|
-
if (pbrMaterial.subSurface.refractionIntensity && !scene._transmissionHelper) {
|
252
|
-
new TransmissionHelper({}, pbrMaterial.getScene());
|
253
|
-
}
|
254
|
-
}
|
255
|
-
else {
|
256
|
-
pbrMaterial.subSurface.refractionIntensity = 0.0;
|
257
|
-
pbrMaterial.subSurface.isRefractionEnabled = false;
|
258
|
-
return Promise.resolve();
|
259
|
-
}
|
260
|
-
pbrMaterial.subSurface.minimumThickness = 0.0;
|
261
|
-
pbrMaterial.subSurface.maximumThickness = 0.0;
|
262
|
-
if (extension.transmissionTexture) {
|
263
|
-
extension.transmissionTexture.nonColorData = true;
|
264
|
-
return this._loader.loadTextureInfoAsync("".concat(context, "/transmissionTexture"), extension.transmissionTexture, undefined)
|
265
|
-
.then(function (texture) {
|
266
|
-
pbrMaterial.subSurface.refractionIntensityTexture = texture;
|
267
|
-
pbrMaterial.subSurface.useGltfStyleTextures = true;
|
268
|
-
});
|
269
|
-
}
|
270
|
-
else {
|
271
|
-
return Promise.resolve();
|
272
|
-
}
|
273
|
-
};
|
274
|
-
return KHR_materials_transmission;
|
275
|
-
}());
|
276
|
-
export { KHR_materials_transmission };
|
277
|
-
GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_transmission(loader); });
|
278
|
-
//# sourceMappingURL=KHR_materials_transmission.js.map
|