@babylonjs/loaders 5.0.3 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,38 @@
1
+ import type { Nullable } from "@babylonjs/core/types.js";
2
+ import type { Material } from "@babylonjs/core/Materials/material.js";
3
+ import type { IMaterial } from "../glTFLoaderInterfaces";
4
+ import type { IGLTFLoaderExtension } from "../glTFLoaderExtension";
5
+ import { GLTFLoader } from "../glTFLoader";
6
+ /**
7
+ * [Experimental Spec](https://github.com/KhronosGroup/glTF/pull/2027)
8
+ */
9
+ export declare class KHR_materials_iridescence implements IGLTFLoaderExtension {
10
+ /**
11
+ * The name of this extension.
12
+ */
13
+ readonly name = "KHR_materials_iridescence";
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
+ /**
24
+ * @param loader
25
+ * @hidden
26
+ */
27
+ constructor(loader: GLTFLoader);
28
+ /** @hidden */
29
+ dispose(): void;
30
+ /**
31
+ * @param context
32
+ * @param material
33
+ * @param babylonMaterial
34
+ * @hidden
35
+ */
36
+ loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
37
+ private _loadIridescencePropertiesAsync;
38
+ }
@@ -0,0 +1,72 @@
1
+ import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
2
+ import { GLTFLoader } from "../glTFLoader.js";
3
+ var NAME = "KHR_materials_iridescence";
4
+ /**
5
+ * [Experimental Spec](https://github.com/KhronosGroup/glTF/pull/2027)
6
+ */
7
+ var KHR_materials_iridescence = /** @class */ (function () {
8
+ /**
9
+ * @param loader
10
+ * @hidden
11
+ */
12
+ function KHR_materials_iridescence(loader) {
13
+ /**
14
+ * The name of this extension.
15
+ */
16
+ this.name = NAME;
17
+ /**
18
+ * Defines a number that determines the order the extensions are applied.
19
+ */
20
+ this.order = 195;
21
+ this._loader = loader;
22
+ this.enabled = this._loader.isExtensionUsed(NAME);
23
+ }
24
+ /** @hidden */
25
+ KHR_materials_iridescence.prototype.dispose = function () {
26
+ this._loader = null;
27
+ };
28
+ /**
29
+ * @param context
30
+ * @param material
31
+ * @param babylonMaterial
32
+ * @hidden
33
+ */
34
+ KHR_materials_iridescence.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
35
+ var _this = this;
36
+ return GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
37
+ var promises = new Array();
38
+ promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
39
+ promises.push(_this._loadIridescencePropertiesAsync(extensionContext, extension, babylonMaterial));
40
+ return Promise.all(promises).then(function () { });
41
+ });
42
+ };
43
+ KHR_materials_iridescence.prototype._loadIridescencePropertiesAsync = function (context, properties, babylonMaterial) {
44
+ var _a, _b, _c, _d;
45
+ if (!(babylonMaterial instanceof PBRMaterial)) {
46
+ throw new Error("".concat(context, ": Material type not supported"));
47
+ }
48
+ var promises = new Array();
49
+ babylonMaterial.iridescence.isEnabled = true;
50
+ babylonMaterial.iridescence.intensity = (_a = properties.iridescenceFactor) !== null && _a !== void 0 ? _a : 0;
51
+ babylonMaterial.iridescence.indexOfRefraction = (_b = properties.iridescenceIOR) !== null && _b !== void 0 ? _b : 1.3;
52
+ babylonMaterial.iridescence.minimumThickness = (_c = properties.iridescenceThicknessMinimum) !== null && _c !== void 0 ? _c : 100;
53
+ babylonMaterial.iridescence.maximumThickness = (_d = properties.iridescenceThicknessMaximum) !== null && _d !== void 0 ? _d : 400;
54
+ if (properties.iridescenceTexture) {
55
+ promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/iridescenceTexture"), properties.iridescenceTexture, function (texture) {
56
+ texture.name = "".concat(babylonMaterial.name, " (Iridescence Intensity)");
57
+ babylonMaterial.iridescence.texture = texture;
58
+ }));
59
+ }
60
+ if (properties.iridescenceThicknessTexture) {
61
+ promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/iridescenceThicknessTexture"), properties.iridescenceThicknessTexture, function (texture) {
62
+ texture.name = "".concat(babylonMaterial.name, " (Iridescence Thickness)");
63
+ babylonMaterial.iridescence.thicknessTexture = texture;
64
+ }));
65
+ }
66
+ return Promise.all(promises).then(function () { });
67
+ };
68
+ return KHR_materials_iridescence;
69
+ }());
70
+ export { KHR_materials_iridescence };
71
+ GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_iridescence(loader); });
72
+ //# sourceMappingURL=KHR_materials_iridescence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KHR_materials_iridescence.js","sourceRoot":"","sources":["../../../../../../../lts/loaders/generated/glTF/2.0/Extensions/KHR_materials_iridescence.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,IAAM,IAAI,GAAG,2BAA2B,CAAC;AAEzC;;GAEG;AACH;IAkBI;;;OAGG;IACH,mCAAY,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;IACtD,CAAC;IAED,cAAc;IACP,2CAAO,GAAd;QACK,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACI,+DAA2B,GAAlC,UAAmC,OAAe,EAAE,QAAmB,EAAE,eAAyB;QAAlG,iBAOC;QANG,OAAO,UAAU,CAAC,kBAAkB,CAA2B,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,UAAC,gBAAgB,EAAE,SAAS;YACrH,IAAM,QAAQ,GAAG,IAAI,KAAK,EAAgB,CAAC;YAC3C,QAAQ,CAAC,IAAI,CAAC,KAA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AC,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC;YAClD,CAAC,CAAC,CACL,CAAC;SACL;QAED,IAAI,UAAU,CAAC,2BAA2B,EAAE;YACxC,QAAQ,CAAC,IAAI,CACT,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,UAAG,OAAO,iCAA8B,EAAE,UAAU,CAAC,2BAA2B,EAAE,UAAC,OAAO;gBACxH,OAAO,CAAC,IAAI,GAAG,UAAG,eAAe,CAAC,IAAI,6BAA0B,CAAC;gBACjE,eAAe,CAAC,WAAW,CAAC,gBAAgB,GAAG,OAAO,CAAC;YAC3D,CAAC,CAAC,CACL,CAAC;SACL;QAED,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,cAAO,CAAC,CAAC,CAAC;IAChD,CAAC;IACL,gCAAC;AAAD,CAAC,AAjFD,IAiFC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,yBAAyB,CAAC,MAAM,CAAC,EAArC,CAAqC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"core/types\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { Material } from \"core/Materials/material\";\r\n\r\nimport type { IMaterial } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRMaterialsIridescence } from \"babylonjs-gltf2interface\";\r\n\r\nconst NAME = \"KHR_materials_iridescence\";\r\n\r\n/**\r\n * [Experimental Spec](https://github.com/KhronosGroup/glTF/pull/2027)\r\n */\r\nexport class KHR_materials_iridescence 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 = 195;\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<IKHRMaterialsIridescence>(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._loadIridescencePropertiesAsync(extensionContext, extension, babylonMaterial));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadIridescencePropertiesAsync(context: string, properties: IKHRMaterialsIridescence, 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.iridescence.isEnabled = true;\r\n\r\n babylonMaterial.iridescence.intensity = properties.iridescenceFactor ?? 0;\r\n babylonMaterial.iridescence.indexOfRefraction = properties.iridescenceIOR ?? 1.3;\r\n babylonMaterial.iridescence.minimumThickness = properties.iridescenceThicknessMinimum ?? 100;\r\n babylonMaterial.iridescence.maximumThickness = properties.iridescenceThicknessMaximum ?? 400;\r\n\r\n if (properties.iridescenceTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/iridescenceTexture`, properties.iridescenceTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Iridescence Intensity)`;\r\n babylonMaterial.iridescence.texture = texture;\r\n })\r\n );\r\n }\r\n\r\n if (properties.iridescenceThicknessTexture) {\r\n promises.push(\r\n this._loader.loadTextureInfoAsync(`${context}/iridescenceThicknessTexture`, properties.iridescenceThicknessTexture, (texture) => {\r\n texture.name = `${babylonMaterial.name} (Iridescence Thickness)`;\r\n babylonMaterial.iridescence.thicknessTexture = 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_iridescence(loader));\r\n"]}
@@ -7,6 +7,7 @@ export * from "./KHR_lights_punctual";
7
7
  export * from "./KHR_materials_pbrSpecularGlossiness";
8
8
  export * from "./KHR_materials_unlit";
9
9
  export * from "./KHR_materials_clearcoat";
10
+ export * from "./KHR_materials_iridescence";
10
11
  export * from "./KHR_materials_emissive_strength";
11
12
  export * from "./KHR_materials_sheen";
12
13
  export * from "./KHR_materials_specular";
@@ -7,6 +7,7 @@ export * from "./KHR_lights_punctual.js";
7
7
  export * from "./KHR_materials_pbrSpecularGlossiness.js";
8
8
  export * from "./KHR_materials_unlit.js";
9
9
  export * from "./KHR_materials_clearcoat.js";
10
+ export * from "./KHR_materials_iridescence.js";
10
11
  export * from "./KHR_materials_emissive_strength.js";
11
12
  export * from "./KHR_materials_sheen.js";
12
13
  export * from "./KHR_materials_specular.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../lts/loaders/generated/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uCAAuC,CAAC;AACtD,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./EXT_lights_image_based\";\r\nexport * from \"./EXT_mesh_gpu_instancing\";\r\nexport * from \"./EXT_meshopt_compression\";\r\nexport * from \"./EXT_texture_webp\";\r\nexport * from \"./KHR_draco_mesh_compression\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./KHR_materials_pbrSpecularGlossiness\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_emissive_strength\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_variants\";\r\nexport * from \"./KHR_materials_transmission\";\r\nexport * from \"./KHR_materials_translucency\";\r\nexport * from \"./KHR_materials_volume\";\r\nexport * from \"./KHR_mesh_quantization\";\r\nexport * from \"./KHR_texture_basisu\";\r\nexport * from \"./KHR_texture_transform\";\r\nexport * from \"./KHR_xmp_json_ld\";\r\nexport * from \"./MSFT_audio_emitter\";\r\nexport * from \"./MSFT_lod\";\r\nexport * from \"./MSFT_minecraftMesh\";\r\nexport * from \"./MSFT_sRGBFactors\";\r\nexport * from \"./ExtrasAsMetadata\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../lts/loaders/generated/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uCAAuC,CAAC;AACtD,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./EXT_lights_image_based\";\r\nexport * from \"./EXT_mesh_gpu_instancing\";\r\nexport * from \"./EXT_meshopt_compression\";\r\nexport * from \"./EXT_texture_webp\";\r\nexport * from \"./KHR_draco_mesh_compression\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./KHR_materials_pbrSpecularGlossiness\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_iridescence\";\r\nexport * from \"./KHR_materials_emissive_strength\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_variants\";\r\nexport * from \"./KHR_materials_transmission\";\r\nexport * from \"./KHR_materials_translucency\";\r\nexport * from \"./KHR_materials_volume\";\r\nexport * from \"./KHR_mesh_quantization\";\r\nexport * from \"./KHR_texture_basisu\";\r\nexport * from \"./KHR_texture_transform\";\r\nexport * from \"./KHR_xmp_json_ld\";\r\nexport * from \"./MSFT_audio_emitter\";\r\nexport * from \"./MSFT_lod\";\r\nexport * from \"./MSFT_minecraftMesh\";\r\nexport * from \"./MSFT_sRGBFactors\";\r\nexport * from \"./ExtrasAsMetadata\";\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs/loaders",
3
- "version": "5.0.3",
3
+ "version": "5.2.0",
4
4
  "main": "index.js",
5
5
  "module": "index.js",
6
6
  "types": "index.d.ts",
@@ -19,8 +19,8 @@
19
19
  "prepublishOnly": "build-tools -c prepare-es6-build"
20
20
  },
21
21
  "dependencies": {
22
- "@babylonjs/core": "^5.0.3",
23
- "babylonjs-gltf2interface": "^5.0.3",
22
+ "@babylonjs/core": "^5.2.0",
23
+ "babylonjs-gltf2interface": "^5.2.0",
24
24
  "tslib": "^2.3.1"
25
25
  },
26
26
  "devDependencies": {