@babylonjs/serializers 5.0.0-rc.7 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/OBJ/index.d.ts +1 -1
  2. package/OBJ/index.js +1 -1
  3. package/OBJ/objSerializer.d.ts +21 -21
  4. package/OBJ/objSerializer.js +174 -174
  5. package/OBJ/objSerializer.js.map +1 -1
  6. package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +41 -41
  7. package/glTF/2.0/Extensions/KHR_lights_punctual.js +189 -189
  8. package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
  9. package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +24 -24
  10. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +90 -90
  11. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
  12. package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +24 -24
  13. package/glTF/2.0/Extensions/KHR_materials_sheen.js +73 -73
  14. package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
  15. package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +20 -20
  16. package/glTF/2.0/Extensions/KHR_materials_unlit.js +51 -51
  17. package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
  18. package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +30 -30
  19. package/glTF/2.0/Extensions/KHR_texture_transform.js +137 -137
  20. package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
  21. package/glTF/2.0/Extensions/index.d.ts +5 -5
  22. package/glTF/2.0/Extensions/index.js +5 -5
  23. package/glTF/2.0/glTFAnimation.d.ts +206 -205
  24. package/glTF/2.0/glTFAnimation.js +852 -852
  25. package/glTF/2.0/glTFAnimation.js.map +1 -1
  26. package/glTF/2.0/glTFData.d.ts +19 -19
  27. package/glTF/2.0/glTFData.js +52 -52
  28. package/glTF/2.0/glTFExporter.d.ts +456 -455
  29. package/glTF/2.0/glTFExporter.js +1975 -1972
  30. package/glTF/2.0/glTFExporter.js.map +1 -1
  31. package/glTF/2.0/glTFExporterExtension.d.ts +74 -74
  32. package/glTF/2.0/glTFExporterExtension.js +3 -3
  33. package/glTF/2.0/glTFExporterExtension.js.map +1 -1
  34. package/glTF/2.0/glTFMaterialExporter.d.ts +208 -207
  35. package/glTF/2.0/glTFMaterialExporter.js +1114 -1114
  36. package/glTF/2.0/glTFMaterialExporter.js.map +1 -1
  37. package/glTF/2.0/glTFSerializer.d.ts +60 -60
  38. package/glTF/2.0/glTFSerializer.js +62 -62
  39. package/glTF/2.0/glTFSerializer.js.map +1 -1
  40. package/glTF/2.0/glTFUtilities.d.ts +99 -97
  41. package/glTF/2.0/glTFUtilities.js +196 -196
  42. package/glTF/2.0/glTFUtilities.js.map +1 -1
  43. package/glTF/2.0/index.d.ts +8 -8
  44. package/glTF/2.0/index.js +9 -8
  45. package/glTF/2.0/index.js.map +1 -1
  46. package/glTF/2.0/shaders/textureTransform.fragment.d.ts +5 -5
  47. package/glTF/2.0/shaders/textureTransform.fragment.js +8 -8
  48. package/glTF/glTFFileExporter.d.ts +20 -20
  49. package/glTF/glTFFileExporter.js +3 -3
  50. package/glTF/index.d.ts +2 -2
  51. package/glTF/index.js +3 -2
  52. package/glTF/index.js.map +1 -1
  53. package/index.d.ts +3 -3
  54. package/index.js +4 -3
  55. package/index.js.map +1 -1
  56. package/legacy/legacy-glTF2Serializer.d.ts +2 -2
  57. package/legacy/legacy-glTF2Serializer.js +44 -43
  58. package/legacy/legacy-glTF2Serializer.js.map +1 -1
  59. package/legacy/legacy-objSerializer.d.ts +1 -1
  60. package/legacy/legacy-objSerializer.js +13 -12
  61. package/legacy/legacy-objSerializer.js.map +1 -1
  62. package/legacy/legacy-stlSerializer.d.ts +1 -1
  63. package/legacy/legacy-stlSerializer.js +13 -12
  64. package/legacy/legacy-stlSerializer.js.map +1 -1
  65. package/legacy/legacy.d.ts +4 -4
  66. package/legacy/legacy.js +6 -5
  67. package/legacy/legacy.js.map +1 -1
  68. package/license.md +71 -0
  69. package/package.json +25 -6
  70. package/stl/index.d.ts +1 -1
  71. package/stl/index.js +1 -1
  72. package/stl/stlSerializer.d.ts +17 -17
  73. package/stl/stlSerializer.js +107 -107
  74. package/stl/stlSerializer.js.map +1 -1
@@ -1,74 +1,74 @@
1
- import { ImageMimeType, IMeshPrimitive, INode, IMaterial, ITextureInfo } from "babylonjs-gltf2interface";
2
- import { Node } from "@babylonjs/core/node.js";
3
- import { Nullable } from "@babylonjs/core/types.js";
4
- import { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
5
- import { SubMesh } from "@babylonjs/core/Meshes/subMesh.js";
6
- import { IDisposable } from "@babylonjs/core/scene.js";
7
- import { _BinaryWriter } from "./glTFExporter";
8
- import { IGLTFExporterExtension } from "../glTFFileExporter";
9
- import { Material } from "@babylonjs/core/Materials/material.js";
10
- import { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
11
- /** @hidden */
12
- export declare var __IGLTFExporterExtensionV2: number;
13
- /**
14
- * Interface for a glTF exporter extension
15
- * @hidden
16
- */
17
- export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
18
- /**
19
- * Define this method to modify the default behavior before exporting a texture
20
- * @param context The context when loading the asset
21
- * @param babylonTexture The Babylon.js texture
22
- * @param mimeType The mime-type of the generated image
23
- * @returns A promise that resolves with the exported texture
24
- */
25
- preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
26
- /**
27
- * Define this method to get notified when a texture info is created
28
- * @param context The context when loading the asset
29
- * @param textureInfo The glTF texture info
30
- * @param babylonTexture The Babylon.js texture
31
- */
32
- postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
33
- /**
34
- * Define this method to modify the default behavior when exporting texture info
35
- * @param context The context when loading the asset
36
- * @param meshPrimitive glTF mesh primitive
37
- * @param babylonSubMesh Babylon submesh
38
- * @param binaryWriter glTF serializer binary writer instance
39
- * @returns nullable IMeshPrimitive promise
40
- */
41
- postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
42
- /**
43
- * Define this method to modify the default behavior when exporting a node
44
- * @param context The context when exporting the node
45
- * @param node glTF node
46
- * @param babylonNode BabylonJS node
47
- * @returns nullable INode promise
48
- */
49
- postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
50
- [key: number]: number;
51
- }): Promise<Nullable<INode>>;
52
- /**
53
- * Define this method to modify the default behavior when exporting a material
54
- * @param material glTF material
55
- * @param babylonMaterial BabylonJS material
56
- * @returns nullable IMaterial promise
57
- */
58
- postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
59
- /**
60
- * Define this method to return additional textures to export from a material
61
- * @param material glTF material
62
- * @param babylonMaterial BabylonJS material
63
- * @returns List of textures
64
- */
65
- postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
66
- /** Gets a boolean indicating that this extension was used */
67
- wasUsed: boolean;
68
- /** Gets a boolean indicating that this extension is required for the file to work */
69
- required: boolean;
70
- /**
71
- * Called after the exporter state changes to EXPORTING
72
- */
73
- onExporting?(): void;
74
- }
1
+ import type { ImageMimeType, IMeshPrimitive, INode, IMaterial, ITextureInfo } from "babylonjs-gltf2interface/.js";
2
+ import type { Node } from "@babylonjs/core/node.js";
3
+ import type { Nullable } from "@babylonjs/core/types.js";
4
+ import type { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
5
+ import type { SubMesh } from "@babylonjs/core/Meshes/subMesh.js";
6
+ import type { IDisposable } from "@babylonjs/core/scene.js";
7
+ import type { _BinaryWriter } from "./glTFExporter";
8
+ import type { IGLTFExporterExtension } from "../glTFFileExporter";
9
+ import type { Material } from "@babylonjs/core/Materials/material.js";
10
+ import type { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
11
+ /** @hidden */
12
+ export declare var __IGLTFExporterExtensionV2: number;
13
+ /**
14
+ * Interface for a glTF exporter extension
15
+ * @hidden
16
+ */
17
+ export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
18
+ /**
19
+ * Define this method to modify the default behavior before exporting a texture
20
+ * @param context The context when loading the asset
21
+ * @param babylonTexture The Babylon.js texture
22
+ * @param mimeType The mime-type of the generated image
23
+ * @returns A promise that resolves with the exported texture
24
+ */
25
+ preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
26
+ /**
27
+ * Define this method to get notified when a texture info is created
28
+ * @param context The context when loading the asset
29
+ * @param textureInfo The glTF texture info
30
+ * @param babylonTexture The Babylon.js texture
31
+ */
32
+ postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
33
+ /**
34
+ * Define this method to modify the default behavior when exporting texture info
35
+ * @param context The context when loading the asset
36
+ * @param meshPrimitive glTF mesh primitive
37
+ * @param babylonSubMesh Babylon submesh
38
+ * @param binaryWriter glTF serializer binary writer instance
39
+ * @returns nullable IMeshPrimitive promise
40
+ */
41
+ postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
42
+ /**
43
+ * Define this method to modify the default behavior when exporting a node
44
+ * @param context The context when exporting the node
45
+ * @param node glTF node
46
+ * @param babylonNode BabylonJS node
47
+ * @returns nullable INode promise
48
+ */
49
+ postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
50
+ [key: number]: number;
51
+ }): Promise<Nullable<INode>>;
52
+ /**
53
+ * Define this method to modify the default behavior when exporting a material
54
+ * @param material glTF material
55
+ * @param babylonMaterial BabylonJS material
56
+ * @returns nullable IMaterial promise
57
+ */
58
+ postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
59
+ /**
60
+ * Define this method to return additional textures to export from a material
61
+ * @param material glTF material
62
+ * @param babylonMaterial BabylonJS material
63
+ * @returns List of textures
64
+ */
65
+ postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
66
+ /** Gets a boolean indicating that this extension was used */
67
+ wasUsed: boolean;
68
+ /** Gets a boolean indicating that this extension is required for the file to work */
69
+ required: boolean;
70
+ /**
71
+ * Called after the exporter state changes to EXPORTING
72
+ */
73
+ onExporting?(): void;
74
+ }
@@ -1,4 +1,4 @@
1
- /** @hidden */
2
- // eslint-disable-next-line no-var, @typescript-eslint/naming-convention
3
- export var __IGLTFExporterExtensionV2 = 0; // I am here to allow dts to be created
1
+ /** @hidden */
2
+ // eslint-disable-next-line no-var, @typescript-eslint/naming-convention
3
+ export var __IGLTFExporterExtensionV2 = 0; // I am here to allow dts to be created
4
4
  //# sourceMappingURL=glTFExporterExtension.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"glTFExporterExtension.js","sourceRoot":"","sources":["../../../../../../lts/serializers/generated/glTF/2.0/glTFExporterExtension.ts"],"names":[],"mappings":"AAaA,cAAc;AACd,wEAAwE;AACxE,MAAM,CAAC,IAAI,0BAA0B,GAAG,CAAC,CAAC,CAAC,uCAAuC","sourcesContent":["import { ImageMimeType, IMeshPrimitive, INode, IMaterial, ITextureInfo } from \"babylonjs-gltf2interface\";\r\nimport { Node } from \"core/node\";\r\nimport { Nullable } from \"core/types\";\r\n\r\nimport { Texture } from \"core/Materials/Textures/texture\";\r\nimport { SubMesh } from \"core/Meshes/subMesh\";\r\nimport { IDisposable } from \"core/scene\";\r\n\r\nimport { _BinaryWriter } from \"./glTFExporter\";\r\nimport { IGLTFExporterExtension } from \"../glTFFileExporter\";\r\nimport { Material } from \"core/Materials/material\";\r\nimport { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\n\r\n/** @hidden */\r\n// eslint-disable-next-line no-var, @typescript-eslint/naming-convention\r\nexport var __IGLTFExporterExtensionV2 = 0; // I am here to allow dts to be created\r\n\r\n/**\r\n * Interface for a glTF exporter extension\r\n * @hidden\r\n */\r\nexport interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {\r\n /**\r\n * Define this method to modify the default behavior before exporting a texture\r\n * @param context The context when loading the asset\r\n * @param babylonTexture The Babylon.js texture\r\n * @param mimeType The mime-type of the generated image\r\n * @returns A promise that resolves with the exported texture\r\n */\r\n preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;\r\n\r\n /**\r\n * Define this method to get notified when a texture info is created\r\n * @param context The context when loading the asset\r\n * @param textureInfo The glTF texture info\r\n * @param babylonTexture The Babylon.js texture\r\n */\r\n postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;\r\n\r\n /**\r\n * Define this method to modify the default behavior when exporting texture info\r\n * @param context The context when loading the asset\r\n * @param meshPrimitive glTF mesh primitive\r\n * @param babylonSubMesh Babylon submesh\r\n * @param binaryWriter glTF serializer binary writer instance\r\n * @returns nullable IMeshPrimitive promise\r\n */\r\n postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;\r\n\r\n /**\r\n * Define this method to modify the default behavior when exporting a node\r\n * @param context The context when exporting the node\r\n * @param node glTF node\r\n * @param babylonNode BabylonJS node\r\n * @returns nullable INode promise\r\n */\r\n postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: { [key: number]: number }): Promise<Nullable<INode>>;\r\n\r\n /**\r\n * Define this method to modify the default behavior when exporting a material\r\n * @param material glTF material\r\n * @param babylonMaterial BabylonJS material\r\n * @returns nullable IMaterial promise\r\n */\r\n postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;\r\n\r\n /**\r\n * Define this method to return additional textures to export from a material\r\n * @param material glTF material\r\n * @param babylonMaterial BabylonJS material\r\n * @returns List of textures\r\n */\r\n postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];\r\n\r\n /** Gets a boolean indicating that this extension was used */\r\n wasUsed: boolean;\r\n\r\n /** Gets a boolean indicating that this extension is required for the file to work */\r\n required: boolean;\r\n\r\n /**\r\n * Called after the exporter state changes to EXPORTING\r\n */\r\n onExporting?(): void;\r\n}\r\n"]}
1
+ {"version":3,"file":"glTFExporterExtension.js","sourceRoot":"","sources":["../../../../../../lts/serializers/generated/glTF/2.0/glTFExporterExtension.ts"],"names":[],"mappings":"AAaA,cAAc;AACd,wEAAwE;AACxE,MAAM,CAAC,IAAI,0BAA0B,GAAG,CAAC,CAAC,CAAC,uCAAuC","sourcesContent":["import type { ImageMimeType, IMeshPrimitive, INode, IMaterial, ITextureInfo } from \"babylonjs-gltf2interface\";\r\nimport type { Node } from \"core/node\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport type { SubMesh } from \"core/Meshes/subMesh\";\r\nimport type { IDisposable } from \"core/scene\";\r\n\r\nimport type { _BinaryWriter } from \"./glTFExporter\";\r\nimport type { IGLTFExporterExtension } from \"../glTFFileExporter\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\n\r\n/** @hidden */\r\n// eslint-disable-next-line no-var, @typescript-eslint/naming-convention\r\nexport var __IGLTFExporterExtensionV2 = 0; // I am here to allow dts to be created\r\n\r\n/**\r\n * Interface for a glTF exporter extension\r\n * @hidden\r\n */\r\nexport interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {\r\n /**\r\n * Define this method to modify the default behavior before exporting a texture\r\n * @param context The context when loading the asset\r\n * @param babylonTexture The Babylon.js texture\r\n * @param mimeType The mime-type of the generated image\r\n * @returns A promise that resolves with the exported texture\r\n */\r\n preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;\r\n\r\n /**\r\n * Define this method to get notified when a texture info is created\r\n * @param context The context when loading the asset\r\n * @param textureInfo The glTF texture info\r\n * @param babylonTexture The Babylon.js texture\r\n */\r\n postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;\r\n\r\n /**\r\n * Define this method to modify the default behavior when exporting texture info\r\n * @param context The context when loading the asset\r\n * @param meshPrimitive glTF mesh primitive\r\n * @param babylonSubMesh Babylon submesh\r\n * @param binaryWriter glTF serializer binary writer instance\r\n * @returns nullable IMeshPrimitive promise\r\n */\r\n postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;\r\n\r\n /**\r\n * Define this method to modify the default behavior when exporting a node\r\n * @param context The context when exporting the node\r\n * @param node glTF node\r\n * @param babylonNode BabylonJS node\r\n * @returns nullable INode promise\r\n */\r\n postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: { [key: number]: number }): Promise<Nullable<INode>>;\r\n\r\n /**\r\n * Define this method to modify the default behavior when exporting a material\r\n * @param material glTF material\r\n * @param babylonMaterial BabylonJS material\r\n * @returns nullable IMaterial promise\r\n */\r\n postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;\r\n\r\n /**\r\n * Define this method to return additional textures to export from a material\r\n * @param material glTF material\r\n * @param babylonMaterial BabylonJS material\r\n * @returns List of textures\r\n */\r\n postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];\r\n\r\n /** Gets a boolean indicating that this extension was used */\r\n wasUsed: boolean;\r\n\r\n /** Gets a boolean indicating that this extension is required for the file to work */\r\n required: boolean;\r\n\r\n /**\r\n * Called after the exporter state changes to EXPORTING\r\n */\r\n onExporting?(): void;\r\n}\r\n"]}
@@ -1,207 +1,208 @@
1
- import { ITextureInfo, ImageMimeType, IMaterial, IMaterialPbrMetallicRoughness } from "babylonjs-gltf2interface";
2
- import { Nullable } from "@babylonjs/core/types.js";
3
- import { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
4
- import { _Exporter } from "./glTFExporter";
5
- declare type Material = import("@babylonjs/core/Materials/material.js").Material;
6
- declare type StandardMaterial = import("@babylonjs/core/Materials/standardMaterial.js").StandardMaterial;
7
- declare type PBRBaseMaterial = import("@babylonjs/core/Materials/PBR/pbrBaseMaterial.js").PBRBaseMaterial;
8
- declare type PBRMetallicRoughnessMaterial = import("@babylonjs/core/Materials/PBR/pbrMetallicRoughnessMaterial.js").PBRMetallicRoughnessMaterial;
9
- /**
10
- * Utility methods for working with glTF material conversion properties. This class should only be used internally
11
- * @hidden
12
- */
13
- export declare class _GLTFMaterialExporter {
14
- /**
15
- * Represents the dielectric specular values for R, G and B
16
- */
17
- private static readonly _DielectricSpecular;
18
- /**
19
- * Allows the maximum specular power to be defined for material calculations
20
- */
21
- private static readonly _MaxSpecularPower;
22
- /**
23
- * Mapping to store textures
24
- */
25
- private _textureMap;
26
- /**
27
- * Numeric tolerance value
28
- */
29
- private static readonly _Epsilon;
30
- /**
31
- * Reference to the glTF Exporter
32
- */
33
- private _exporter;
34
- constructor(exporter: _Exporter);
35
- /**
36
- * Specifies if two colors are approximately equal in value
37
- * @param color1 first color to compare to
38
- * @param color2 second color to compare to
39
- * @param epsilon threshold value
40
- */
41
- private static _FuzzyEquals;
42
- /**
43
- * Gets the materials from a Babylon scene and converts them to glTF materials
44
- * @param exportMaterials
45
- * @param mimeType texture mime type
46
- * @param hasTextureCoords specifies if texture coordinates are present on the material
47
- */
48
- _convertMaterialsToGLTFAsync(exportMaterials: Set<Material>, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
49
- /**
50
- * Makes a copy of the glTF material without the texture parameters
51
- * @param originalMaterial original glTF material
52
- * @returns glTF material without texture parameters
53
- */
54
- _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
55
- /**
56
- * Specifies if the material has any texture parameters present
57
- * @param material glTF Material
58
- * @returns boolean specifying if texture parameters are present
59
- */
60
- _hasTexturesPresent(material: IMaterial): boolean;
61
- _getTextureInfo(babylonTexture: Nullable<BaseTexture>): Nullable<ITextureInfo>;
62
- /**
63
- * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
64
- * @param babylonStandardMaterial
65
- * @returns glTF Metallic Roughness Material representation
66
- */
67
- _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
68
- /**
69
- * Computes the metallic factor
70
- * @param diffuse diffused value
71
- * @param specular specular value
72
- * @param oneMinusSpecularStrength one minus the specular strength
73
- * @returns metallic value
74
- */
75
- static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
76
- /**
77
- * Sets the glTF alpha mode to a glTF material from the Babylon Material
78
- * @param glTFMaterial glTF material
79
- * @param babylonMaterial Babylon material
80
- */
81
- private static _SetAlphaMode;
82
- /**
83
- * Converts a Babylon Standard Material to a glTF Material
84
- * @param babylonStandardMaterial BJS Standard Material
85
- * @param mimeType mime type to use for the textures
86
- * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
87
- */
88
- _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
89
- private _finishMaterial;
90
- /**
91
- * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
92
- * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
93
- * @param mimeType mime type to use for the textures
94
- * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
95
- */
96
- _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
97
- /**
98
- * Converts an image typed array buffer to a base64 image
99
- * @param buffer typed array buffer
100
- * @param width width of the image
101
- * @param height height of the image
102
- * @param mimeType mimetype of the image
103
- * @returns base64 image string
104
- */
105
- private _createBase64FromCanvasAsync;
106
- /**
107
- * Generates a white texture based on the specified width and height
108
- * @param width width of the texture in pixels
109
- * @param height height of the texture in pixels
110
- * @param scene babylonjs scene
111
- * @returns white texture
112
- */
113
- private _createWhiteTexture;
114
- /**
115
- * Resizes the two source textures to the same dimensions. If a texture is null, a default white texture is generated. If both textures are null, returns null
116
- * @param texture1 first texture to resize
117
- * @param texture2 second texture to resize
118
- * @param scene babylonjs scene
119
- * @returns resized textures or null
120
- */
121
- private _resizeTexturesToSameDimensions;
122
- /**
123
- * Converts an array of pixels to a Float32Array
124
- * Throws an error if the pixel format is not supported
125
- * @param pixels - array buffer containing pixel values
126
- * @returns Float32 of pixels
127
- */
128
- private _convertPixelArrayToFloat32;
129
- /**
130
- * Convert Specular Glossiness Textures to Metallic Roughness
131
- * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
132
- * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
133
- * @param diffuseTexture texture used to store diffuse information
134
- * @param specularGlossinessTexture texture used to store specular and glossiness information
135
- * @param factors specular glossiness material factors
136
- * @param mimeType the mime type to use for the texture
137
- * @returns pbr metallic roughness interface or null
138
- */
139
- private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
140
- /**
141
- * Converts specular glossiness material properties to metallic roughness
142
- * @param specularGlossiness interface with specular glossiness material properties
143
- * @returns interface with metallic roughness material properties
144
- */
145
- private _convertSpecularGlossinessToMetallicRoughness;
146
- /**
147
- * Calculates the surface reflectance, independent of lighting conditions
148
- * @param color Color source to calculate brightness from
149
- * @returns number representing the perceived brightness, or zero if color is undefined
150
- */
151
- private _getPerceivedBrightness;
152
- /**
153
- * Returns the maximum color component value
154
- * @param color
155
- * @returns maximum color component value, or zero if color is null or undefined
156
- */
157
- private _getMaxComponent;
158
- /**
159
- * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
160
- * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
161
- * @param mimeType mime type to use for the textures
162
- * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
163
- * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
164
- * @returns glTF PBR Metallic Roughness factors
165
- */
166
- private _convertMetalRoughFactorsToMetallicRoughnessAsync;
167
- private _getGLTFTextureSampler;
168
- private _getGLTFTextureWrapMode;
169
- private _getGLTFTextureWrapModesSampler;
170
- /**
171
- * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
172
- * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
173
- * @param mimeType mime type to use for the textures
174
- * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
175
- * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
176
- * @returns glTF PBR Metallic Roughness factors
177
- */
178
- private _convertSpecGlossFactorsToMetallicRoughnessAsync;
179
- /**
180
- * Converts a Babylon PBR Base Material to a glTF Material
181
- * @param babylonPBRMaterial BJS PBR Base Material
182
- * @param mimeType mime type to use for the textures
183
- * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
184
- */
185
- _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
186
- private _setMetallicRoughnessPbrMaterial;
187
- private _getPixelsFromTexture;
188
- /**
189
- * Extracts a texture from a Babylon texture into file data and glTF data
190
- * @param babylonTexture Babylon texture to extract
191
- * @param mimeType Mime Type of the babylonTexture
192
- * @return glTF texture info, or null if the texture format is not supported
193
- */
194
- _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
195
- _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
196
- /**
197
- * Builds a texture from base64 string
198
- * @param base64Texture base64 texture string
199
- * @param baseTextureName Name to use for the texture
200
- * @param mimeType image mime type for the texture
201
- * @param texCoordIndex
202
- * @param samplerIndex
203
- * @returns glTF texture info, or null if the texture format is not supported
204
- */
205
- private _getTextureInfoFromBase64;
206
- }
207
- export {};
1
+ import type { ITextureInfo, IMaterial, IMaterialPbrMetallicRoughness } from "babylonjs-gltf2interface/.js";
2
+ import { ImageMimeType } from "babylonjs-gltf2interface/.js";
3
+ import type { Nullable } from "@babylonjs/core/types.js";
4
+ import type { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
5
+ import type { _Exporter } from "./glTFExporter";
6
+ declare type Material = import("@babylonjs/core/Materials/material.js").Material;
7
+ declare type StandardMaterial = import("@babylonjs/core/Materials/standardMaterial.js").StandardMaterial;
8
+ declare type PBRBaseMaterial = import("@babylonjs/core/Materials/PBR/pbrBaseMaterial.js").PBRBaseMaterial;
9
+ declare type PBRMetallicRoughnessMaterial = import("@babylonjs/core/Materials/PBR/pbrMetallicRoughnessMaterial.js").PBRMetallicRoughnessMaterial;
10
+ /**
11
+ * Utility methods for working with glTF material conversion properties. This class should only be used internally
12
+ * @hidden
13
+ */
14
+ export declare class _GLTFMaterialExporter {
15
+ /**
16
+ * Represents the dielectric specular values for R, G and B
17
+ */
18
+ private static readonly _DielectricSpecular;
19
+ /**
20
+ * Allows the maximum specular power to be defined for material calculations
21
+ */
22
+ private static readonly _MaxSpecularPower;
23
+ /**
24
+ * Mapping to store textures
25
+ */
26
+ private _textureMap;
27
+ /**
28
+ * Numeric tolerance value
29
+ */
30
+ private static readonly _Epsilon;
31
+ /**
32
+ * Reference to the glTF Exporter
33
+ */
34
+ private _exporter;
35
+ constructor(exporter: _Exporter);
36
+ /**
37
+ * Specifies if two colors are approximately equal in value
38
+ * @param color1 first color to compare to
39
+ * @param color2 second color to compare to
40
+ * @param epsilon threshold value
41
+ */
42
+ private static _FuzzyEquals;
43
+ /**
44
+ * Gets the materials from a Babylon scene and converts them to glTF materials
45
+ * @param exportMaterials
46
+ * @param mimeType texture mime type
47
+ * @param hasTextureCoords specifies if texture coordinates are present on the material
48
+ */
49
+ _convertMaterialsToGLTFAsync(exportMaterials: Set<Material>, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
50
+ /**
51
+ * Makes a copy of the glTF material without the texture parameters
52
+ * @param originalMaterial original glTF material
53
+ * @returns glTF material without texture parameters
54
+ */
55
+ _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
56
+ /**
57
+ * Specifies if the material has any texture parameters present
58
+ * @param material glTF Material
59
+ * @returns boolean specifying if texture parameters are present
60
+ */
61
+ _hasTexturesPresent(material: IMaterial): boolean;
62
+ _getTextureInfo(babylonTexture: Nullable<BaseTexture>): Nullable<ITextureInfo>;
63
+ /**
64
+ * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
65
+ * @param babylonStandardMaterial
66
+ * @returns glTF Metallic Roughness Material representation
67
+ */
68
+ _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
69
+ /**
70
+ * Computes the metallic factor
71
+ * @param diffuse diffused value
72
+ * @param specular specular value
73
+ * @param oneMinusSpecularStrength one minus the specular strength
74
+ * @returns metallic value
75
+ */
76
+ static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
77
+ /**
78
+ * Sets the glTF alpha mode to a glTF material from the Babylon Material
79
+ * @param glTFMaterial glTF material
80
+ * @param babylonMaterial Babylon material
81
+ */
82
+ private static _SetAlphaMode;
83
+ /**
84
+ * Converts a Babylon Standard Material to a glTF Material
85
+ * @param babylonStandardMaterial BJS Standard Material
86
+ * @param mimeType mime type to use for the textures
87
+ * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
88
+ */
89
+ _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
90
+ private _finishMaterial;
91
+ /**
92
+ * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
93
+ * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
94
+ * @param mimeType mime type to use for the textures
95
+ * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
96
+ */
97
+ _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
98
+ /**
99
+ * Converts an image typed array buffer to a base64 image
100
+ * @param buffer typed array buffer
101
+ * @param width width of the image
102
+ * @param height height of the image
103
+ * @param mimeType mimetype of the image
104
+ * @returns base64 image string
105
+ */
106
+ private _createBase64FromCanvasAsync;
107
+ /**
108
+ * Generates a white texture based on the specified width and height
109
+ * @param width width of the texture in pixels
110
+ * @param height height of the texture in pixels
111
+ * @param scene babylonjs scene
112
+ * @returns white texture
113
+ */
114
+ private _createWhiteTexture;
115
+ /**
116
+ * Resizes the two source textures to the same dimensions. If a texture is null, a default white texture is generated. If both textures are null, returns null
117
+ * @param texture1 first texture to resize
118
+ * @param texture2 second texture to resize
119
+ * @param scene babylonjs scene
120
+ * @returns resized textures or null
121
+ */
122
+ private _resizeTexturesToSameDimensions;
123
+ /**
124
+ * Converts an array of pixels to a Float32Array
125
+ * Throws an error if the pixel format is not supported
126
+ * @param pixels - array buffer containing pixel values
127
+ * @returns Float32 of pixels
128
+ */
129
+ private _convertPixelArrayToFloat32;
130
+ /**
131
+ * Convert Specular Glossiness Textures to Metallic Roughness
132
+ * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
133
+ * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
134
+ * @param diffuseTexture texture used to store diffuse information
135
+ * @param specularGlossinessTexture texture used to store specular and glossiness information
136
+ * @param factors specular glossiness material factors
137
+ * @param mimeType the mime type to use for the texture
138
+ * @returns pbr metallic roughness interface or null
139
+ */
140
+ private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
141
+ /**
142
+ * Converts specular glossiness material properties to metallic roughness
143
+ * @param specularGlossiness interface with specular glossiness material properties
144
+ * @returns interface with metallic roughness material properties
145
+ */
146
+ private _convertSpecularGlossinessToMetallicRoughness;
147
+ /**
148
+ * Calculates the surface reflectance, independent of lighting conditions
149
+ * @param color Color source to calculate brightness from
150
+ * @returns number representing the perceived brightness, or zero if color is undefined
151
+ */
152
+ private _getPerceivedBrightness;
153
+ /**
154
+ * Returns the maximum color component value
155
+ * @param color
156
+ * @returns maximum color component value, or zero if color is null or undefined
157
+ */
158
+ private _getMaxComponent;
159
+ /**
160
+ * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
161
+ * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
162
+ * @param mimeType mime type to use for the textures
163
+ * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
164
+ * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
165
+ * @returns glTF PBR Metallic Roughness factors
166
+ */
167
+ private _convertMetalRoughFactorsToMetallicRoughnessAsync;
168
+ private _getGLTFTextureSampler;
169
+ private _getGLTFTextureWrapMode;
170
+ private _getGLTFTextureWrapModesSampler;
171
+ /**
172
+ * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
173
+ * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
174
+ * @param mimeType mime type to use for the textures
175
+ * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
176
+ * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
177
+ * @returns glTF PBR Metallic Roughness factors
178
+ */
179
+ private _convertSpecGlossFactorsToMetallicRoughnessAsync;
180
+ /**
181
+ * Converts a Babylon PBR Base Material to a glTF Material
182
+ * @param babylonPBRMaterial BJS PBR Base Material
183
+ * @param mimeType mime type to use for the textures
184
+ * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
185
+ */
186
+ _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
187
+ private _setMetallicRoughnessPbrMaterial;
188
+ private _getPixelsFromTexture;
189
+ /**
190
+ * Extracts a texture from a Babylon texture into file data and glTF data
191
+ * @param babylonTexture Babylon texture to extract
192
+ * @param mimeType Mime Type of the babylonTexture
193
+ * @return glTF texture info, or null if the texture format is not supported
194
+ */
195
+ _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
196
+ _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
197
+ /**
198
+ * Builds a texture from base64 string
199
+ * @param base64Texture base64 texture string
200
+ * @param baseTextureName Name to use for the texture
201
+ * @param mimeType image mime type for the texture
202
+ * @param texCoordIndex
203
+ * @param samplerIndex
204
+ * @returns glTF texture info, or null if the texture format is not supported
205
+ */
206
+ private _getTextureInfoFromBase64;
207
+ }
208
+ export {};