@onerjs/serializers 8.29.3 → 8.29.5
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/glTFExporter.d.ts +2 -0
- package/glTF/2.0/glTFExporter.js +11 -0
- package/glTF/2.0/glTFExporter.js.map +1 -1
- package/glTF/2.0/glTFSerializer.d.ts +2 -8
- package/glTF/2.0/glTFSerializer.js +0 -17
- package/glTF/2.0/glTFSerializer.js.map +1 -1
- package/package.json +3 -3
- package/glTF/2.0/glTFExporter2.d.ts +0 -113
- package/glTF/2.0/glTFExporter2.js +0 -1198
- package/glTF/2.0/glTFExporter2.js.map +0 -1
|
@@ -2,6 +2,7 @@ import type { Node } from "@onerjs/core/node.js";
|
|
|
2
2
|
import type { Scene } from "@onerjs/core/scene.js";
|
|
3
3
|
import type { Animation } from "@onerjs/core/Animations/animation.js";
|
|
4
4
|
import type { GLTFData } from "./glTFData.js";
|
|
5
|
+
import type { Material } from "@onerjs/core/Materials/material.js";
|
|
5
6
|
/**
|
|
6
7
|
* Mesh compression methods.
|
|
7
8
|
*/
|
|
@@ -29,6 +30,7 @@ export interface IExportOptions {
|
|
|
29
30
|
* @returns the data to store into the glTF extras field
|
|
30
31
|
*/
|
|
31
32
|
metadataSelector?(metadata: any): any;
|
|
33
|
+
shouldExportMaterial?(material: Material): boolean;
|
|
32
34
|
/**
|
|
33
35
|
* The sample rate to bake animation curves. Defaults to 1 / 60.
|
|
34
36
|
*/
|
|
@@ -83,12 +85,4 @@ export declare class GLTF2Export {
|
|
|
83
85
|
* @returns Returns the exported data
|
|
84
86
|
*/
|
|
85
87
|
static GLBAsync(scene: Scene, fileName: string, options?: IExportOptions): Promise<GLTFData>;
|
|
86
|
-
/**
|
|
87
|
-
* Exports the scene to .glb file format
|
|
88
|
-
* @param scene Babylon scene
|
|
89
|
-
* @param fileName Name to use for the .glb file
|
|
90
|
-
* @param options Exporter options
|
|
91
|
-
* @returns Returns the exported data
|
|
92
|
-
*/
|
|
93
|
-
static GLBAsync2(scene: Scene, fileName: string, options?: IExportOptions): Promise<GLTFData>;
|
|
94
88
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { GLTFExporter } from "./glTFExporter.js";
|
|
2
|
-
import { GLTFExporter as GLTFExporter2 } from "./glTFExporter2.js";
|
|
3
2
|
/**
|
|
4
3
|
* Class for generating glTF data from a Babylon scene.
|
|
5
4
|
*/
|
|
@@ -36,21 +35,5 @@ export class GLTF2Export {
|
|
|
36
35
|
exporter.dispose();
|
|
37
36
|
return data;
|
|
38
37
|
}
|
|
39
|
-
/**
|
|
40
|
-
* Exports the scene to .glb file format
|
|
41
|
-
* @param scene Babylon scene
|
|
42
|
-
* @param fileName Name to use for the .glb file
|
|
43
|
-
* @param options Exporter options
|
|
44
|
-
* @returns Returns the exported data
|
|
45
|
-
*/
|
|
46
|
-
static async GLBAsync2(scene, fileName, options) {
|
|
47
|
-
if (!options || !options.exportWithoutWaitingForScene) {
|
|
48
|
-
await scene.whenReadyAsync();
|
|
49
|
-
}
|
|
50
|
-
const exporter = new GLTFExporter2(scene, options);
|
|
51
|
-
const data = await exporter.generateGLBAsync(fileName.replace(/\.[^/.]+$/, ""));
|
|
52
|
-
exporter.dispose();
|
|
53
|
-
return data;
|
|
54
|
-
}
|
|
55
38
|
}
|
|
56
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,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
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;AA6E9C;;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;QACnB,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\nimport type { Material } from \"core/Materials/material\";\r\n\r\n/**\r\n * Mesh compression methods.\r\n */\r\nexport type MeshCompressionMethod = \"None\" | \"Draco\";\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 to extract the part of the scene or node's `metadata` that will populate the corresponding\r\n * glTF object's `extras` field. If not defined, `node.metadata.gltf.extras` will be used.\r\n * @param metadata source metadata to read from\r\n * @returns the data to store into the glTF extras field\r\n */\r\n metadataSelector?(metadata: any): any;\r\n\r\n shouldExportMaterial?(material: Material): boolean;\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 * Indicates what compression method to apply to mesh data.\r\n */\r\n meshCompressionMethod?: MeshCompressionMethod;\r\n\r\n /**\r\n * Indicates if force convert to right handed pos;\r\n */\r\n convertToRightHanded?: boolean;\r\n /**\r\n * Indicates if force convert to right handed pos;\r\n */\r\n convectSkeletonToTightHanded?: 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 return data;\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onerjs/serializers",
|
|
3
|
-
"version": "8.29.
|
|
3
|
+
"version": "8.29.5",
|
|
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
|
-
"@onerjs/core": "^8.29.
|
|
21
|
+
"@onerjs/core": "^8.29.5",
|
|
22
22
|
"@dev/build-tools": "^1.0.0",
|
|
23
23
|
"@lts/serializers": "^1.0.0",
|
|
24
|
-
"babylonjs-gltf2interface": "^8.29.
|
|
24
|
+
"babylonjs-gltf2interface": "^8.29.5"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@onerjs/core": "^8.0.0",
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import type { IBufferView, IAccessor, INode, IScene, IMesh, IMaterial, ITexture, IImage, ISampler, IAnimation, IMeshPrimitive, IGLTF, ITextureInfo, ISkin, ICamera, ImageMimeType } from "babylonjs-gltf2interface";
|
|
2
|
-
import type { Nullable } from "@onerjs/core/types.js";
|
|
3
|
-
import type { Node } from "@onerjs/core/node.js";
|
|
4
|
-
import type { BaseTexture } from "@onerjs/core/Materials/Textures/baseTexture.js";
|
|
5
|
-
import { Material } from "@onerjs/core/Materials/material.js";
|
|
6
|
-
import type { Scene } from "@onerjs/core/scene.js";
|
|
7
|
-
import type { IGLTFExporterExtensionV2 } from "./glTFExporterExtension.js";
|
|
8
|
-
import { GLTFMaterialExporter } from "./glTFMaterialExporter.js";
|
|
9
|
-
import type { IExportOptions } from "./glTFSerializer.js";
|
|
10
|
-
import { GLTFData } from "./glTFData.js";
|
|
11
|
-
import { BufferManager } from "./bufferManager.js";
|
|
12
|
-
/** @internal */
|
|
13
|
-
export declare class GLTFExporter {
|
|
14
|
-
readonly _glTF: IGLTF;
|
|
15
|
-
readonly _animations: IAnimation[];
|
|
16
|
-
readonly _accessors: IAccessor[];
|
|
17
|
-
readonly _bufferViews: IBufferView[];
|
|
18
|
-
readonly _cameras: ICamera[];
|
|
19
|
-
readonly _images: IImage[];
|
|
20
|
-
readonly _materials: IMaterial[];
|
|
21
|
-
readonly _meshes: IMesh[];
|
|
22
|
-
readonly _nodes: INode[];
|
|
23
|
-
readonly _samplers: ISampler[];
|
|
24
|
-
readonly _scenes: IScene[];
|
|
25
|
-
readonly _skins: ISkin[];
|
|
26
|
-
readonly _textures: ITexture[];
|
|
27
|
-
readonly _babylonScene: Scene;
|
|
28
|
-
readonly _imageData: {
|
|
29
|
-
[fileName: string]: {
|
|
30
|
-
data: ArrayBuffer;
|
|
31
|
-
mimeType: ImageMimeType;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Baked animation sample rate
|
|
36
|
-
*/
|
|
37
|
-
private _animationSampleRate;
|
|
38
|
-
private readonly _options;
|
|
39
|
-
_shouldUseGlb: boolean;
|
|
40
|
-
readonly _materialExporter: GLTFMaterialExporter;
|
|
41
|
-
private readonly _extensions;
|
|
42
|
-
readonly _bufferManager: BufferManager;
|
|
43
|
-
private readonly _shouldExportNodeMap;
|
|
44
|
-
private readonly _nodeMap;
|
|
45
|
-
readonly _materialMap: Map<Material, number>;
|
|
46
|
-
private readonly _camerasMap;
|
|
47
|
-
private readonly _nodesCameraMap;
|
|
48
|
-
private readonly _skinMap;
|
|
49
|
-
private readonly _nodesSkinMap;
|
|
50
|
-
readonly _materialNeedsUVsSet: Set<Material>;
|
|
51
|
-
private static readonly _ExtensionNames;
|
|
52
|
-
private static readonly _ExtensionFactories;
|
|
53
|
-
private static readonly _ExtensionOrders;
|
|
54
|
-
private _ApplyExtension;
|
|
55
|
-
private _ApplyExtensions;
|
|
56
|
-
_extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node, nodeMap: Map<Node, number>, convertToRightHanded: boolean): Promise<Nullable<INode>>;
|
|
57
|
-
_extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
|
|
58
|
-
/**
|
|
59
|
-
* Get additional textures for a material
|
|
60
|
-
* @param context The context when loading the asset
|
|
61
|
-
* @param material The glTF material
|
|
62
|
-
* @param babylonMaterial The Babylon.js material
|
|
63
|
-
* @returns List of additional textures
|
|
64
|
-
*/
|
|
65
|
-
_extensionsPostExportMaterialAdditionalTexturesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<BaseTexture[]>;
|
|
66
|
-
_extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
|
|
67
|
-
_extensionsPostExportMeshPrimitive(primitive: IMeshPrimitive): void;
|
|
68
|
-
_extensionsPreGenerateBinaryAsync(): Promise<void>;
|
|
69
|
-
private _forEachExtensions;
|
|
70
|
-
private _extensionsOnExporting;
|
|
71
|
-
private _loadExtensions;
|
|
72
|
-
constructor(babylonScene?: Nullable<Scene>, options?: IExportOptions);
|
|
73
|
-
dispose(): void;
|
|
74
|
-
get options(): Required<IExportOptions>;
|
|
75
|
-
static RegisterExtension(name: string, factory: (exporter: GLTFExporter) => IGLTFExporterExtensionV2, order?: number): void;
|
|
76
|
-
static UnregisterExtension(name: string): boolean;
|
|
77
|
-
private _generateJSON;
|
|
78
|
-
generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
|
|
79
|
-
private _generateBinaryAsync;
|
|
80
|
-
/**
|
|
81
|
-
* Pads the number to a multiple of 4
|
|
82
|
-
* @param num number to pad
|
|
83
|
-
* @returns padded number
|
|
84
|
-
*/
|
|
85
|
-
private _getPadding;
|
|
86
|
-
generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
|
|
87
|
-
private _setNodeTransformation;
|
|
88
|
-
private _setCameraTransformation;
|
|
89
|
-
private _listAvailableCameras;
|
|
90
|
-
private _exportAndAssignCameras;
|
|
91
|
-
private _listAvailableSkeletons;
|
|
92
|
-
private _exportAndAssignSkeletons;
|
|
93
|
-
private _exportSceneAsync;
|
|
94
|
-
private _shouldExportNode;
|
|
95
|
-
private _exportNodesAsync;
|
|
96
|
-
private _collectBuffers;
|
|
97
|
-
private _exportBuffers;
|
|
98
|
-
/**
|
|
99
|
-
* Processes a node to be exported to the glTF file
|
|
100
|
-
* @returns A promise that resolves once the node has been exported
|
|
101
|
-
* @internal
|
|
102
|
-
*/
|
|
103
|
-
private _exportNodeAsync;
|
|
104
|
-
/**
|
|
105
|
-
* Creates a glTF node from a Babylon.js node. If skipped, returns null.
|
|
106
|
-
* @internal
|
|
107
|
-
*/
|
|
108
|
-
private _createNodeAsync;
|
|
109
|
-
private _exportIndices;
|
|
110
|
-
private _exportVertexBuffer;
|
|
111
|
-
private _exportMaterialAsync;
|
|
112
|
-
private _exportMeshAsync;
|
|
113
|
-
}
|