@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
@@ -1,58 +1,39 @@
|
|
1
|
-
import {
|
1
|
+
import { GLTFExporter } from "./glTFExporter.js";
|
2
2
|
/**
|
3
3
|
* Class for generating glTF data from a Babylon scene.
|
4
4
|
*/
|
5
5
|
export class GLTF2Export {
|
6
6
|
/**
|
7
|
-
* Exports the
|
8
|
-
* @param scene Babylon scene
|
9
|
-
* @param
|
7
|
+
* Exports the scene to .gltf file format
|
8
|
+
* @param scene Babylon scene
|
9
|
+
* @param fileName Name to use for the .gltf file
|
10
10
|
* @param options Exporter options
|
11
|
-
* @returns Returns
|
12
|
-
* as keys and their data and paths as values
|
11
|
+
* @returns Returns the exported data
|
13
12
|
*/
|
14
|
-
static GLTFAsync(scene,
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
return Promise.resolve().then(() => {
|
23
|
-
if (options && options.exportWithoutWaitingForScene) {
|
24
|
-
return Promise.resolve();
|
25
|
-
}
|
26
|
-
else {
|
27
|
-
return scene.whenReadyAsync();
|
28
|
-
}
|
29
|
-
});
|
30
|
-
}
|
31
|
-
static _PostExportAsync(scene, glTFData, options) {
|
32
|
-
return Promise.resolve().then(() => {
|
33
|
-
if (options && options.exportWithoutWaitingForScene) {
|
34
|
-
return glTFData;
|
35
|
-
}
|
36
|
-
else {
|
37
|
-
return glTFData;
|
38
|
-
}
|
39
|
-
});
|
13
|
+
static async GLTFAsync(scene, fileName, options) {
|
14
|
+
if (!options || !options.exportWithoutWaitingForScene) {
|
15
|
+
await scene.whenReadyAsync();
|
16
|
+
}
|
17
|
+
const exporter = new GLTFExporter(scene, options);
|
18
|
+
const data = await exporter.generateGLTFAsync(fileName.replace(/\.[^/.]+$/, ""));
|
19
|
+
exporter.dispose();
|
20
|
+
return data;
|
40
21
|
}
|
41
22
|
/**
|
42
|
-
* Exports the
|
43
|
-
* @param scene Babylon scene
|
44
|
-
* @param
|
23
|
+
* Exports the scene to .glb file format
|
24
|
+
* @param scene Babylon scene
|
25
|
+
* @param fileName Name to use for the .glb file
|
45
26
|
* @param options Exporter options
|
46
|
-
* @returns Returns
|
27
|
+
* @returns Returns the exported data
|
47
28
|
*/
|
48
|
-
static GLBAsync(scene,
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
29
|
+
static async GLBAsync(scene, fileName, options) {
|
30
|
+
if (!options || !options.exportWithoutWaitingForScene) {
|
31
|
+
await scene.whenReadyAsync();
|
32
|
+
}
|
33
|
+
const exporter = new GLTFExporter(scene, options);
|
34
|
+
const data = await exporter.generateGLBAsync(fileName.replace(/\.[^/.]+$/, ""));
|
35
|
+
exporter.dispose();
|
36
|
+
return data;
|
56
37
|
}
|
57
38
|
}
|
58
39
|
//# sourceMappingURL=glTFSerializer.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"glTFSerializer.js","sourceRoot":"","sources":["../../../../../dev/serializers/src/glTF/2.0/glTFSerializer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"glTFSerializer.js","sourceRoot":"","sources":["../../../../../dev/serializers/src/glTF/2.0/glTFSerializer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAsD9C;;GAEG;AACH,MAAM,OAAO,WAAW;IACpB;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,KAAY,EAAE,QAAgB,EAAE,OAAwB;QAClF,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,4BAA4B,EAAE,CAAC;YACpD,MAAM,KAAK,CAAC,cAAc,EAAE,CAAC;QACjC,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAClD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC;QACjF,QAAQ,CAAC,OAAO,EAAE,CAAC;QAEnB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAY,EAAE,QAAgB,EAAE,OAAwB;QACjF,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,4BAA4B,EAAE,CAAC;YACpD,MAAM,KAAK,CAAC,cAAc,EAAE,CAAC;QACjC,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAClD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC;QAChF,QAAQ,CAAC,OAAO,EAAE,CAAC;QAEnB,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { Node } from \"core/node\";\r\nimport type { Scene } from \"core/scene\";\r\nimport type { Animation } from \"core/Animations/animation\";\r\nimport type { GLTFData } from \"./glTFData\";\r\nimport { GLTFExporter } from \"./glTFExporter\";\r\n\r\n/**\r\n * Holds a collection of exporter options and parameters\r\n */\r\nexport interface IExportOptions {\r\n /**\r\n * Function which indicates whether a babylon node should be exported or not\r\n * @param node source Babylon node. It is used to check whether it should be exported to glTF or not\r\n * @returns boolean, which indicates whether the node should be exported (true) or not (false)\r\n */\r\n shouldExportNode?(node: Node): boolean;\r\n\r\n /**\r\n * Function which indicates whether an animation on the scene should be exported or not\r\n * @param animation source animation\r\n * @returns boolean, which indicates whether the animation should be exported (true) or not (false)\r\n */\r\n shouldExportAnimation?(animation: Animation): boolean;\r\n\r\n /**\r\n * Function used to extract the part of node's metadata that will be exported into glTF node extras\r\n * @param metadata source metadata to read from\r\n * @returns the data to store to glTF node extras\r\n */\r\n metadataSelector?(metadata: any): any;\r\n\r\n /**\r\n * The sample rate to bake animation curves. Defaults to 1 / 60.\r\n */\r\n animationSampleRate?: number;\r\n\r\n /**\r\n * Begin serialization without waiting for the scene to be ready. Defaults to false.\r\n */\r\n exportWithoutWaitingForScene?: boolean;\r\n\r\n /**\r\n * Indicates if unused vertex uv attributes should be included in export. Defaults to false.\r\n */\r\n exportUnusedUVs?: boolean;\r\n\r\n /**\r\n * Remove no-op root nodes when possible. Defaults to true.\r\n */\r\n removeNoopRootNodes?: boolean;\r\n\r\n /**\r\n * Indicates if coordinate system swapping root nodes should be included in export. Defaults to false.\r\n * @deprecated Please use removeNoopRootNodes instead\r\n */\r\n includeCoordinateSystemConversionNodes?: boolean;\r\n}\r\n\r\n/**\r\n * Class for generating glTF data from a Babylon scene.\r\n */\r\nexport class GLTF2Export {\r\n /**\r\n * Exports the scene to .gltf file format\r\n * @param scene Babylon scene\r\n * @param fileName Name to use for the .gltf file\r\n * @param options Exporter options\r\n * @returns Returns the exported data\r\n */\r\n public static async GLTFAsync(scene: Scene, fileName: string, options?: IExportOptions): Promise<GLTFData> {\r\n if (!options || !options.exportWithoutWaitingForScene) {\r\n await scene.whenReadyAsync();\r\n }\r\n\r\n const exporter = new GLTFExporter(scene, options);\r\n const data = await exporter.generateGLTFAsync(fileName.replace(/\\.[^/.]+$/, \"\"));\r\n exporter.dispose();\r\n\r\n return data;\r\n }\r\n\r\n /**\r\n * Exports the scene to .glb file format\r\n * @param scene Babylon scene\r\n * @param fileName Name to use for the .glb file\r\n * @param options Exporter options\r\n * @returns Returns the exported data\r\n */\r\n public static async GLBAsync(scene: Scene, fileName: string, options?: IExportOptions): Promise<GLTFData> {\r\n if (!options || !options.exportWithoutWaitingForScene) {\r\n await scene.whenReadyAsync();\r\n }\r\n\r\n const exporter = new GLTFExporter(scene, options);\r\n const data = await exporter.generateGLBAsync(fileName.replace(/\\.[^/.]+$/, \"\"));\r\n exporter.dispose();\r\n\r\n return data;\r\n }\r\n}\r\n"]}
|
@@ -1,46 +1,78 @@
|
|
1
|
-
import type { IBufferView, AccessorComponentType, IAccessor } from "babylonjs-gltf2interface";
|
2
|
-
import { AccessorType } from "babylonjs-gltf2interface";
|
3
|
-
import type { FloatArray, Nullable } from "@babylonjs/core/types.js";
|
1
|
+
import type { IBufferView, AccessorComponentType, IAccessor, INode } from "babylonjs-gltf2interface";
|
2
|
+
import { AccessorType, MeshPrimitiveMode } from "babylonjs-gltf2interface";
|
3
|
+
import type { FloatArray, DataArray, IndicesArray, Nullable } from "@babylonjs/core/types.js";
|
4
4
|
import type { Vector4 } from "@babylonjs/core/Maths/math.vector.js";
|
5
|
-
import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
5
|
+
import { Quaternion, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
6
|
+
import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
|
7
|
+
import type { Node } from "@babylonjs/core/node.js";
|
6
8
|
/**
|
7
|
-
*
|
9
|
+
* Creates a buffer view based on the supplied arguments
|
10
|
+
* @param bufferIndex index value of the specified buffer
|
11
|
+
* @param byteOffset byte offset value
|
12
|
+
* @param byteLength byte length of the bufferView
|
13
|
+
* @param byteStride byte distance between conequential elements
|
14
|
+
* @returns bufferView for glTF
|
8
15
|
*/
|
9
|
-
export declare
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
16
|
+
export declare function CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number): IBufferView;
|
17
|
+
/**
|
18
|
+
* Creates an accessor based on the supplied arguments
|
19
|
+
* @param bufferViewIndex The index of the bufferview referenced by this accessor
|
20
|
+
* @param type The type of the accessor
|
21
|
+
* @param componentType The datatype of components in the attribute
|
22
|
+
* @param count The number of attributes referenced by this accessor
|
23
|
+
* @param byteOffset The offset relative to the start of the bufferView in bytes
|
24
|
+
* @param minMax Minimum and maximum value of each component in this attribute
|
25
|
+
* @param normalized Specifies whether integer data values are normalized before usage
|
26
|
+
* @returns accessor for glTF
|
27
|
+
*/
|
28
|
+
export declare function CreateAccessor(bufferViewIndex: number, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, minMax?: Nullable<{
|
29
|
+
min: number[];
|
30
|
+
max: number[];
|
31
|
+
}>, normalized?: boolean): IAccessor;
|
32
|
+
export declare function GetAccessorElementCount(accessorType: AccessorType): number;
|
33
|
+
export declare function FloatsNeed16BitInteger(floatArray: FloatArray): boolean;
|
34
|
+
export declare function IsStandardVertexAttribute(type: string): boolean;
|
35
|
+
export declare function GetAccessorType(kind: string, hasVertexColorAlpha: boolean): AccessorType;
|
36
|
+
export declare function GetAttributeType(kind: string): string;
|
37
|
+
export declare function GetPrimitiveMode(fillMode: number): MeshPrimitiveMode;
|
38
|
+
export declare function IsTriangleFillMode(fillMode: number): boolean;
|
39
|
+
export declare function NormalizeTangent(tangent: Vector4 | Vector3): void;
|
40
|
+
export declare function ConvertToRightHandedPosition(value: Vector3): Vector3;
|
41
|
+
export declare function ConvertToRightHandedRotation(value: Quaternion): Quaternion;
|
42
|
+
export declare function ConvertToRightHandedNode(value: INode): void;
|
43
|
+
/**
|
44
|
+
* Rotation by 180 as glTF has a different convention than Babylon.
|
45
|
+
* @param rotation Target camera rotation.
|
46
|
+
* @returns Ref to camera rotation.
|
47
|
+
*/
|
48
|
+
export declare function ConvertCameraRotationToGLTF(rotation: Quaternion): Quaternion;
|
49
|
+
export declare function RotateNode180Y(node: INode): void;
|
50
|
+
/**
|
51
|
+
* Collapses GLTF parent and node into a single node. This is useful for removing nodes that were added by the GLTF importer.
|
52
|
+
* @param node Target parent node.
|
53
|
+
* @param parentNode Original GLTF node (Light or Camera).
|
54
|
+
*/
|
55
|
+
export declare function CollapseParentNode(node: INode, parentNode: INode): void;
|
56
|
+
/**
|
57
|
+
* Sometimes the GLTF Importer can add extra transform nodes (for lights and cameras). This checks if a parent node was added by the GLTF Importer. If so, it should be removed during serialization.
|
58
|
+
* @param babylonNode Original GLTF node (Light or Camera).
|
59
|
+
* @param parentBabylonNode Target parent node.
|
60
|
+
* @returns True if the parent node was added by the GLTF importer.
|
61
|
+
*/
|
62
|
+
export declare function IsParentAddedByImporter(babylonNode: Node, parentBabylonNode: Node): boolean;
|
63
|
+
export declare function IsNoopNode(node: Node, useRightHandedSystem: boolean): boolean;
|
64
|
+
export declare function AreIndices32Bits(indices: Nullable<IndicesArray>, count: number): boolean;
|
65
|
+
export declare function IndicesArrayToUint8Array(indices: IndicesArray, start: number, count: number, is32Bits: boolean): Uint8Array;
|
66
|
+
export declare function DataArrayToUint8Array(data: DataArray): Uint8Array;
|
67
|
+
export declare function GetMinMax(data: DataArray, vertexBuffer: VertexBuffer, start: number, count: number): {
|
68
|
+
min: number[];
|
69
|
+
max: number[];
|
70
|
+
};
|
71
|
+
/**
|
72
|
+
* Removes, in-place, object properties which have the same value as the default value.
|
73
|
+
* Useful for avoiding unnecessary properties in the glTF JSON.
|
74
|
+
* @param object the object to omit default values from
|
75
|
+
* @param defaultValues a partial object with default values
|
76
|
+
* @returns object with default values omitted
|
77
|
+
*/
|
78
|
+
export declare function OmitDefaultValues<T extends Object>(object: T, defaultValues: Partial<T>): T;
|