@babylonjs/serializers 9.26.2 → 9.27.0
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/KHR_interactivity.d.ts +5 -0
- package/glTF/2.0/Extensions/KHR_interactivity.js +8 -0
- package/glTF/2.0/Extensions/KHR_interactivity.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_interactivity.pure.d.ts +29 -0
- package/glTF/2.0/Extensions/KHR_interactivity.pure.js +74 -0
- package/glTF/2.0/Extensions/KHR_interactivity.pure.js.map +1 -0
- package/glTF/2.0/Extensions/index.d.ts +1 -0
- package/glTF/2.0/Extensions/index.js +1 -0
- package/glTF/2.0/Extensions/index.js.map +1 -1
- package/glTF/2.0/Extensions/pure.d.ts +1 -0
- package/glTF/2.0/Extensions/pure.js +1 -0
- package/glTF/2.0/Extensions/pure.js.map +1 -1
- package/glTF/2.0/glTFAnimation.d.ts +9 -1
- package/glTF/2.0/glTFAnimation.js +9 -1
- package/glTF/2.0/glTFAnimation.js.map +1 -1
- package/glTF/2.0/glTFExporter.d.ts +17 -2
- package/glTF/2.0/glTFExporter.js +80 -6
- package/glTF/2.0/glTFExporter.js.map +1 -1
- package/glTF/2.0/glTFSerializer.d.ts +80 -1
- package/glTF/2.0/glTFSerializer.js.map +1 -1
- package/package.json +4 -3
|
@@ -1,11 +1,84 @@
|
|
|
1
1
|
import { type Node } from "@babylonjs/core/node.js";
|
|
2
2
|
import { type Scene } from "@babylonjs/core/scene.js";
|
|
3
3
|
import { type Animation } from "@babylonjs/core/Animations/animation.js";
|
|
4
|
+
import { type AnimationGroup } from "@babylonjs/core/Animations/animationGroup.js";
|
|
5
|
+
import { type Camera } from "@babylonjs/core/Cameras/camera.js";
|
|
6
|
+
import { type Material } from "@babylonjs/core/Materials/material.js";
|
|
7
|
+
import { type IKHRInteractivity } from "babylonjs-gltf2interface";
|
|
4
8
|
import { type GLTFData } from "./glTFData.js";
|
|
9
|
+
/**
|
|
10
|
+
* Indexed glTF root collections that KHR_interactivity references can target.
|
|
11
|
+
*/
|
|
12
|
+
export type KhrInteractivityRootCollection = "nodes" | "animations" | "cameras" | "materials" | "meshes" | "textures" | "images" | "samplers" | "skins" | "scenes";
|
|
5
13
|
/**
|
|
6
14
|
* Mesh compression methods.
|
|
7
15
|
*/
|
|
8
16
|
export type MeshCompressionMethod = "None" | "Draco";
|
|
17
|
+
/**
|
|
18
|
+
* Final entity remapping context exposed to a KHR_interactivity export provider.
|
|
19
|
+
*/
|
|
20
|
+
export interface IKHRInteractivityExportContext {
|
|
21
|
+
/**
|
|
22
|
+
* Gets the final number of glTF nodes.
|
|
23
|
+
* @returns final glTF node count
|
|
24
|
+
*/
|
|
25
|
+
getNodeCount(): number;
|
|
26
|
+
/**
|
|
27
|
+
* Gets the final glTF node index for a Babylon node.
|
|
28
|
+
* @param node Babylon node to resolve
|
|
29
|
+
* @returns final glTF node index, or undefined when the node was not exported
|
|
30
|
+
*/
|
|
31
|
+
getNodeIndex(node: Node): number | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the final glTF animation index for a Babylon animation group.
|
|
34
|
+
* @param animation Babylon animation group to resolve
|
|
35
|
+
* @returns final glTF animation index, or undefined when the animation was not exported
|
|
36
|
+
*/
|
|
37
|
+
getAnimationIndex(animation: AnimationGroup): number | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Gets the final glTF camera index for a Babylon camera.
|
|
40
|
+
* @param camera Babylon camera to resolve
|
|
41
|
+
* @returns final glTF camera index, or undefined when the camera was not exported
|
|
42
|
+
*/
|
|
43
|
+
getCameraIndex(camera: Camera): number | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Gets the final glTF material index for a Babylon material.
|
|
46
|
+
* @param material Babylon material to resolve
|
|
47
|
+
* @returns final glTF material index, or undefined when the material was not exported
|
|
48
|
+
*/
|
|
49
|
+
getMaterialIndex(material: Material): number | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Gets the final glTF index for an imported Babylon entity in a root collection.
|
|
52
|
+
* @param collection target glTF root collection
|
|
53
|
+
* @param entity imported Babylon entity associated with the source entry
|
|
54
|
+
* @returns final glTF index, or undefined when the entity was not exported uniquely
|
|
55
|
+
*/
|
|
56
|
+
getRootIndex?(collection: KhrInteractivityRootCollection, entity: object): number | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Writes a companion extension on an already-exported glTF node.
|
|
59
|
+
* @param nodeIndex final glTF node index
|
|
60
|
+
* @param extensionName companion extension name
|
|
61
|
+
* @param value companion extension payload
|
|
62
|
+
*/
|
|
63
|
+
setNodeExtension(nodeIndex: number, extensionName: string, value: unknown): void;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Supplies a detached canonical KHR_interactivity document to the glTF serializer.
|
|
67
|
+
*/
|
|
68
|
+
export interface IKHRInteractivityExportProvider {
|
|
69
|
+
/** Whether KHR_interactivity must be listed in extensionsRequired. */
|
|
70
|
+
readonly required: boolean;
|
|
71
|
+
/** Additional operation or companion extensions referenced by the graph. */
|
|
72
|
+
readonly additionalExtensionsUsed: readonly string[];
|
|
73
|
+
/** Additional extensions that must be listed in extensionsRequired. */
|
|
74
|
+
readonly additionalExtensionsRequired: readonly string[];
|
|
75
|
+
/**
|
|
76
|
+
* Builds the extension after final glTF entity indices are available.
|
|
77
|
+
* @param context final serializer remapping context
|
|
78
|
+
* @returns canonical KHR_interactivity extension payload
|
|
79
|
+
*/
|
|
80
|
+
build(context: IKHRInteractivityExportContext): IKHRInteractivity;
|
|
81
|
+
}
|
|
9
82
|
/**
|
|
10
83
|
* Holds a collection of exporter options and parameters
|
|
11
84
|
*/
|
|
@@ -42,7 +115,8 @@ export interface IExportOptions {
|
|
|
42
115
|
*/
|
|
43
116
|
exportUnusedUVs?: boolean;
|
|
44
117
|
/**
|
|
45
|
-
* Remove no-op root nodes when possible. Defaults to true.
|
|
118
|
+
* Remove no-op root nodes when possible. Defaults to true. No-op roots are preserved when
|
|
119
|
+
* {@link khrInteractivity} is provided because the graph may reference them.
|
|
46
120
|
*/
|
|
47
121
|
removeNoopRootNodes?: boolean;
|
|
48
122
|
/**
|
|
@@ -54,6 +128,11 @@ export interface IExportOptions {
|
|
|
54
128
|
* Indicates what compression method to apply to mesh data.
|
|
55
129
|
*/
|
|
56
130
|
meshCompressionMethod?: MeshCompressionMethod;
|
|
131
|
+
/**
|
|
132
|
+
* Canonical KHR_interactivity export provider. The provider is evaluated only after scene
|
|
133
|
+
* nodes and animations have their final glTF indices.
|
|
134
|
+
*/
|
|
135
|
+
khrInteractivity?: IKHRInteractivityExportProvider;
|
|
57
136
|
}
|
|
58
137
|
/**
|
|
59
138
|
* Class for generating glTF data from a Babylon scene.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glTFSerializer.js","sourceRoot":"","sources":["../../../../../dev/serializers/src/glTF/2.0/glTFSerializer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"glTFSerializer.js","sourceRoot":"","sources":["../../../../../dev/serializers/src/glTF/2.0/glTFSerializer.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAgJ9C;;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 AnimationGroup } from \"core/Animations/animationGroup\";\r\nimport { type Camera } from \"core/Cameras/camera\";\r\nimport { type Material } from \"core/Materials/material\";\r\nimport { type IKHRInteractivity } from \"babylonjs-gltf2interface\";\r\nimport { type GLTFData } from \"./glTFData\";\r\nimport { GLTFExporter } from \"./glTFExporter\";\r\n\r\n/**\r\n * Indexed glTF root collections that KHR_interactivity references can target.\r\n */\r\nexport type KhrInteractivityRootCollection = \"nodes\" | \"animations\" | \"cameras\" | \"materials\" | \"meshes\" | \"textures\" | \"images\" | \"samplers\" | \"skins\" | \"scenes\";\r\n\r\n/**\r\n * Mesh compression methods.\r\n */\r\nexport type MeshCompressionMethod = \"None\" | \"Draco\";\r\n\r\n/**\r\n * Final entity remapping context exposed to a KHR_interactivity export provider.\r\n */\r\nexport interface IKHRInteractivityExportContext {\r\n /**\r\n * Gets the final number of glTF nodes.\r\n * @returns final glTF node count\r\n */\r\n getNodeCount(): number;\r\n /**\r\n * Gets the final glTF node index for a Babylon node.\r\n * @param node Babylon node to resolve\r\n * @returns final glTF node index, or undefined when the node was not exported\r\n */\r\n getNodeIndex(node: Node): number | undefined;\r\n /**\r\n * Gets the final glTF animation index for a Babylon animation group.\r\n * @param animation Babylon animation group to resolve\r\n * @returns final glTF animation index, or undefined when the animation was not exported\r\n */\r\n getAnimationIndex(animation: AnimationGroup): number | undefined;\r\n /**\r\n * Gets the final glTF camera index for a Babylon camera.\r\n * @param camera Babylon camera to resolve\r\n * @returns final glTF camera index, or undefined when the camera was not exported\r\n */\r\n getCameraIndex(camera: Camera): number | undefined;\r\n /**\r\n * Gets the final glTF material index for a Babylon material.\r\n * @param material Babylon material to resolve\r\n * @returns final glTF material index, or undefined when the material was not exported\r\n */\r\n getMaterialIndex(material: Material): number | undefined;\r\n /**\r\n * Gets the final glTF index for an imported Babylon entity in a root collection.\r\n * @param collection target glTF root collection\r\n * @param entity imported Babylon entity associated with the source entry\r\n * @returns final glTF index, or undefined when the entity was not exported uniquely\r\n */\r\n getRootIndex?(collection: KhrInteractivityRootCollection, entity: object): number | undefined;\r\n /**\r\n * Writes a companion extension on an already-exported glTF node.\r\n * @param nodeIndex final glTF node index\r\n * @param extensionName companion extension name\r\n * @param value companion extension payload\r\n */\r\n setNodeExtension(nodeIndex: number, extensionName: string, value: unknown): void;\r\n}\r\n\r\n/**\r\n * Supplies a detached canonical KHR_interactivity document to the glTF serializer.\r\n */\r\nexport interface IKHRInteractivityExportProvider {\r\n /** Whether KHR_interactivity must be listed in extensionsRequired. */\r\n readonly required: boolean;\r\n /** Additional operation or companion extensions referenced by the graph. */\r\n readonly additionalExtensionsUsed: readonly string[];\r\n /** Additional extensions that must be listed in extensionsRequired. */\r\n readonly additionalExtensionsRequired: readonly string[];\r\n /**\r\n * Builds the extension after final glTF entity indices are available.\r\n * @param context final serializer remapping context\r\n * @returns canonical KHR_interactivity extension payload\r\n */\r\n build(context: IKHRInteractivityExportContext): IKHRInteractivity;\r\n}\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 /**\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. No-op roots are preserved when\r\n * {@link khrInteractivity} is provided because the graph may reference them.\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 * Canonical KHR_interactivity export provider. The provider is evaluated only after scene\r\n * nodes and animations have their final glTF indices.\r\n */\r\n khrInteractivity?: IKHRInteractivityExportProvider;\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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@babylonjs/serializers",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.27.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"module": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"postcompile": "build-tools -c add-js-to-es6"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@babylonjs/core": "9.
|
|
21
|
+
"@babylonjs/core": "9.27.0",
|
|
22
22
|
"@dev/build-tools": "^1.0.0",
|
|
23
23
|
"@dev/serializers": "^1.0.0",
|
|
24
|
-
"babylonjs-gltf2interface": "9.
|
|
24
|
+
"babylonjs-gltf2interface": "9.27.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@babylonjs/core": "^9.0.0",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"glTF/2.0/Extensions/EXT_texture_avif.js",
|
|
47
47
|
"glTF/2.0/Extensions/EXT_texture_webp.js",
|
|
48
48
|
"glTF/2.0/Extensions/KHR_draco_mesh_compression.js",
|
|
49
|
+
"glTF/2.0/Extensions/KHR_interactivity.js",
|
|
49
50
|
"glTF/2.0/Extensions/KHR_lights_punctual.js",
|
|
50
51
|
"glTF/2.0/Extensions/KHR_materials_anisotropy.js",
|
|
51
52
|
"glTF/2.0/Extensions/KHR_materials_diffuse_roughness.js",
|