@babylonjs/serializers 8.6.0 → 8.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,24 @@
1
+ import type { IMaterial } from "babylonjs-gltf2interface";
2
+ import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
3
+ import { GLTFExporter } from "../glTFExporter.js";
4
+ import type { Material } from "@babylonjs/core/Materials/material.js";
5
+ import type { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
6
+ /**
7
+ * @internal
8
+ */
9
+ export declare class EXT_materials_diffuse_roughness implements IGLTFExporterExtensionV2 {
10
+ /** Name of this extension */
11
+ readonly name = "EXT_materials_diffuse_roughness";
12
+ /** Defines whether this extension is enabled */
13
+ enabled: boolean;
14
+ /** Defines whether this extension is required */
15
+ required: boolean;
16
+ private _exporter;
17
+ private _wasUsed;
18
+ constructor(exporter: GLTFExporter);
19
+ dispose(): void;
20
+ /** @internal */
21
+ get wasUsed(): boolean;
22
+ postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
23
+ postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
24
+ }
@@ -0,0 +1,60 @@
1
+ import { GLTFExporter } from "../glTFExporter.js";
2
+ import { PBRBaseMaterial } from "@babylonjs/core/Materials/PBR/pbrBaseMaterial.js";
3
+ const NAME = "EXT_materials_diffuse_roughness";
4
+ /**
5
+ * @internal
6
+ */
7
+ // eslint-disable-next-line @typescript-eslint/naming-convention
8
+ export class EXT_materials_diffuse_roughness {
9
+ constructor(exporter) {
10
+ /** Name of this extension */
11
+ this.name = NAME;
12
+ /** Defines whether this extension is enabled */
13
+ this.enabled = true;
14
+ /** Defines whether this extension is required */
15
+ this.required = false;
16
+ this._wasUsed = false;
17
+ this._exporter = exporter;
18
+ }
19
+ dispose() { }
20
+ /** @internal */
21
+ get wasUsed() {
22
+ return this._wasUsed;
23
+ }
24
+ postExportMaterialAdditionalTextures(context, node, babylonMaterial) {
25
+ const additionalTextures = [];
26
+ if (babylonMaterial instanceof PBRBaseMaterial) {
27
+ if (babylonMaterial._baseDiffuseRoughness) {
28
+ if (babylonMaterial._baseDiffuseRoughnessTexture) {
29
+ additionalTextures.push(babylonMaterial._baseDiffuseRoughnessTexture);
30
+ }
31
+ return additionalTextures;
32
+ }
33
+ }
34
+ return [];
35
+ }
36
+ postExportMaterialAsync(context, node, babylonMaterial) {
37
+ return new Promise((resolve) => {
38
+ if (babylonMaterial instanceof PBRBaseMaterial) {
39
+ if (!babylonMaterial._baseDiffuseRoughness) {
40
+ resolve(node);
41
+ return;
42
+ }
43
+ this._wasUsed = true;
44
+ node.extensions = node.extensions || {};
45
+ const diffuseRoughnessTextureInfo = this._exporter._materialExporter.getTextureInfo(babylonMaterial._baseDiffuseRoughnessTexture);
46
+ const diffuseRoughnessInfo = {
47
+ diffuseRoughnessFactor: babylonMaterial._baseDiffuseRoughness,
48
+ diffuseRoughnessTexture: diffuseRoughnessTextureInfo ?? undefined,
49
+ };
50
+ if (diffuseRoughnessInfo.diffuseRoughnessTexture !== null) {
51
+ this._exporter._materialNeedsUVsSet.add(babylonMaterial);
52
+ }
53
+ node.extensions[NAME] = diffuseRoughnessInfo;
54
+ }
55
+ resolve(node);
56
+ });
57
+ }
58
+ }
59
+ GLTFExporter.RegisterExtension(NAME, (exporter) => new EXT_materials_diffuse_roughness(exporter));
60
+ //# sourceMappingURL=EXT_materials_diffuse_roughness.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EXT_materials_diffuse_roughness.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/EXT_materials_diffuse_roughness.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,yDAA2C;AAGrE,MAAM,IAAI,GAAG,iCAAiC,CAAC;AAE/C;;GAEG;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CAAC,eAAe,CAAC,4BAA4B,CAAC,CAAC;gBAElI,MAAM,oBAAoB,GAAkC;oBACxD,sBAAsB,EAAE,eAAe,CAAC,qBAAqB;oBAC7D,uBAAuB,EAAE,2BAA2B,IAAI,SAAS;iBACpE,CAAC;gBAEF,IAAI,oBAAoB,CAAC,uBAAuB,KAAK,IAAI,EAAE,CAAC;oBACxD,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;gBAC7D,CAAC;gBAED,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC;YACjD,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,YAAY,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,+BAA+B,CAAC,QAAQ,CAAC,CAAC,CAAC","sourcesContent":["import type { IMaterial, IEXTMaterialsDiffuseRoughness } from \"babylonjs-gltf2interface\";\r\nimport type { IGLTFExporterExtensionV2 } from \"../glTFExporterExtension\";\r\nimport { GLTFExporter } from \"../glTFExporter\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { PBRBaseMaterial } from \"core/Materials/PBR/pbrBaseMaterial\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\n\r\nconst NAME = \"EXT_materials_diffuse_roughness\";\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class EXT_materials_diffuse_roughness implements IGLTFExporterExtensionV2 {\r\n /** Name of this extension */\r\n public readonly name = NAME;\r\n\r\n /** Defines whether this extension is enabled */\r\n public enabled = true;\r\n\r\n /** Defines whether this extension is required */\r\n public required = false;\r\n\r\n private _exporter: GLTFExporter;\r\n\r\n private _wasUsed = false;\r\n\r\n constructor(exporter: GLTFExporter) {\r\n this._exporter = exporter;\r\n }\r\n\r\n public dispose() {}\r\n\r\n /** @internal */\r\n public get wasUsed() {\r\n return this._wasUsed;\r\n }\r\n\r\n public postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[] {\r\n const additionalTextures: BaseTexture[] = [];\r\n if (babylonMaterial instanceof PBRBaseMaterial) {\r\n if (babylonMaterial._baseDiffuseRoughness) {\r\n if (babylonMaterial._baseDiffuseRoughnessTexture) {\r\n additionalTextures.push(babylonMaterial._baseDiffuseRoughnessTexture);\r\n }\r\n return additionalTextures;\r\n }\r\n }\r\n\r\n return [];\r\n }\r\n\r\n public postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial> {\r\n return new Promise((resolve) => {\r\n if (babylonMaterial instanceof PBRBaseMaterial) {\r\n if (!babylonMaterial._baseDiffuseRoughness) {\r\n resolve(node);\r\n return;\r\n }\r\n\r\n this._wasUsed = true;\r\n\r\n node.extensions = node.extensions || {};\r\n\r\n const diffuseRoughnessTextureInfo = this._exporter._materialExporter.getTextureInfo(babylonMaterial._baseDiffuseRoughnessTexture);\r\n\r\n const diffuseRoughnessInfo: IEXTMaterialsDiffuseRoughness = {\r\n diffuseRoughnessFactor: babylonMaterial._baseDiffuseRoughness,\r\n diffuseRoughnessTexture: diffuseRoughnessTextureInfo ?? undefined,\r\n };\r\n\r\n if (diffuseRoughnessInfo.diffuseRoughnessTexture !== null) {\r\n this._exporter._materialNeedsUVsSet.add(babylonMaterial);\r\n }\r\n\r\n node.extensions[NAME] = diffuseRoughnessInfo;\r\n }\r\n resolve(node);\r\n });\r\n }\r\n}\r\n\r\nGLTFExporter.RegisterExtension(NAME, (exporter) => new EXT_materials_diffuse_roughness(exporter));\r\n"]}
@@ -13,4 +13,5 @@ export * from "./KHR_materials_specular.js";
13
13
  export * from "./KHR_materials_transmission.js";
14
14
  export * from "./KHR_materials_unlit.js";
15
15
  export * from "./KHR_materials_volume.js";
16
+ export * from "./EXT_materials_diffuse_roughness.js";
16
17
  export * from "./KHR_texture_transform.js";
@@ -13,5 +13,6 @@ export * from "./KHR_materials_specular.js";
13
13
  export * from "./KHR_materials_transmission.js";
14
14
  export * from "./KHR_materials_unlit.js";
15
15
  export * from "./KHR_materials_volume.js";
16
+ export * from "./EXT_materials_diffuse_roughness.js";
16
17
  export * from "./KHR_texture_transform.js";
17
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mCAAmC,CAAC;AAClD,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC","sourcesContent":["export * from \"./EXT_mesh_gpu_instancing\";\r\nexport * from \"./KHR_draco_mesh_compression\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./KHR_materials_anisotropy\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_diffuse_transmission\";\r\nexport * from \"./KHR_materials_dispersion\";\r\nexport * from \"./KHR_materials_emissive_strength\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_iridescence\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_transmission\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_volume\";\r\nexport * from \"./KHR_texture_transform\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mCAAmC,CAAC;AAClD,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mCAAmC,CAAC;AAClD,cAAc,yBAAyB,CAAC","sourcesContent":["export * from \"./EXT_mesh_gpu_instancing\";\r\nexport * from \"./KHR_draco_mesh_compression\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./KHR_materials_anisotropy\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_diffuse_transmission\";\r\nexport * from \"./KHR_materials_dispersion\";\r\nexport * from \"./KHR_materials_emissive_strength\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_iridescence\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_transmission\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_volume\";\r\nexport * from \"./EXT_materials_diffuse_roughness\";\r\nexport * from \"./KHR_texture_transform\";\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs/serializers",
3
- "version": "8.6.0",
3
+ "version": "8.6.2",
4
4
  "main": "index.js",
5
5
  "module": "index.js",
6
6
  "types": "index.d.ts",
@@ -18,10 +18,10 @@
18
18
  "postcompile": "build-tools -c add-js-to-es6"
19
19
  },
20
20
  "devDependencies": {
21
- "@babylonjs/core": "^8.6.0",
21
+ "@babylonjs/core": "^8.6.2",
22
22
  "@dev/build-tools": "^1.0.0",
23
23
  "@lts/serializers": "^1.0.0",
24
- "babylonjs-gltf2interface": "^8.6.0"
24
+ "babylonjs-gltf2interface": "^8.6.2"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "@babylonjs/core": "^8.0.0",