@onerjs/serializers 8.56.4 → 9.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.
package/exportUtils.d.ts CHANGED
@@ -7,6 +7,7 @@ import { type Node } from "@onerjs/core/node.js";
7
7
  export declare const ConvertHandednessMatrix: Matrix;
8
8
  /**
9
9
  * Checks if a node is a "noop" transform node, usually inserted by the glTF loader to correct handedness.
10
+ * Refreshes changed transforms even when the scene's render ID has not advanced.
10
11
  * @internal
11
12
  */
12
13
  export declare function IsNoopNode(node: Node, useRightHandedSystem: boolean): boolean;
package/exportUtils.js CHANGED
@@ -9,6 +9,7 @@ import { AbstractMesh } from "@onerjs/core/Meshes/abstractMesh.js";
9
9
  export const ConvertHandednessMatrix = Matrix.Compose(new Vector3(-1, 1, 1), Quaternion.Identity(), Vector3.Zero());
10
10
  /**
11
11
  * Checks if a node is a "noop" transform node, usually inserted by the glTF loader to correct handedness.
12
+ * Refreshes changed transforms even when the scene's render ID has not advanced.
12
13
  * @internal
13
14
  */
14
15
  export function IsNoopNode(node, useRightHandedSystem) {
@@ -16,14 +17,14 @@ export function IsNoopNode(node, useRightHandedSystem) {
16
17
  return false;
17
18
  }
18
19
  // Transform
20
+ const worldMatrix = node.computeWorldMatrix(!node.isSynchronized());
19
21
  if (useRightHandedSystem) {
20
- const matrix = node.getWorldMatrix();
21
- if (!matrix.equalsWithEpsilon(Matrix.IdentityReadOnly, Epsilon)) {
22
+ if (!worldMatrix.equalsWithEpsilon(Matrix.IdentityReadOnly, Epsilon)) {
22
23
  return false;
23
24
  }
24
25
  }
25
26
  else {
26
- const matrix = node.getWorldMatrix().multiplyToRef(ConvertHandednessMatrix, TmpVectors.Matrix[0]);
27
+ const matrix = worldMatrix.multiplyToRef(ConvertHandednessMatrix, TmpVectors.Matrix[0]);
27
28
  if (!matrix.equalsWithEpsilon(Matrix.IdentityReadOnly, Epsilon)) {
28
29
  return false;
29
30
  }
@@ -1 +1 @@
1
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AI,IAAI,YAAY,YAAY,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import { Matrix, Quaternion, TmpVectors, Vector3 } from \"core/Maths/math.vector\";\r\nimport { Epsilon } from \"core/Maths/math.constants\";\r\nimport { TransformNode } from \"core/Meshes/transformNode\";\r\nimport { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport { type Node } from \"core/node\";\r\n\r\n/**\r\n * Matrix that converts handedness on the X-axis. Used to convert from LH to RH and vice versa.\r\n * @internal\r\n */\r\nexport const ConvertHandednessMatrix = Matrix.Compose(new Vector3(-1, 1, 1), Quaternion.Identity(), Vector3.Zero());\r\n\r\n/**\r\n * Checks if a node is a \"noop\" transform node, usually inserted by the glTF loader to correct handedness.\r\n * @internal\r\n */\r\nexport function IsNoopNode(node: Node, useRightHandedSystem: boolean): boolean {\r\n if (!(node instanceof TransformNode)) {\r\n return false;\r\n }\r\n\r\n // Transform\r\n if (useRightHandedSystem) {\r\n const matrix = node.getWorldMatrix();\r\n if (!matrix.equalsWithEpsilon(Matrix.IdentityReadOnly, Epsilon)) {\r\n return false;\r\n }\r\n } else {\r\n const matrix = node.getWorldMatrix().multiplyToRef(ConvertHandednessMatrix, TmpVectors.Matrix[0]);\r\n if (!matrix.equalsWithEpsilon(Matrix.IdentityReadOnly, Epsilon)) {\r\n return false;\r\n }\r\n }\r\n\r\n // Geometry\r\n if (node instanceof AbstractMesh && node.geometry) {\r\n return false;\r\n }\r\n\r\n return true;\r\n}\r\n"]}
1
+ {"version":3,"file":"exportUtils.js","sourceRoot":"","sources":["../../../dev/serializers/src/exportUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjF,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAA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from \"core/Maths/math.constants\";\r\nimport { TransformNode } from \"core/Meshes/transformNode\";\r\nimport { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport { type Node } from \"core/node\";\r\n\r\n/**\r\n * Matrix that converts handedness on the X-axis. Used to convert from LH to RH and vice versa.\r\n * @internal\r\n */\r\nexport const ConvertHandednessMatrix = Matrix.Compose(new Vector3(-1, 1, 1), Quaternion.Identity(), Vector3.Zero());\r\n\r\n/**\r\n * Checks if a node is a \"noop\" transform node, usually inserted by the glTF loader to correct handedness.\r\n * Refreshes changed transforms even when the scene's render ID has not advanced.\r\n * @internal\r\n */\r\nexport function IsNoopNode(node: Node, useRightHandedSystem: boolean): boolean {\r\n if (!(node instanceof TransformNode)) {\r\n return false;\r\n }\r\n\r\n // Transform\r\n const worldMatrix = node.computeWorldMatrix(!node.isSynchronized());\r\n if (useRightHandedSystem) {\r\n if (!worldMatrix.equalsWithEpsilon(Matrix.IdentityReadOnly, Epsilon)) {\r\n return false;\r\n }\r\n } else {\r\n const matrix = worldMatrix.multiplyToRef(ConvertHandednessMatrix, TmpVectors.Matrix[0]);\r\n if (!matrix.equalsWithEpsilon(Matrix.IdentityReadOnly, Epsilon)) {\r\n return false;\r\n }\r\n }\r\n\r\n // Geometry\r\n if (node instanceof AbstractMesh && node.geometry) {\r\n return false;\r\n }\r\n\r\n return true;\r\n}\r\n"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Re-exports the pure implementation and applies the runtime registration side effect.
3
+ * Import "./KHR_interactivity.pure" for tree-shakeable, side-effect-free usage.
4
+ */
5
+ export * from "./KHR_interactivity.pure.js";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Re-exports the pure implementation and applies the runtime registration side effect.
3
+ * Import "./KHR_interactivity.pure" for tree-shakeable, side-effect-free usage.
4
+ */
5
+ export * from "./KHR_interactivity.pure.js";
6
+ import { RegisterKHR_interactivity } from "./KHR_interactivity.pure.js";
7
+ RegisterKHR_interactivity();
8
+ //# sourceMappingURL=KHR_interactivity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KHR_interactivity.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_interactivity.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,0BAA0B,CAAC;AAEzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,yBAAyB,EAAE,CAAC","sourcesContent":["/**\n * Re-exports the pure implementation and applies the runtime registration side effect.\n * Import \"./KHR_interactivity.pure\" for tree-shakeable, side-effect-free usage.\n */\nexport * from \"./KHR_interactivity.pure\";\n\nimport { RegisterKHR_interactivity } from \"./KHR_interactivity.pure\";\nRegisterKHR_interactivity();\n"]}
@@ -0,0 +1,29 @@
1
+ import { type IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
2
+ import { GLTFExporter } from "../glTFExporter.js";
3
+ /**
4
+ * [Specification](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_interactivity)
5
+ */
6
+ export declare class KHR_interactivity implements IGLTFExporterExtensionV2 {
7
+ private _exporter;
8
+ /** The extension name. */
9
+ readonly name = "KHR_interactivity";
10
+ /** Whether this extension is enabled for the current export. */
11
+ readonly enabled: boolean;
12
+ /** Whether this extension is required for the exported asset. */
13
+ readonly required: boolean;
14
+ /**
15
+ * @param _exporter owning glTF exporter
16
+ */
17
+ constructor(_exporter: GLTFExporter);
18
+ /** @internal */
19
+ dispose(): void;
20
+ /** @internal */
21
+ get wasUsed(): boolean;
22
+ /** @internal */
23
+ onExporting(): void;
24
+ }
25
+ /**
26
+ * Registers the KHR_interactivity glTF serializer extension with the {@link GLTFExporter}.
27
+ * Safe to call multiple times; only the first call has an effect.
28
+ */
29
+ export declare function RegisterKHR_interactivity(): void;
@@ -0,0 +1,74 @@
1
+ import { GLTFExporter } from "../glTFExporter.js";
2
+ const NAME = "KHR_interactivity";
3
+ /**
4
+ * [Specification](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_interactivity)
5
+ */
6
+ // eslint-disable-next-line @typescript-eslint/naming-convention
7
+ export class KHR_interactivity {
8
+ /**
9
+ * @param _exporter owning glTF exporter
10
+ */
11
+ constructor(_exporter) {
12
+ this._exporter = _exporter;
13
+ /** The extension name. */
14
+ this.name = NAME;
15
+ this.enabled = !!_exporter.options.khrInteractivity;
16
+ this.required = _exporter.options.khrInteractivity?.required ?? false;
17
+ }
18
+ /** @internal */
19
+ dispose() {
20
+ this._exporter = null;
21
+ }
22
+ /** @internal */
23
+ get wasUsed() {
24
+ return this.enabled;
25
+ }
26
+ /** @internal */
27
+ onExporting() {
28
+ var _a, _b, _c;
29
+ const provider = this._exporter.options.khrInteractivity;
30
+ if (!provider) {
31
+ return;
32
+ }
33
+ const extension = provider.build({
34
+ getNodeCount: () => this._exporter._nodes.length,
35
+ getNodeIndex: (node) => this._exporter._getNodeIndex(node),
36
+ getAnimationIndex: (animationGroup) => this._exporter._getAnimationIndex(animationGroup),
37
+ getCameraIndex: (camera) => this._exporter._getCameraIndex(camera),
38
+ getMaterialIndex: (material) => this._exporter._getMaterialIndex(material),
39
+ getRootIndex: (collection, entity) => this._exporter._getRootIndex(collection, entity),
40
+ setNodeExtension: (nodeIndex, extensionName, value) => this._exporter._setNodeExtension(nodeIndex, extensionName, value),
41
+ });
42
+ this._exporter._glTF.extensions[NAME] = extension;
43
+ for (const extensionName of provider.additionalExtensionsUsed) {
44
+ (_a = this._exporter._glTF).extensionsUsed || (_a.extensionsUsed = []);
45
+ if (this._exporter._glTF.extensionsUsed.indexOf(extensionName) === -1) {
46
+ this._exporter._glTF.extensionsUsed.push(extensionName);
47
+ }
48
+ }
49
+ for (const extensionName of provider.additionalExtensionsRequired) {
50
+ (_b = this._exporter._glTF).extensionsUsed || (_b.extensionsUsed = []);
51
+ if (this._exporter._glTF.extensionsUsed.indexOf(extensionName) === -1) {
52
+ this._exporter._glTF.extensionsUsed.push(extensionName);
53
+ }
54
+ (_c = this._exporter._glTF).extensionsRequired || (_c.extensionsRequired = []);
55
+ if (this._exporter._glTF.extensionsRequired.indexOf(extensionName) === -1) {
56
+ this._exporter._glTF.extensionsRequired.push(extensionName);
57
+ }
58
+ }
59
+ }
60
+ }
61
+ let _Registered = false;
62
+ /**
63
+ * Registers the KHR_interactivity glTF serializer extension with the {@link GLTFExporter}.
64
+ * Safe to call multiple times; only the first call has an effect.
65
+ */
66
+ // eslint-disable-next-line @typescript-eslint/naming-convention
67
+ export function RegisterKHR_interactivity() {
68
+ if (_Registered) {
69
+ return;
70
+ }
71
+ _Registered = true;
72
+ GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_interactivity(exporter), 200);
73
+ }
74
+ //# sourceMappingURL=KHR_interactivity.pure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KHR_interactivity.pure.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/KHR_interactivity.pure.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,IAAI,GAAG,mBAAmB,CAAC;AAEjC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,iBAAiB;IAQ1B;;OAEG;IACH,YAA2B,SAAuB;QAAvB,cAAS,GAAT,SAAS,CAAc;QAVlD,0BAA0B;QACV,SAAI,GAAG,IAAI,CAAC;QAUxB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,gBAAgB,CAAC;QACpD,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,gBAAgB,EAAE,QAAQ,IAAI,KAAK,CAAC;IAC1E,CAAC;IAED,gBAAgB;IACT,OAAO;QACT,IAAI,CAAC,SAAiB,GAAG,IAAI,CAAC;IACnC,CAAC;IAED,gBAAgB;IAChB,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,gBAAgB;IACT,WAAW;;QACd,MAA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import { GLTFExporter } from \"../glTFExporter\";\n\nconst NAME = \"KHR_interactivity\";\n\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_interactivity)\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport class KHR_interactivity implements IGLTFExporterExtensionV2 {\n /** The extension name. */\n public readonly name = NAME;\n /** Whether this extension is enabled for the current export. */\n public readonly enabled: boolean;\n /** Whether this extension is required for the exported asset. */\n public readonly required: boolean;\n\n /**\n * @param _exporter owning glTF exporter\n */\n public constructor(private _exporter: GLTFExporter) {\n this.enabled = !!_exporter.options.khrInteractivity;\n this.required = _exporter.options.khrInteractivity?.required ?? false;\n }\n\n /** @internal */\n public dispose(): void {\n (this._exporter as any) = null;\n }\n\n /** @internal */\n public get wasUsed(): boolean {\n return this.enabled;\n }\n\n /** @internal */\n public onExporting(): void {\n const provider = this._exporter.options.khrInteractivity;\n if (!provider) {\n return;\n }\n const extension = provider.build({\n getNodeCount: () => this._exporter._nodes.length,\n getNodeIndex: (node) => this._exporter._getNodeIndex(node),\n getAnimationIndex: (animationGroup) => this._exporter._getAnimationIndex(animationGroup),\n getCameraIndex: (camera) => this._exporter._getCameraIndex(camera),\n getMaterialIndex: (material) => this._exporter._getMaterialIndex(material),\n getRootIndex: (collection, entity) => this._exporter._getRootIndex(collection, entity),\n setNodeExtension: (nodeIndex, extensionName, value) => this._exporter._setNodeExtension(nodeIndex, extensionName, value),\n });\n this._exporter._glTF.extensions![NAME] = extension;\n for (const extensionName of provider.additionalExtensionsUsed) {\n this._exporter._glTF.extensionsUsed ||= [];\n if (this._exporter._glTF.extensionsUsed.indexOf(extensionName) === -1) {\n this._exporter._glTF.extensionsUsed.push(extensionName);\n }\n }\n for (const extensionName of provider.additionalExtensionsRequired) {\n this._exporter._glTF.extensionsUsed ||= [];\n if (this._exporter._glTF.extensionsUsed.indexOf(extensionName) === -1) {\n this._exporter._glTF.extensionsUsed.push(extensionName);\n }\n this._exporter._glTF.extensionsRequired ||= [];\n if (this._exporter._glTF.extensionsRequired.indexOf(extensionName) === -1) {\n this._exporter._glTF.extensionsRequired.push(extensionName);\n }\n }\n }\n}\n\nlet _Registered = false;\n\n/**\n * Registers the KHR_interactivity glTF serializer extension with the {@link GLTFExporter}.\n * Safe to call multiple times; only the first call has an effect.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function RegisterKHR_interactivity(): void {\n if (_Registered) {\n return;\n }\n _Registered = true;\n GLTFExporter.RegisterExtension(NAME, (exporter) => new KHR_interactivity(exporter), 200);\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  export * from "./EXT_mesh_gpu_instancing.js";
2
2
  export * from "./KHR_draco_mesh_compression.js";
3
3
  export * from "./KHR_lights_punctual.js";
4
+ export * from "./KHR_interactivity.js";
4
5
  export * from "./EXT_lights_area.js";
5
6
  export * from "./KHR_materials_anisotropy.js";
6
7
  export * from "./KHR_materials_clearcoat.js";
@@ -1,6 +1,7 @@
1
1
  export * from "./EXT_mesh_gpu_instancing.js";
2
2
  export * from "./KHR_draco_mesh_compression.js";
3
3
  export * from "./KHR_lights_punctual.js";
4
+ export * from "./KHR_interactivity.js";
4
5
  export * from "./EXT_lights_area.js";
5
6
  export * from "./KHR_materials_anisotropy.js";
6
7
  export * from "./KHR_materials_clearcoat.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mCAAmC,CAAC;AAClD,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mCAAmC,CAAC;AAClD,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./EXT_mesh_gpu_instancing\";\r\nexport * from \"./KHR_draco_mesh_compression\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./EXT_lights_area\";\r\nexport * from \"./KHR_materials_anisotropy\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_coat\";\r\nexport * from \"./KHR_materials_diffuse_transmission\";\r\nexport * from \"./KHR_materials_dispersion\";\r\nexport * from \"./KHR_materials_emissive_strength\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_iridescence\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_fuzz\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_transmission\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_volume\";\r\nexport * from \"./KHR_materials_volume_scatter\";\r\nexport * from \"./KHR_materials_diffuse_roughness\";\r\nexport * from \"./KHR_materials_openpbr\";\r\nexport * from \"./KHR_texture_transform\";\r\nexport * from \"./KHR_texture_basisu\";\r\nexport * from \"./EXT_texture_webp\";\r\nexport * from \"./EXT_texture_avif\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mCAAmC,CAAC;AAClD,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mCAAmC,CAAC;AAClD,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./EXT_mesh_gpu_instancing\";\r\nexport * from \"./KHR_draco_mesh_compression\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./KHR_interactivity\";\r\nexport * from \"./EXT_lights_area\";\r\nexport * from \"./KHR_materials_anisotropy\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_coat\";\r\nexport * from \"./KHR_materials_diffuse_transmission\";\r\nexport * from \"./KHR_materials_dispersion\";\r\nexport * from \"./KHR_materials_emissive_strength\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_iridescence\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_fuzz\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_transmission\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_volume\";\r\nexport * from \"./KHR_materials_volume_scatter\";\r\nexport * from \"./KHR_materials_diffuse_roughness\";\r\nexport * from \"./KHR_materials_openpbr\";\r\nexport * from \"./KHR_texture_transform\";\r\nexport * from \"./KHR_texture_basisu\";\r\nexport * from \"./EXT_texture_webp\";\r\nexport * from \"./EXT_texture_avif\";\r\n"]}
@@ -2,6 +2,7 @@
2
2
  export * from "./EXT_mesh_gpu_instancing.pure.js";
3
3
  export * from "./KHR_draco_mesh_compression.pure.js";
4
4
  export * from "./KHR_lights_punctual.pure.js";
5
+ export * from "./KHR_interactivity.pure.js";
5
6
  export * from "./EXT_lights_area.pure.js";
6
7
  export * from "./KHR_materials_anisotropy.pure.js";
7
8
  export * from "./KHR_materials_clearcoat.pure.js";
@@ -2,6 +2,7 @@
2
2
  export * from "./EXT_mesh_gpu_instancing.pure.js";
3
3
  export * from "./KHR_draco_mesh_compression.pure.js";
4
4
  export * from "./KHR_lights_punctual.pure.js";
5
+ export * from "./KHR_interactivity.pure.js";
5
6
  export * from "./EXT_lights_area.pure.js";
6
7
  export * from "./KHR_materials_anisotropy.pure.js";
7
8
  export * from "./KHR_materials_clearcoat.pure.js";
@@ -1 +1 @@
1
- {"version":3,"file":"pure.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mCAAmC,CAAC;AAClD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,iCAAiC,CAAC;AAChD,cAAc,wCAAwC,CAAC;AACvD,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC;AACvD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC","sourcesContent":["/** Pure barrel — re-exports only side-effect-free modules */\nexport * from \"./EXT_mesh_gpu_instancing.pure\";\nexport * from \"./KHR_draco_mesh_compression.pure\";\nexport * from \"./KHR_lights_punctual.pure\";\nexport * from \"./EXT_lights_area.pure\";\nexport * from \"./KHR_materials_anisotropy.pure\";\nexport * from \"./KHR_materials_clearcoat.pure\";\nexport * from \"./KHR_materials_coat.pure\";\nexport * from \"./KHR_materials_diffuse_transmission.pure\";\nexport * from \"./KHR_materials_dispersion.pure\";\nexport * from \"./KHR_materials_emissive_strength.pure\";\nexport * from \"./KHR_materials_ior.pure\";\nexport * from \"./KHR_materials_iridescence.pure\";\nexport * from \"./KHR_materials_sheen.pure\";\nexport * from \"./KHR_materials_fuzz.pure\";\nexport * from \"./KHR_materials_specular.pure\";\nexport * from \"./KHR_materials_transmission.pure\";\nexport * from \"./KHR_materials_unlit.pure\";\nexport * from \"./KHR_materials_volume.pure\";\nexport * from \"./KHR_materials_volume_scatter.pure\";\nexport * from \"./KHR_materials_diffuse_roughness.pure\";\nexport * from \"./KHR_materials_openpbr.pure\";\nexport * from \"./KHR_texture_transform.pure\";\nexport * from \"./KHR_texture_basisu.pure\";\nexport * from \"./EXT_texture_webp.pure\";\nexport * from \"./EXT_texture_avif.pure\";\n"]}
1
+ {"version":3,"file":"pure.js","sourceRoot":"","sources":["../../../../../../dev/serializers/src/glTF/2.0/Extensions/pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,mCAAmC,CAAC;AAClD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,iCAAiC,CAAC;AAChD,cAAc,wCAAwC,CAAC;AACvD,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC;AACvD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC","sourcesContent":["/** Pure barrel — re-exports only side-effect-free modules */\nexport * from \"./EXT_mesh_gpu_instancing.pure\";\nexport * from \"./KHR_draco_mesh_compression.pure\";\nexport * from \"./KHR_lights_punctual.pure\";\nexport * from \"./KHR_interactivity.pure\";\nexport * from \"./EXT_lights_area.pure\";\nexport * from \"./KHR_materials_anisotropy.pure\";\nexport * from \"./KHR_materials_clearcoat.pure\";\nexport * from \"./KHR_materials_coat.pure\";\nexport * from \"./KHR_materials_diffuse_transmission.pure\";\nexport * from \"./KHR_materials_dispersion.pure\";\nexport * from \"./KHR_materials_emissive_strength.pure\";\nexport * from \"./KHR_materials_ior.pure\";\nexport * from \"./KHR_materials_iridescence.pure\";\nexport * from \"./KHR_materials_sheen.pure\";\nexport * from \"./KHR_materials_fuzz.pure\";\nexport * from \"./KHR_materials_specular.pure\";\nexport * from \"./KHR_materials_transmission.pure\";\nexport * from \"./KHR_materials_unlit.pure\";\nexport * from \"./KHR_materials_volume.pure\";\nexport * from \"./KHR_materials_volume_scatter.pure\";\nexport * from \"./KHR_materials_diffuse_roughness.pure\";\nexport * from \"./KHR_materials_openpbr.pure\";\nexport * from \"./KHR_texture_transform.pure\";\nexport * from \"./KHR_texture_basisu.pure\";\nexport * from \"./EXT_texture_webp.pure\";\nexport * from \"./EXT_texture_avif.pure\";\n"]}
@@ -2,6 +2,7 @@ import { type IAnimation, type INode, type IBufferView, type IAccessor, Animatio
2
2
  import { type Node } from "@onerjs/core/node.js";
3
3
  import { type Nullable } from "@onerjs/core/types.js";
4
4
  import { Animation } from "@onerjs/core/Animations/animation.js";
5
+ import { type AnimationGroup } from "@onerjs/core/Animations/animationGroup.js";
5
6
  import { type Scene } from "@onerjs/core/scene.js";
6
7
  import { type BufferManager } from "./bufferManager.js";
7
8
  /**
@@ -82,6 +83,8 @@ export declare class _GLTFAnimation {
82
83
  * @param bufferViews
83
84
  * @param accessors
84
85
  * @param animationSampleRate
86
+ * @param useRightHanded
87
+ * @param shouldExportAnimation
85
88
  */
86
89
  static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: Map<Node, number>, nodes: INode[], bufferManager: BufferManager, bufferViews: IBufferView[], accessors: IAccessor[], animationSampleRate: number, useRightHanded: boolean, shouldExportAnimation?: (animation: Animation) => boolean): void;
87
90
  /**
@@ -96,6 +99,8 @@ export declare class _GLTFAnimation {
96
99
  * @param bufferViews
97
100
  * @param accessors
98
101
  * @param animationSampleRate
102
+ * @param useRightHanded
103
+ * @param shouldExportAnimation
99
104
  */
100
105
  static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: Map<Node, number>, nodes: INode[], bufferManager: BufferManager, bufferViews: IBufferView[], accessors: IAccessor[], animationSampleRate: number, useRightHanded: boolean, shouldExportAnimation?: (animation: Animation) => boolean): void;
101
106
  /**
@@ -109,8 +114,11 @@ export declare class _GLTFAnimation {
109
114
  * @param bufferViews
110
115
  * @param accessors
111
116
  * @param animationSampleRate
117
+ * @param leftHandedNodes nodes that require right-handed conversion
118
+ * @param shouldExportAnimation optional animation filter
119
+ * @param animationGroupMap final glTF animation index for each exported Babylon animation group
112
120
  */
113
- static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: Map<Node, number>, bufferManager: BufferManager, bufferViews: IBufferView[], accessors: IAccessor[], animationSampleRate: number, leftHandedNodes: Set<Node>, shouldExportAnimation?: (animation: Animation) => boolean, _convertToRightHanded?: boolean): void;
121
+ static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: Map<Node, number>, bufferManager: BufferManager, bufferViews: IBufferView[], accessors: IAccessor[], animationSampleRate: number, leftHandedNodes: Set<Node>, shouldExportAnimation?: (animation: Animation) => boolean, animationGroupMap?: Map<AnimationGroup, number>, _convertToRightHanded?: boolean): void;
114
122
  private static _AddAnimation;
115
123
  /**
116
124
  * Create a baked animation
@@ -136,6 +136,8 @@ export class _GLTFAnimation {
136
136
  * @param bufferViews
137
137
  * @param accessors
138
138
  * @param animationSampleRate
139
+ * @param useRightHanded
140
+ * @param shouldExportAnimation
139
141
  */
140
142
  static _CreateNodeAnimationFromNodeAnimations(babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, nodes, bufferManager, bufferViews, accessors, animationSampleRate, useRightHanded, shouldExportAnimation) {
141
143
  let glTFAnimation;
@@ -173,6 +175,8 @@ export class _GLTFAnimation {
173
175
  * @param bufferViews
174
176
  * @param accessors
175
177
  * @param animationSampleRate
178
+ * @param useRightHanded
179
+ * @param shouldExportAnimation
176
180
  */
177
181
  static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, nodes, bufferManager, bufferViews, accessors, animationSampleRate, useRightHanded, shouldExportAnimation) {
178
182
  let glTFAnimation;
@@ -228,8 +232,11 @@ export class _GLTFAnimation {
228
232
  * @param bufferViews
229
233
  * @param accessors
230
234
  * @param animationSampleRate
235
+ * @param leftHandedNodes nodes that require right-handed conversion
236
+ * @param shouldExportAnimation optional animation filter
237
+ * @param animationGroupMap final glTF animation index for each exported Babylon animation group
231
238
  */
232
- static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene, glTFAnimations, nodeMap, bufferManager, bufferViews, accessors, animationSampleRate, leftHandedNodes, shouldExportAnimation, _convertToRightHanded = true) {
239
+ static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene, glTFAnimations, nodeMap, bufferManager, bufferViews, accessors, animationSampleRate, leftHandedNodes, shouldExportAnimation, animationGroupMap, _convertToRightHanded = true) {
233
240
  let glTFAnimation;
234
241
  if (babylonScene.animationGroups) {
235
242
  const animationGroups = babylonScene.animationGroups;
@@ -340,6 +347,7 @@ export class _GLTFAnimation {
340
347
  }
341
348
  });
342
349
  if (glTFAnimation.channels.length && glTFAnimation.samplers.length) {
350
+ animationGroupMap?.set(animationGroup, glTFAnimations.length);
343
351
  glTFAnimations.push(glTFAnimation);
344
352
  }
345
353
  }