@babylonjs/serializers 7.37.1 → 7.37.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.
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +6 -7
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +18 -12
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +5 -6
- package/glTF/2.0/Extensions/KHR_lights_punctual.js +99 -109
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_anisotropy.d.ts +2 -2
- package/glTF/2.0/Extensions/KHR_materials_anisotropy.js +6 -6
- package/glTF/2.0/Extensions/KHR_materials_anisotropy.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +2 -2
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +9 -9
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.d.ts +2 -2
- package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js +7 -7
- package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_dispersion.js +2 -2
- package/glTF/2.0/Extensions/KHR_materials_dispersion.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +2 -2
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_ior.js +2 -2
- package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_iridescence.d.ts +2 -2
- package/glTF/2.0/Extensions/KHR_materials_iridescence.js +7 -7
- package/glTF/2.0/Extensions/KHR_materials_iridescence.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +2 -2
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +8 -8
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +2 -2
- package/glTF/2.0/Extensions/KHR_materials_specular.js +7 -7
- package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +2 -2
- package/glTF/2.0/Extensions/KHR_materials_transmission.js +6 -6
- package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_unlit.js +2 -2
- package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +2 -2
- package/glTF/2.0/Extensions/KHR_materials_volume.js +6 -6
- package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.js +2 -2
- package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
- package/glTF/2.0/Extensions/index.d.ts +9 -9
- package/glTF/2.0/Extensions/index.js +9 -9
- package/glTF/2.0/Extensions/index.js.map +1 -1
- package/glTF/2.0/dataWriter.d.ts +18 -0
- package/glTF/2.0/dataWriter.js +65 -0
- package/glTF/2.0/dataWriter.js.map +1 -0
- package/glTF/2.0/glTFAnimation.d.ts +4 -10
- package/glTF/2.0/glTFAnimation.js +87 -19
- package/glTF/2.0/glTFAnimation.js.map +1 -1
- package/glTF/2.0/glTFData.d.ts +5 -3
- package/glTF/2.0/glTFData.js +35 -36
- package/glTF/2.0/glTFData.js.map +1 -1
- package/glTF/2.0/glTFExporter.d.ts +62 -363
- package/glTF/2.0/glTFExporter.js +867 -1579
- package/glTF/2.0/glTFExporter.js.map +1 -1
- package/glTF/2.0/glTFExporterExtension.d.ts +8 -9
- package/glTF/2.0/glTFExporterExtension.js.map +1 -1
- package/glTF/2.0/glTFMaterialExporter.d.ts +26 -126
- package/glTF/2.0/glTFMaterialExporter.js +276 -438
- package/glTF/2.0/glTFMaterialExporter.js.map +1 -1
- package/glTF/2.0/glTFMorphTargetsUtilities.d.ts +14 -0
- package/glTF/2.0/glTFMorphTargetsUtilities.js +105 -0
- package/glTF/2.0/glTFMorphTargetsUtilities.js.map +1 -0
- package/glTF/2.0/glTFSerializer.d.ts +10 -13
- package/glTF/2.0/glTFSerializer.js +25 -44
- package/glTF/2.0/glTFSerializer.js.map +1 -1
- package/glTF/2.0/glTFUtilities.d.ts +75 -43
- package/glTF/2.0/glTFUtilities.js +350 -103
- package/glTF/2.0/glTFUtilities.js.map +1 -1
- package/package.json +3 -3
package/glTF/2.0/glTFData.js
CHANGED
@@ -1,50 +1,49 @@
|
|
1
|
+
import { Tools } from "@babylonjs/core/Misc/tools.js";
|
2
|
+
function GetMimeType(fileName) {
|
3
|
+
if (fileName.endsWith(".glb")) {
|
4
|
+
return "model/gltf-binary";
|
5
|
+
}
|
6
|
+
else if (fileName.endsWith(".bin")) {
|
7
|
+
return "application/octet-stream";
|
8
|
+
}
|
9
|
+
else if (fileName.endsWith(".gltf")) {
|
10
|
+
return "model/gltf+json";
|
11
|
+
}
|
12
|
+
else if (fileName.endsWith(".jpeg") || fileName.endsWith(".jpg")) {
|
13
|
+
return "image/jpeg" /* ImageMimeType.JPEG */;
|
14
|
+
}
|
15
|
+
else if (fileName.endsWith(".png")) {
|
16
|
+
return "image/png" /* ImageMimeType.PNG */;
|
17
|
+
}
|
18
|
+
else if (fileName.endsWith(".webp")) {
|
19
|
+
return "image/webp" /* ImageMimeType.WEBP */;
|
20
|
+
}
|
21
|
+
return undefined;
|
22
|
+
}
|
1
23
|
/**
|
2
24
|
* Class for holding and downloading glTF file data
|
3
25
|
*/
|
4
26
|
export class GLTFData {
|
27
|
+
constructor() {
|
28
|
+
/**
|
29
|
+
* Object which contains the file name as the key and its data as the value
|
30
|
+
*/
|
31
|
+
this.files = {};
|
32
|
+
}
|
5
33
|
/**
|
6
|
-
*
|
34
|
+
* @deprecated Use files instead
|
7
35
|
*/
|
8
|
-
|
9
|
-
this.
|
36
|
+
get glTFFiles() {
|
37
|
+
return this.files;
|
10
38
|
}
|
11
39
|
/**
|
12
40
|
* Downloads the glTF data as files based on their names and data
|
13
41
|
*/
|
14
42
|
downloadFiles() {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
* @returns Boolean indicating whether the suffix was found (true) or not (false)
|
20
|
-
*/
|
21
|
-
function endsWith(str, suffix) {
|
22
|
-
return str.indexOf(suffix, str.length - suffix.length) !== -1;
|
23
|
-
}
|
24
|
-
for (const key in this.glTFFiles) {
|
25
|
-
const link = document.createElement("a");
|
26
|
-
document.body.appendChild(link);
|
27
|
-
link.setAttribute("type", "hidden");
|
28
|
-
link.download = key;
|
29
|
-
const blob = this.glTFFiles[key];
|
30
|
-
let mimeType;
|
31
|
-
if (endsWith(key, ".glb")) {
|
32
|
-
mimeType = { type: "model/gltf-binary" };
|
33
|
-
}
|
34
|
-
else if (endsWith(key, ".bin")) {
|
35
|
-
mimeType = { type: "application/octet-stream" };
|
36
|
-
}
|
37
|
-
else if (endsWith(key, ".gltf")) {
|
38
|
-
mimeType = { type: "model/gltf+json" };
|
39
|
-
}
|
40
|
-
else if (endsWith(key, ".jpeg") || endsWith(key, ".jpg")) {
|
41
|
-
mimeType = { type: "image/jpeg" /* ImageMimeType.JPEG */ };
|
42
|
-
}
|
43
|
-
else if (endsWith(key, ".png")) {
|
44
|
-
mimeType = { type: "image/png" /* ImageMimeType.PNG */ };
|
45
|
-
}
|
46
|
-
link.href = window.URL.createObjectURL(new Blob([blob], mimeType));
|
47
|
-
link.click();
|
43
|
+
for (const key in this.files) {
|
44
|
+
const value = this.files[key];
|
45
|
+
const blob = new Blob([value], { type: GetMimeType(key) });
|
46
|
+
Tools.Download(blob, key);
|
48
47
|
}
|
49
48
|
}
|
50
49
|
}
|
package/glTF/2.0/glTFData.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"glTFData.js","sourceRoot":"","sources":["../../../../../dev/serializers/src/glTF/2.0/glTFData.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"glTFData.js","sourceRoot":"","sources":["../../../../../dev/serializers/src/glTF/2.0/glTFData.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAExC,SAAS,WAAW,CAAC,QAAgB;IACjC,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,OAAO,mBAAmB,CAAC;IAC/B,CAAC;SAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACnC,OAAO,0BAA0B,CAAC;IACtC,CAAC;SAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,OAAO,iBAAiB,CAAC;IAC7B,CAAC;SAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACjE,6CAA0B;IAC9B,CAAC;SAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACnC,2CAAyB;IAC7B,CAAC;SAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,6CAA0B;IAC9B,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,QAAQ;IAArB;QACI;;WAEG;QACa,UAAK,GAA0C,EAAE,CAAC;IAmBtE,CAAC;IAjBG;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED;;OAEG;IACI,aAAa;QAChB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC9B,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC3D,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC9B,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { ImageMimeType } from \"babylonjs-gltf2interface\";\r\nimport { Tools } from \"core/Misc/tools\";\r\n\r\nfunction GetMimeType(fileName: string): string | undefined {\r\n if (fileName.endsWith(\".glb\")) {\r\n return \"model/gltf-binary\";\r\n } else if (fileName.endsWith(\".bin\")) {\r\n return \"application/octet-stream\";\r\n } else if (fileName.endsWith(\".gltf\")) {\r\n return \"model/gltf+json\";\r\n } else if (fileName.endsWith(\".jpeg\") || fileName.endsWith(\".jpg\")) {\r\n return ImageMimeType.JPEG;\r\n } else if (fileName.endsWith(\".png\")) {\r\n return ImageMimeType.PNG;\r\n } else if (fileName.endsWith(\".webp\")) {\r\n return ImageMimeType.WEBP;\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\n/**\r\n * Class for holding and downloading glTF file data\r\n */\r\nexport class GLTFData {\r\n /**\r\n * Object which contains the file name as the key and its data as the value\r\n */\r\n public readonly files: { [fileName: string]: string | Blob } = {};\r\n\r\n /**\r\n * @deprecated Use files instead\r\n */\r\n public get glTFFiles() {\r\n return this.files;\r\n }\r\n\r\n /**\r\n * Downloads the glTF data as files based on their names and data\r\n */\r\n public downloadFiles(): void {\r\n for (const key in this.files) {\r\n const value = this.files[key];\r\n const blob = new Blob([value], { type: GetMimeType(key) });\r\n Tools.Download(blob, key);\r\n }\r\n }\r\n}\r\n"]}
|
@@ -1,231 +1,75 @@
|
|
1
|
-
import type { IBufferView, IAccessor, INode, IMaterial, ITexture, IImage, ISampler, IMeshPrimitive, IGLTF, ITextureInfo, ISkin } from "babylonjs-gltf2interface";
|
2
|
-
import { ImageMimeType
|
3
|
-
import type {
|
4
|
-
import { Vector3, Vector4 } from "@babylonjs/core/Maths/math.vector.js";
|
1
|
+
import type { IBufferView, IAccessor, INode, IScene, IMesh, IMaterial, ITexture, IImage, ISampler, IAnimation, IMeshPrimitive, IGLTF, ITextureInfo, ISkin, ICamera } from "babylonjs-gltf2interface";
|
2
|
+
import { ImageMimeType } from "babylonjs-gltf2interface";
|
3
|
+
import type { Nullable } from "@babylonjs/core/types.js";
|
5
4
|
import type { Node } from "@babylonjs/core/node.js";
|
6
|
-
import { TransformNode } from "@babylonjs/core/Meshes/transformNode.js";
|
7
5
|
import type { SubMesh } from "@babylonjs/core/Meshes/subMesh.js";
|
8
6
|
import type { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
|
9
7
|
import type { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
|
10
8
|
import { Material } from "@babylonjs/core/Materials/material.js";
|
11
9
|
import type { Scene } from "@babylonjs/core/scene.js";
|
12
10
|
import type { IGLTFExporterExtensionV2 } from "./glTFExporterExtension";
|
13
|
-
import {
|
11
|
+
import { GLTFMaterialExporter } from "./glTFMaterialExporter";
|
14
12
|
import type { IExportOptions } from "./glTFSerializer";
|
15
13
|
import { GLTFData } from "./glTFData";
|
16
|
-
/**
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
/**
|
34
|
-
* Stores all the generated nodes, which contains transform and/or mesh information per node
|
35
|
-
*/
|
36
|
-
_nodes: INode[];
|
37
|
-
/**
|
38
|
-
* Stores all the generated glTF scenes, which stores multiple node hierarchies
|
39
|
-
*/
|
40
|
-
private _scenes;
|
41
|
-
/**
|
42
|
-
* Stores all the generated glTF cameras
|
43
|
-
*/
|
44
|
-
private _cameras;
|
45
|
-
/**
|
46
|
-
* Stores all the generated mesh information, each containing a set of primitives to render in glTF
|
47
|
-
*/
|
48
|
-
private _meshes;
|
49
|
-
/**
|
50
|
-
* Stores all the generated material information, which represents the appearance of each primitive
|
51
|
-
*/
|
52
|
-
_materials: IMaterial[];
|
53
|
-
_materialMap: {
|
54
|
-
[materialID: number]: number;
|
55
|
-
};
|
56
|
-
/**
|
57
|
-
* Stores all the generated texture information, which is referenced by glTF materials
|
58
|
-
*/
|
59
|
-
_textures: ITexture[];
|
60
|
-
/**
|
61
|
-
* Stores all the generated image information, which is referenced by glTF textures
|
62
|
-
*/
|
63
|
-
_images: IImage[];
|
64
|
-
/**
|
65
|
-
* Stores all the texture samplers
|
66
|
-
*/
|
67
|
-
_samplers: ISampler[];
|
68
|
-
/**
|
69
|
-
* Stores all the generated glTF skins
|
70
|
-
*/
|
71
|
-
_skins: ISkin[];
|
72
|
-
/**
|
73
|
-
* Stores all the generated animation samplers, which is referenced by glTF animations
|
74
|
-
*/
|
75
|
-
/**
|
76
|
-
* Stores the animations for glTF models
|
77
|
-
*/
|
78
|
-
private _animations;
|
79
|
-
/**
|
80
|
-
* Stores the total amount of bytes stored in the glTF buffer
|
81
|
-
*/
|
82
|
-
private _totalByteLength;
|
83
|
-
/**
|
84
|
-
* Stores a reference to the Babylon scene containing the source geometry and material information
|
85
|
-
*/
|
86
|
-
_babylonScene: Scene;
|
87
|
-
/**
|
88
|
-
* Stores a map of the image data, where the key is the file name and the value
|
89
|
-
* is the image data
|
90
|
-
*/
|
91
|
-
_imageData: {
|
14
|
+
/** @internal */
|
15
|
+
export declare class GLTFExporter {
|
16
|
+
readonly _glTF: IGLTF;
|
17
|
+
readonly _animations: IAnimation[];
|
18
|
+
readonly _accessors: IAccessor[];
|
19
|
+
readonly _bufferViews: IBufferView[];
|
20
|
+
readonly _cameras: ICamera[];
|
21
|
+
readonly _images: IImage[];
|
22
|
+
readonly _materials: IMaterial[];
|
23
|
+
readonly _meshes: IMesh[];
|
24
|
+
readonly _nodes: INode[];
|
25
|
+
readonly _samplers: ISampler[];
|
26
|
+
readonly _scenes: IScene[];
|
27
|
+
readonly _skins: ISkin[];
|
28
|
+
readonly _textures: ITexture[];
|
29
|
+
readonly _babylonScene: Scene;
|
30
|
+
readonly _imageData: {
|
92
31
|
[fileName: string]: {
|
93
32
|
data: ArrayBuffer;
|
94
33
|
mimeType: ImageMimeType;
|
95
34
|
};
|
96
35
|
};
|
97
|
-
private _orderedImageData;
|
98
|
-
/**
|
99
|
-
* Stores a map of the unique id of a node to its index in the node array
|
100
|
-
*/
|
101
|
-
private _nodeMap;
|
36
|
+
private readonly _orderedImageData;
|
102
37
|
/**
|
103
38
|
* Baked animation sample rate
|
104
39
|
*/
|
105
40
|
private _animationSampleRate;
|
106
|
-
private _options;
|
107
|
-
|
108
|
-
|
109
|
-
private
|
110
|
-
private
|
111
|
-
private
|
41
|
+
private readonly _options;
|
42
|
+
readonly _materialExporter: GLTFMaterialExporter;
|
43
|
+
private readonly _extensions;
|
44
|
+
private readonly _dataWriter;
|
45
|
+
private readonly _shouldExportNodeMap;
|
46
|
+
private readonly _nodeMap;
|
47
|
+
readonly _materialMap: Map<Material, number>;
|
48
|
+
private readonly _camerasMap;
|
49
|
+
private readonly _nodesCameraMap;
|
50
|
+
private readonly _skinMap;
|
51
|
+
private readonly _nodesSkinMap;
|
52
|
+
readonly _materialNeedsUVsSet: Set<Material>;
|
53
|
+
private static readonly _ExtensionNames;
|
54
|
+
private static readonly _ExtensionFactories;
|
112
55
|
private _applyExtension;
|
113
56
|
private _applyExtensions;
|
114
|
-
_extensionsPreExportTextureAsync(context: string, babylonTexture:
|
115
|
-
_extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh
|
116
|
-
_extensionsPostExportNodeAsync(context: string, node:
|
117
|
-
|
118
|
-
}, binaryWriter: _BinaryWriter): Promise<Nullable<INode>>;
|
119
|
-
_extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
|
57
|
+
_extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
|
58
|
+
_extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh): Promise<Nullable<IMeshPrimitive>>;
|
59
|
+
_extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node, nodeMap: Map<Node, number>, convertToRightHanded: boolean): Promise<Nullable<INode>>;
|
60
|
+
_extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
|
120
61
|
_extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
|
121
62
|
_extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
|
122
63
|
private _forEachExtensions;
|
123
64
|
private _extensionsOnExporting;
|
124
|
-
/**
|
125
|
-
* Load glTF serializer extensions
|
126
|
-
*/
|
127
65
|
private _loadExtensions;
|
128
|
-
/**
|
129
|
-
* Creates a glTF Exporter instance, which can accept optional exporter options
|
130
|
-
* @param babylonScene Babylon scene object
|
131
|
-
* @param options Options to modify the behavior of the exporter
|
132
|
-
*/
|
133
66
|
constructor(babylonScene?: Nullable<Scene>, options?: IExportOptions);
|
134
67
|
dispose(): void;
|
135
|
-
get options(): IExportOptions
|
136
|
-
|
137
|
-
* Registers a glTF exporter extension
|
138
|
-
* @param name Name of the extension to export
|
139
|
-
* @param factory The factory function that creates the exporter extension
|
140
|
-
*/
|
141
|
-
static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
|
142
|
-
/**
|
143
|
-
* Un-registers an exporter extension
|
144
|
-
* @param name The name fo the exporter extension
|
145
|
-
* @returns A boolean indicating whether the extension has been un-registered
|
146
|
-
*/
|
68
|
+
get options(): Required<IExportOptions>;
|
69
|
+
static RegisterExtension(name: string, factory: (exporter: GLTFExporter) => IGLTFExporterExtensionV2): void;
|
147
70
|
static UnregisterExtension(name: string): boolean;
|
148
|
-
private _reorderIndicesBasedOnPrimitiveMode;
|
149
|
-
/**
|
150
|
-
* Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
|
151
|
-
* clock-wise during export to glTF
|
152
|
-
* @param submesh BabylonJS submesh
|
153
|
-
* @param primitiveMode Primitive mode of the mesh
|
154
|
-
* @param vertexBufferKind The type of vertex attribute
|
155
|
-
* @param meshAttributeArray The vertex attribute data
|
156
|
-
* @param byteOffset The offset to the binary data
|
157
|
-
* @param binaryWriter The binary data for the glTF file
|
158
|
-
*/
|
159
|
-
private _reorderVertexAttributeDataBasedOnPrimitiveMode;
|
160
|
-
/**
|
161
|
-
* Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
|
162
|
-
* clock-wise during export to glTF
|
163
|
-
* @param submesh BabylonJS submesh
|
164
|
-
* @param vertexBufferKind The type of vertex attribute
|
165
|
-
* @param meshAttributeArray The vertex attribute data
|
166
|
-
* @param byteOffset The offset to the binary data
|
167
|
-
* @param binaryWriter The binary data for the glTF file
|
168
|
-
*/
|
169
|
-
private _reorderTriangleFillMode;
|
170
|
-
/**
|
171
|
-
* Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
|
172
|
-
* clock-wise during export to glTF
|
173
|
-
* @param submesh BabylonJS submesh
|
174
|
-
* @param vertexBufferKind The type of vertex attribute
|
175
|
-
* @param meshAttributeArray The vertex attribute data
|
176
|
-
* @param byteOffset The offset to the binary data
|
177
|
-
* @param binaryWriter The binary data for the glTF file
|
178
|
-
*/
|
179
|
-
private _reorderTriangleStripDrawMode;
|
180
|
-
/**
|
181
|
-
* Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
|
182
|
-
* clock-wise during export to glTF
|
183
|
-
* @param submesh BabylonJS submesh
|
184
|
-
* @param vertexBufferKind The type of vertex attribute
|
185
|
-
* @param meshAttributeArray The vertex attribute data
|
186
|
-
* @param byteOffset The offset to the binary data
|
187
|
-
* @param binaryWriter The binary data for the glTF file
|
188
|
-
*/
|
189
|
-
private _reorderTriangleFanMode;
|
190
|
-
/**
|
191
|
-
* Writes the vertex attribute data to binary
|
192
|
-
* @param vertices The vertices to write to the binary writer
|
193
|
-
* @param byteOffset The offset into the binary writer to overwrite binary data
|
194
|
-
* @param vertexAttributeKind The vertex attribute type
|
195
|
-
* @param binaryWriter The writer containing the binary data
|
196
|
-
*/
|
197
|
-
private _writeVertexAttributeData;
|
198
|
-
/**
|
199
|
-
* Writes mesh attribute data to a data buffer
|
200
|
-
* Returns the bytelength of the data
|
201
|
-
* @param vertexBufferKind Indicates what kind of vertex data is being passed in
|
202
|
-
* @param attributeComponentKind
|
203
|
-
* @param meshAttributeArray Array containing the attribute data
|
204
|
-
* @param stride Specifies the space between data
|
205
|
-
* @param binaryWriter The buffer to write the binary data to
|
206
|
-
* @param babylonTransformNode
|
207
|
-
*/
|
208
|
-
_writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, babylonTransformNode: TransformNode): void;
|
209
|
-
private _createMorphTargetBufferViewKind;
|
210
|
-
/**
|
211
|
-
* Generates glTF json data
|
212
|
-
* @param shouldUseGlb Indicates whether the json should be written for a glb file
|
213
|
-
* @param glTFPrefix Text to use when prefixing a glTF file
|
214
|
-
* @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
|
215
|
-
* @returns json data as string
|
216
|
-
*/
|
217
71
|
private _generateJSON;
|
218
|
-
|
219
|
-
* Generates data for .gltf and .bin files based on the glTF prefix string
|
220
|
-
* @param glTFPrefix Text to use when prefixing a glTF file
|
221
|
-
* @param dispose Dispose the exporter
|
222
|
-
* @returns GLTFData with glTF file data
|
223
|
-
*/
|
224
|
-
_generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
|
225
|
-
/**
|
226
|
-
* Creates a binary buffer for glTF
|
227
|
-
* @returns array buffer for binary data
|
228
|
-
*/
|
72
|
+
generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
|
229
73
|
private _generateBinaryAsync;
|
230
74
|
/**
|
231
75
|
* Pads the number to a multiple of 4
|
@@ -233,171 +77,26 @@ export declare class _Exporter {
|
|
233
77
|
* @returns padded number
|
234
78
|
*/
|
235
79
|
private _getPadding;
|
236
|
-
|
237
|
-
* @internal
|
238
|
-
*/
|
239
|
-
_generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
|
240
|
-
/**
|
241
|
-
* Sets the TRS for each node
|
242
|
-
* @param node glTF Node for storing the transformation data
|
243
|
-
* @param babylonTransformNode Babylon mesh used as the source for the transformation data
|
244
|
-
*/
|
80
|
+
generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
|
245
81
|
private _setNodeTransformation;
|
246
82
|
private _setCameraTransformation;
|
247
|
-
private
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
*
|
259
|
-
* @
|
260
|
-
* @returns Unsigned integer of the primitive mode or null
|
261
|
-
*/
|
262
|
-
private _getMeshPrimitiveMode;
|
263
|
-
/**
|
264
|
-
* Sets the primitive mode of the glTF mesh primitive
|
265
|
-
* @param meshPrimitive glTF mesh primitive
|
266
|
-
* @param primitiveMode The primitive mode
|
267
|
-
*/
|
268
|
-
private _setPrimitiveMode;
|
269
|
-
/**
|
270
|
-
* Sets the vertex attribute accessor based of the glTF mesh primitive
|
271
|
-
* @param meshPrimitive glTF mesh primitive
|
272
|
-
* @param attributeKind vertex attribute
|
273
|
-
*/
|
274
|
-
private _setAttributeKind;
|
275
|
-
/**
|
276
|
-
* Sets data for the primitive attributes of each submesh
|
277
|
-
* @param mesh glTF Mesh object to store the primitive attribute information
|
278
|
-
* @param babylonTransformNode Babylon mesh to get the primitive attribute data from
|
279
|
-
* @param binaryWriter Buffer to write the attribute data to
|
280
|
-
* @returns promise that resolves when done setting the primitive attributes
|
281
|
-
*/
|
282
|
-
private _setPrimitiveAttributesAsync;
|
283
|
-
/**
|
284
|
-
* Creates a glTF scene based on the array of meshes
|
285
|
-
* Returns the total byte offset
|
286
|
-
* @param binaryWriter Buffer to write binary data to
|
287
|
-
* @returns a promise that resolves when done
|
288
|
-
*/
|
289
|
-
private _createSceneAsync;
|
290
|
-
/**
|
291
|
-
* Getting the nodes and materials that would be exported.
|
292
|
-
* @param nodes Babylon transform nodes
|
293
|
-
* @returns Set of materials which would be exported.
|
294
|
-
*/
|
295
|
-
private _getExportNodes;
|
296
|
-
/**
|
297
|
-
* Creates a mapping of Node unique id to node index and handles animations
|
298
|
-
* @param nodes Babylon transform nodes
|
299
|
-
* @param binaryWriter Buffer to write binary data to
|
300
|
-
* @returns Node mapping of unique id to index
|
301
|
-
*/
|
302
|
-
private _createNodeMapAndAnimationsAsync;
|
303
|
-
/**
|
304
|
-
* Creates a glTF node from a Babylon mesh
|
305
|
-
* @param babylonNode Source Babylon mesh
|
306
|
-
* @param binaryWriter Buffer for storing geometry data
|
307
|
-
* @returns glTF node
|
308
|
-
*/
|
309
|
-
private _createNodeAsync;
|
310
|
-
/**
|
311
|
-
* Creates a glTF skin from a Babylon skeleton
|
312
|
-
* @param nodeMap Babylon transform nodes
|
313
|
-
* @param binaryWriter Buffer to write binary data to
|
314
|
-
* @returns Node mapping of unique id to index
|
315
|
-
*/
|
316
|
-
private _createSkinsAsync;
|
317
|
-
}
|
318
|
-
/**
|
319
|
-
* @internal
|
320
|
-
*
|
321
|
-
* Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
|
322
|
-
*/
|
323
|
-
export declare class _BinaryWriter {
|
324
|
-
/**
|
325
|
-
* Array buffer which stores all binary data
|
326
|
-
*/
|
327
|
-
private _arrayBuffer;
|
328
|
-
/**
|
329
|
-
* View of the array buffer
|
330
|
-
*/
|
331
|
-
private _dataView;
|
332
|
-
/**
|
333
|
-
* byte offset of data in array buffer
|
334
|
-
*/
|
335
|
-
private _byteOffset;
|
336
|
-
/**
|
337
|
-
* Initialize binary writer with an initial byte length
|
338
|
-
* @param byteLength Initial byte length of the array buffer
|
339
|
-
*/
|
340
|
-
constructor(byteLength: number);
|
341
|
-
/**
|
342
|
-
* Resize the array buffer to the specified byte length
|
343
|
-
* @param byteLength The new byte length
|
344
|
-
* @returns The resized array buffer
|
345
|
-
*/
|
346
|
-
private _resizeBuffer;
|
347
|
-
/**
|
348
|
-
* Get an array buffer with the length of the byte offset
|
349
|
-
* @returns ArrayBuffer resized to the byte offset
|
350
|
-
*/
|
351
|
-
getArrayBuffer(): ArrayBuffer;
|
352
|
-
/**
|
353
|
-
* Get the byte offset of the array buffer
|
354
|
-
* @returns byte offset
|
355
|
-
*/
|
356
|
-
getByteOffset(): number;
|
357
|
-
/**
|
358
|
-
* Stores an UInt8 in the array buffer
|
359
|
-
* @param entry
|
360
|
-
* @param byteOffset If defined, specifies where to set the value as an offset.
|
361
|
-
*/
|
362
|
-
setUInt8(entry: number, byteOffset?: number): void;
|
363
|
-
/**
|
364
|
-
* Stores an UInt16 in the array buffer
|
365
|
-
* @param entry
|
366
|
-
* @param byteOffset If defined, specifies where to set the value as an offset.
|
367
|
-
*/
|
368
|
-
setUInt16(entry: number, byteOffset?: number): void;
|
369
|
-
/**
|
370
|
-
* Gets an UInt32 in the array buffer
|
371
|
-
* @param byteOffset If defined, specifies where to set the value as an offset.
|
372
|
-
* @returns entry
|
373
|
-
*/
|
374
|
-
getUInt32(byteOffset: number): number;
|
375
|
-
getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
|
376
|
-
setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
|
377
|
-
getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
|
378
|
-
setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
|
379
|
-
/**
|
380
|
-
* Stores a Float32 in the array buffer
|
381
|
-
* @param entry
|
382
|
-
* @param byteOffset
|
383
|
-
*/
|
384
|
-
setFloat32(entry: number, byteOffset?: number): void;
|
385
|
-
/**
|
386
|
-
* Stores an UInt32 in the array buffer
|
387
|
-
* @param entry
|
388
|
-
* @param byteOffset If defined, specifies where to set the value as an offset.
|
389
|
-
*/
|
390
|
-
setUInt32(entry: number, byteOffset?: number): void;
|
391
|
-
/**
|
392
|
-
* Stores an Int16 in the array buffer
|
393
|
-
* @param entry
|
394
|
-
* @param byteOffset If defined, specifies where to set the value as an offset.
|
395
|
-
*/
|
396
|
-
setInt16(entry: number, byteOffset?: number): void;
|
397
|
-
/**
|
398
|
-
* Stores a byte in the array buffer
|
399
|
-
* @param entry
|
400
|
-
* @param byteOffset If defined, specifies where to set the value as an offset.
|
83
|
+
private _listAvailableCameras;
|
84
|
+
private _exportAndAssignCameras;
|
85
|
+
private _listAvailableSkeletons;
|
86
|
+
private _exportAndAssignSkeletons;
|
87
|
+
private _exportSceneAsync;
|
88
|
+
private _shouldExportNode;
|
89
|
+
private _exportNodesAsync;
|
90
|
+
private _collectBuffers;
|
91
|
+
private _exportBuffers;
|
92
|
+
/**
|
93
|
+
* Processes a node to be exported to the glTF file
|
94
|
+
* @returns A promise that resolves with the node index when the processing is complete, or null if the node should not be exported
|
95
|
+
* @internal
|
401
96
|
*/
|
402
|
-
|
97
|
+
private _exportNodeAsync;
|
98
|
+
private _exportIndices;
|
99
|
+
private _exportVertexBuffer;
|
100
|
+
private _exportMaterialAsync;
|
101
|
+
private _exportMeshAsync;
|
403
102
|
}
|