@babylonjs/serializers 6.6.1 → 6.8.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.
@@ -46,9 +46,9 @@ export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDispo
46
46
  * @param babylonNode BabylonJS node
47
47
  * @returns nullable INode promise
48
48
  */
49
- postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
49
+ postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap: {
50
50
  [key: number]: number;
51
- }, binaryWriter?: _BinaryWriter): Promise<Nullable<INode>>;
51
+ }, binaryWriter: _BinaryWriter): Promise<Nullable<INode>>;
52
52
  /**
53
53
  * Define this method to modify the default behavior when exporting a material
54
54
  * @param material glTF material
@@ -1 +1 @@
1
- {"version":3,"file":"glTFExporterExtension.js","sourceRoot":"","sources":["../../../../../lts/serializers/generated/glTF/2.0/glTFExporterExtension.ts"],"names":[],"mappings":"AAaA,gBAAgB;AAChB,wEAAwE;AACxE,MAAM,CAAC,IAAI,0BAA0B,GAAG,CAAC,CAAC,CAAC,uCAAuC","sourcesContent":["import type { ImageMimeType, IMeshPrimitive, INode, IMaterial, ITextureInfo } from \"babylonjs-gltf2interface\";\r\nimport type { Node } from \"core/node\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport type { SubMesh } from \"core/Meshes/subMesh\";\r\nimport type { IDisposable } from \"core/scene\";\r\n\r\nimport type { _BinaryWriter } from \"./glTFExporter\";\r\nimport type { IGLTFExporterExtension } from \"../glTFFileExporter\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\n\r\n/** @internal */\r\n// eslint-disable-next-line no-var, @typescript-eslint/naming-convention\r\nexport var __IGLTFExporterExtensionV2 = 0; // I am here to allow dts to be created\r\n\r\n/**\r\n * Interface for a glTF exporter extension\r\n * @internal\r\n */\r\nexport interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {\r\n /**\r\n * Define this method to modify the default behavior before exporting a texture\r\n * @param context The context when loading the asset\r\n * @param babylonTexture The Babylon.js texture\r\n * @param mimeType The mime-type of the generated image\r\n * @returns A promise that resolves with the exported texture\r\n */\r\n preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<Texture>>;\r\n\r\n /**\r\n * Define this method to get notified when a texture info is created\r\n * @param context The context when loading the asset\r\n * @param textureInfo The glTF texture info\r\n * @param babylonTexture The Babylon.js texture\r\n */\r\n postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;\r\n\r\n /**\r\n * Define this method to modify the default behavior when exporting texture info\r\n * @param context The context when loading the asset\r\n * @param meshPrimitive glTF mesh primitive\r\n * @param babylonSubMesh Babylon submesh\r\n * @param binaryWriter glTF serializer binary writer instance\r\n * @returns nullable IMeshPrimitive promise\r\n */\r\n postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;\r\n\r\n /**\r\n * Define this method to modify the default behavior when exporting a node\r\n * @param context The context when exporting the node\r\n * @param node glTF node\r\n * @param babylonNode BabylonJS node\r\n * @returns nullable INode promise\r\n */\r\n postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: { [key: number]: number }, binaryWriter?: _BinaryWriter): Promise<Nullable<INode>>;\r\n\r\n /**\r\n * Define this method to modify the default behavior when exporting a material\r\n * @param material glTF material\r\n * @param babylonMaterial BabylonJS material\r\n * @returns nullable IMaterial promise\r\n */\r\n postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;\r\n\r\n /**\r\n * Define this method to return additional textures to export from a material\r\n * @param material glTF material\r\n * @param babylonMaterial BabylonJS material\r\n * @returns List of textures\r\n */\r\n postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];\r\n\r\n /** Gets a boolean indicating that this extension was used */\r\n wasUsed: boolean;\r\n\r\n /** Gets a boolean indicating that this extension is required for the file to work */\r\n required: boolean;\r\n\r\n /**\r\n * Called after the exporter state changes to EXPORTING\r\n */\r\n onExporting?(): void;\r\n}\r\n"]}
1
+ {"version":3,"file":"glTFExporterExtension.js","sourceRoot":"","sources":["../../../../../lts/serializers/generated/glTF/2.0/glTFExporterExtension.ts"],"names":[],"mappings":"AAaA,gBAAgB;AAChB,wEAAwE;AACxE,MAAM,CAAC,IAAI,0BAA0B,GAAG,CAAC,CAAC,CAAC,uCAAuC","sourcesContent":["import type { ImageMimeType, IMeshPrimitive, INode, IMaterial, ITextureInfo } from \"babylonjs-gltf2interface\";\r\nimport type { Node } from \"core/node\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport type { SubMesh } from \"core/Meshes/subMesh\";\r\nimport type { IDisposable } from \"core/scene\";\r\n\r\nimport type { _BinaryWriter } from \"./glTFExporter\";\r\nimport type { IGLTFExporterExtension } from \"../glTFFileExporter\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\n\r\n/** @internal */\r\n// eslint-disable-next-line no-var, @typescript-eslint/naming-convention\r\nexport var __IGLTFExporterExtensionV2 = 0; // I am here to allow dts to be created\r\n\r\n/**\r\n * Interface for a glTF exporter extension\r\n * @internal\r\n */\r\nexport interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {\r\n /**\r\n * Define this method to modify the default behavior before exporting a texture\r\n * @param context The context when loading the asset\r\n * @param babylonTexture The Babylon.js texture\r\n * @param mimeType The mime-type of the generated image\r\n * @returns A promise that resolves with the exported texture\r\n */\r\n preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<Texture>>;\r\n\r\n /**\r\n * Define this method to get notified when a texture info is created\r\n * @param context The context when loading the asset\r\n * @param textureInfo The glTF texture info\r\n * @param babylonTexture The Babylon.js texture\r\n */\r\n postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;\r\n\r\n /**\r\n * Define this method to modify the default behavior when exporting texture info\r\n * @param context The context when loading the asset\r\n * @param meshPrimitive glTF mesh primitive\r\n * @param babylonSubMesh Babylon submesh\r\n * @param binaryWriter glTF serializer binary writer instance\r\n * @returns nullable IMeshPrimitive promise\r\n */\r\n postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;\r\n\r\n /**\r\n * Define this method to modify the default behavior when exporting a node\r\n * @param context The context when exporting the node\r\n * @param node glTF node\r\n * @param babylonNode BabylonJS node\r\n * @returns nullable INode promise\r\n */\r\n postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap: { [key: number]: number }, binaryWriter: _BinaryWriter): Promise<Nullable<INode>>;\r\n\r\n /**\r\n * Define this method to modify the default behavior when exporting a material\r\n * @param material glTF material\r\n * @param babylonMaterial BabylonJS material\r\n * @returns nullable IMaterial promise\r\n */\r\n postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;\r\n\r\n /**\r\n * Define this method to return additional textures to export from a material\r\n * @param material glTF material\r\n * @param babylonMaterial BabylonJS material\r\n * @returns List of textures\r\n */\r\n postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];\r\n\r\n /** Gets a boolean indicating that this extension was used */\r\n wasUsed: boolean;\r\n\r\n /** Gets a boolean indicating that this extension is required for the file to work */\r\n required: boolean;\r\n\r\n /**\r\n * Called after the exporter state changes to EXPORTING\r\n */\r\n onExporting?(): void;\r\n}\r\n"]}
@@ -25,19 +25,24 @@ export interface IExportOptions {
25
25
  */
26
26
  metadataSelector?(metadata: any): any;
27
27
  /**
28
- * The sample rate to bake animation curves
28
+ * The sample rate to bake animation curves. Defaults to 1 / 60.
29
29
  */
30
30
  animationSampleRate?: number;
31
31
  /**
32
- * Begin serialization without waiting for the scene to be ready
32
+ * Begin serialization without waiting for the scene to be ready. Defaults to false.
33
33
  */
34
34
  exportWithoutWaitingForScene?: boolean;
35
35
  /**
36
- * Indicates if unused vertex uv attributes should be included in export
36
+ * Indicates if unused vertex uv attributes should be included in export. Defaults to false.
37
37
  */
38
38
  exportUnusedUVs?: boolean;
39
39
  /**
40
- * Indicates if coordinate system swapping root nodes should be included in export
40
+ * Remove no-op root nodes when possible. Defaults to true.
41
+ */
42
+ removeNoopRootNodes?: boolean;
43
+ /**
44
+ * Indicates if coordinate system swapping root nodes should be included in export. Defaults to false.
45
+ * @deprecated Please use removeNoopRootNodes instead
41
46
  */
42
47
  includeCoordinateSystemConversionNodes?: boolean;
43
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"glTFSerializer.js","sourceRoot":"","sources":["../../../../../lts/serializers/generated/glTF/2.0/glTFSerializer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAgD3C;;GAEG;AACH,MAAM,OAAO,WAAW;IACpB;;;;;;;OAOG;IACI,MAAM,CAAC,SAAS,CAAC,KAAY,EAAE,UAAkB,EAAE,OAAwB;QAC9E,OAAO,KAAK,CAAC,cAAc,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YACpC,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YACvD,MAAM,aAAa,GAAG,IAAI,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YACpD,OAAO,aAAa,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,MAAM,CAAC,eAAe,CAAC,KAAY,EAAE,OAAwB;QACjE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YAC/B,IAAI,OAAO,IAAI,OAAO,CAAC,4BAA4B,EAAE;gBACjD,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;aAC5B;iBAAM;gBACH,OAAO,KAAK,CAAC,cAAc,EAAE,CAAC;aACjC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,MAAM,CAAC,gBAAgB,CAAC,KAAY,EAAE,QAAkB,EAAE,OAAwB;QACtF,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YAC/B,IAAI,OAAO,IAAI,OAAO,CAAC,4BAA4B,EAAE;gBACjD,OAAO,QAAQ,CAAC;aACnB;iBAAM;gBACH,OAAO,QAAQ,CAAC;aACnB;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,QAAQ,CAAC,KAAY,EAAE,UAAkB,EAAE,OAAwB;QAC7E,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;YAClD,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YACvD,MAAM,aAAa,GAAG,IAAI,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YACpD,OAAO,aAAa,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACjE,OAAO,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC3D,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,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 { _Exporter } 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\r\n */\r\n animationSampleRate?: number;\r\n\r\n /**\r\n * Begin serialization without waiting for the scene to be ready\r\n */\r\n exportWithoutWaitingForScene?: boolean;\r\n\r\n /**\r\n * Indicates if unused vertex uv attributes should be included in export\r\n */\r\n exportUnusedUVs?: boolean;\r\n\r\n /**\r\n * Indicates if coordinate system swapping root nodes should be included in export\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 geometry of the scene to .gltf file format asynchronously\r\n * @param scene Babylon scene with scene hierarchy information\r\n * @param filePrefix File prefix to use when generating the glTF file\r\n * @param options Exporter options\r\n * @returns Returns an object with a .gltf file and associates texture names\r\n * as keys and their data and paths as values\r\n */\r\n public static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData> {\r\n return scene.whenReadyAsync().then(() => {\r\n const glTFPrefix = filePrefix.replace(/\\.[^/.]+$/, \"\");\r\n const gltfGenerator = new _Exporter(scene, options);\r\n return gltfGenerator._generateGLTFAsync(glTFPrefix);\r\n });\r\n }\r\n\r\n private static _PreExportAsync(scene: Scene, options?: IExportOptions): Promise<void> {\r\n return Promise.resolve().then(() => {\r\n if (options && options.exportWithoutWaitingForScene) {\r\n return Promise.resolve();\r\n } else {\r\n return scene.whenReadyAsync();\r\n }\r\n });\r\n }\r\n\r\n private static _PostExportAsync(scene: Scene, glTFData: GLTFData, options?: IExportOptions): Promise<GLTFData> {\r\n return Promise.resolve().then(() => {\r\n if (options && options.exportWithoutWaitingForScene) {\r\n return glTFData;\r\n } else {\r\n return glTFData;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Exports the geometry of the scene to .glb file format asychronously\r\n * @param scene Babylon scene with scene hierarchy information\r\n * @param filePrefix File prefix to use when generating glb file\r\n * @param options Exporter options\r\n * @returns Returns an object with a .glb filename as key and data as value\r\n */\r\n public static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData> {\r\n return this._PreExportAsync(scene, options).then(() => {\r\n const glTFPrefix = filePrefix.replace(/\\.[^/.]+$/, \"\");\r\n const gltfGenerator = new _Exporter(scene, options);\r\n return gltfGenerator._generateGLBAsync(glTFPrefix).then((glTFData) => {\r\n return this._PostExportAsync(scene, glTFData, options);\r\n });\r\n });\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"glTFSerializer.js","sourceRoot":"","sources":["../../../../../lts/serializers/generated/glTF/2.0/glTFSerializer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAsD3C;;GAEG;AACH,MAAM,OAAO,WAAW;IACpB;;;;;;;OAOG;IACI,MAAM,CAAC,SAAS,CAAC,KAAY,EAAE,UAAkB,EAAE,OAAwB;QAC9E,OAAO,KAAK,CAAC,cAAc,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YACpC,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YACvD,MAAM,aAAa,GAAG,IAAI,SAAS,CAAC,KAAK,EAAE,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CAAC,CAAC,CAAC;IACP,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 { _Exporter } 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 geometry of the scene to .gltf file format asynchronously\r\n * @param scene Babylon scene with scene hierarchy information\r\n * @param filePrefix File prefix to use when generating the glTF file\r\n * @param options Exporter options\r\n * @returns Returns an object with a .gltf file and associates texture names\r\n * as keys and their data and paths as values\r\n */\r\n public static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData> {\r\n return scene.whenReadyAsync().then(() => {\r\n const glTFPrefix = filePrefix.replace(/\\.[^/.]+$/, \"\");\r\n const gltfGenerator = new _Exporter(scene, options);\r\n return gltfGenerator._generateGLTFAsync(glTFPrefix);\r\n });\r\n }\r\n\r\n private static _PreExportAsync(scene: Scene, options?: IExportOptions): Promise<void> {\r\n return Promise.resolve().then(() => {\r\n if (options && options.exportWithoutWaitingForScene) {\r\n return Promise.resolve();\r\n } else {\r\n return scene.whenReadyAsync();\r\n }\r\n });\r\n }\r\n\r\n private static _PostExportAsync(scene: Scene, glTFData: GLTFData, options?: IExportOptions): Promise<GLTFData> {\r\n return Promise.resolve().then(() => {\r\n if (options && options.exportWithoutWaitingForScene) {\r\n return glTFData;\r\n } else {\r\n return glTFData;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Exports the geometry of the scene to .glb file format asychronously\r\n * @param scene Babylon scene with scene hierarchy information\r\n * @param filePrefix File prefix to use when generating glb file\r\n * @param options Exporter options\r\n * @returns Returns an object with a .glb filename as key and data as value\r\n */\r\n public static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData> {\r\n return this._PreExportAsync(scene, options).then(() => {\r\n const glTFPrefix = filePrefix.replace(/\\.[^/.]+$/, \"\");\r\n const gltfGenerator = new _Exporter(scene, options);\r\n return gltfGenerator._generateGLBAsync(glTFPrefix).then((glTFData) => {\r\n return this._PostExportAsync(scene, glTFData, options);\r\n });\r\n });\r\n }\r\n}\r\n"]}
@@ -1,8 +1,7 @@
1
1
  import type { IBufferView, AccessorComponentType, IAccessor } from "babylonjs-gltf2interface";
2
2
  import { AccessorType } from "babylonjs-gltf2interface";
3
3
  import type { FloatArray, Nullable } from "@babylonjs/core/types.js";
4
- import type { Vector4, Quaternion } from "@babylonjs/core/Maths/math.vector.js";
5
- import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
4
+ import type { Vector4 } from "@babylonjs/core/Maths/math.vector.js";
6
5
  /**
7
6
  * @internal
8
7
  */
@@ -35,65 +34,12 @@ export declare class _GLTFUtilities {
35
34
  * @param positions Positions array of a mesh
36
35
  * @param vertexStart Starting vertex offset to calculate min and max values
37
36
  * @param vertexCount Number of vertices to check for min and max values
38
- * @param convertToRightHandedSystem
39
37
  * @returns min number array and max number array
40
38
  */
41
- static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
39
+ static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number): {
42
40
  min: number[];
43
41
  max: number[];
44
42
  };
45
- /**
46
- * Converts a new right-handed Vector3
47
- * @param vector vector3 array
48
- * @returns right-handed Vector3
49
- */
50
- static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
51
- /**
52
- * Converts a Vector3 to right-handed
53
- * @param vector Vector3 to convert to right-handed
54
- */
55
- static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
56
- /**
57
- * Converts a three element number array to right-handed
58
- * @param vector number array to convert to right-handed
59
- */
60
- static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
61
- /**
62
- * Converts a new right-handed Vector3
63
- * @param vector vector3 array
64
- * @returns right-handed Vector3
65
- */
66
- static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
67
- /**
68
- * Converts a Vector3 to right-handed
69
- * @param vector Vector3 to convert to right-handed
70
- */
71
- static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
72
- /**
73
- * Converts a three element number array to right-handed
74
- * @param vector number array to convert to right-handed
75
- */
76
- static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
77
- /**
78
- * Converts a Vector4 to right-handed
79
- * @param vector Vector4 to convert to right-handed
80
- */
81
- static _GetRightHandedVector4FromRef(vector: Vector4): void;
82
- /**
83
- * Converts a Vector4 to right-handed
84
- * @param vector Vector4 to convert to right-handed
85
- */
86
- static _GetRightHandedArray4FromRef(vector: number[]): void;
87
- /**
88
- * Converts a Quaternion to right-handed
89
- * @param quaternion Source quaternion to convert to right-handed
90
- */
91
- static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
92
- /**
93
- * Converts a Quaternion to right-handed
94
- * @param quaternion Source quaternion to convert to right-handed
95
- */
96
- static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
97
43
  static _NormalizeTangentFromRef(tangent: Vector4): void;
98
44
  static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
99
45
  }
@@ -55,10 +55,9 @@ export class _GLTFUtilities {
55
55
  * @param positions Positions array of a mesh
56
56
  * @param vertexStart Starting vertex offset to calculate min and max values
57
57
  * @param vertexCount Number of vertices to check for min and max values
58
- * @param convertToRightHandedSystem
59
58
  * @returns min number array and max number array
60
59
  */
61
- static _CalculateMinMaxPositions(positions, vertexStart, vertexCount, convertToRightHandedSystem) {
60
+ static _CalculateMinMaxPositions(positions, vertexStart, vertexCount) {
62
61
  const min = [Infinity, Infinity, Infinity];
63
62
  const max = [-Infinity, -Infinity, -Infinity];
64
63
  const positionStrideSize = 3;
@@ -69,9 +68,6 @@ export class _GLTFUtilities {
69
68
  for (let i = vertexStart, length = vertexStart + vertexCount; i < length; ++i) {
70
69
  indexOffset = positionStrideSize * i;
71
70
  position = Vector3.FromArray(positions, indexOffset);
72
- if (convertToRightHandedSystem) {
73
- _GLTFUtilities._GetRightHandedPositionVector3FromRef(position);
74
- }
75
71
  vector = position.asArray();
76
72
  for (let j = 0; j < positionStrideSize; ++j) {
77
73
  const num = vector[j];
@@ -87,82 +83,6 @@ export class _GLTFUtilities {
87
83
  }
88
84
  return { min, max };
89
85
  }
90
- /**
91
- * Converts a new right-handed Vector3
92
- * @param vector vector3 array
93
- * @returns right-handed Vector3
94
- */
95
- static _GetRightHandedPositionVector3(vector) {
96
- return new Vector3(vector.x, vector.y, -vector.z);
97
- }
98
- /**
99
- * Converts a Vector3 to right-handed
100
- * @param vector Vector3 to convert to right-handed
101
- */
102
- static _GetRightHandedPositionVector3FromRef(vector) {
103
- vector.z *= -1;
104
- }
105
- /**
106
- * Converts a three element number array to right-handed
107
- * @param vector number array to convert to right-handed
108
- */
109
- static _GetRightHandedPositionArray3FromRef(vector) {
110
- vector[2] *= -1;
111
- }
112
- /**
113
- * Converts a new right-handed Vector3
114
- * @param vector vector3 array
115
- * @returns right-handed Vector3
116
- */
117
- static _GetRightHandedNormalVector3(vector) {
118
- return new Vector3(vector.x, vector.y, -vector.z);
119
- }
120
- /**
121
- * Converts a Vector3 to right-handed
122
- * @param vector Vector3 to convert to right-handed
123
- */
124
- static _GetRightHandedNormalVector3FromRef(vector) {
125
- vector.z *= -1;
126
- }
127
- /**
128
- * Converts a three element number array to right-handed
129
- * @param vector number array to convert to right-handed
130
- */
131
- static _GetRightHandedNormalArray3FromRef(vector) {
132
- vector[2] *= -1;
133
- }
134
- /**
135
- * Converts a Vector4 to right-handed
136
- * @param vector Vector4 to convert to right-handed
137
- */
138
- static _GetRightHandedVector4FromRef(vector) {
139
- vector.z *= -1;
140
- vector.w *= -1;
141
- }
142
- /**
143
- * Converts a Vector4 to right-handed
144
- * @param vector Vector4 to convert to right-handed
145
- */
146
- static _GetRightHandedArray4FromRef(vector) {
147
- vector[2] *= -1;
148
- vector[3] *= -1;
149
- }
150
- /**
151
- * Converts a Quaternion to right-handed
152
- * @param quaternion Source quaternion to convert to right-handed
153
- */
154
- static _GetRightHandedQuaternionFromRef(quaternion) {
155
- quaternion.x *= -1;
156
- quaternion.y *= -1;
157
- }
158
- /**
159
- * Converts a Quaternion to right-handed
160
- * @param quaternion Source quaternion to convert to right-handed
161
- */
162
- static _GetRightHandedQuaternionArrayFromRef(quaternion) {
163
- quaternion[0] *= -1;
164
- quaternion[1] *= -1;
165
- }
166
86
  static _NormalizeTangentFromRef(tangent) {
167
87
  const length = Math.sqrt(tangent.x * tangent.x + tangent.y * tangent.y + tangent.z * tangent.z);
168
88
  if (length > 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"glTFUtilities.js","sourceRoot":"","sources":["../../../../../lts/serializers/generated/glTF/2.0/glTFUtilities.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,6CAA+B;AAEjD;;GAEG;AACH,MAAM,OAAO,cAAc;IACvB;;;;;;;;OAQG;IACI,MAAM,CAAC,iBAAiB,CAAC,WAAmB,EAAE,UAAkB,EAAE,UAAkB,EAAE,UAAmB,EAAE,IAAa;QAC3H,MAAM,UAAU,GAAgB,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;QAChF,IAAI,UAAU,EAAE;YACZ,UAAU,CAAC,UAAU,GAAG,UAAU,CAAC;SACtC;QACD,IAAI,IAAI,EAAE;YACN,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC;SAC1B;QACD,IAAI,UAAU,EAAE;YACZ,UAAU,CAAC,UAAU,GAAG,UAAU,CAAC;SACtC;QAED,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;;;;;;;;;;OAWG;IACI,MAAM,CAAC,eAAe,CACzB,eAAuB,EACvB,IAAY,EACZ,IAAkB,EAClB,aAAoC,EACpC,KAAa,EACb,UAA4B,EAC5B,GAAuB,EACvB,GAAuB;QAEvB,MAAM,QAAQ,GAAc,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QAEhI,IAAI,GAAG,IAAI,IAAI,EAAE;YACb,QAAQ,CAAC,GAAG,GAAG,GAAG,CAAC;SACtB;QACD,IAAI,GAAG,IAAI,IAAI,EAAE;YACb,QAAQ,CAAC,GAAG,GAAG,GAAG,CAAC;SACtB;QACD,IAAI,UAAU,IAAI,IAAI,EAAE;YACpB,QAAQ,CAAC,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CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,gCAAgC,CAAC,UAAsB;QACjE,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACnB,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACvB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,qCAAqC,CAAC,UAAoB;QACpE,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACpB,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACxB,CAAC;IAEM,MAAM,CAAC,wBAAwB,CAAC,OAAgB;QACnD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAChG,IAAI,MAAM,GAAG,CAAC,EAAE;YACZ,OAAO,CAAC,CAAC,IAAI,MAAM,CAAC;YACpB,OAAO,CAAC,CAAC,IAAI,MAAM,CAAC;YACpB,OAAO,CAAC,CAAC,IAAI,MAAM,CAAC;SACvB;IACL,CAAC;IAEM,MAAM,CAAC,4BAA4B,CAAC,YAA0B;QACjE,QAAQ,YAAY,EAAE;YAClB;gBACI,OAAO,CAAC,CAAC;YACb;gBACI,OAAO,CAAC,CAAC;YACb;gBACI,OAAO,EAAE,CAAC;YACd;gBACI,OAAO,CAAC,CAAC;YACb;gBACI,OAAO,CAAC,CAAC;YACb;gBACI,OAAO,CAAC,CAAC;YACb;gBACI,OAAO,CAAC,CAAC;SAChB;IACL,CAAC;CACJ","sourcesContent":["import type { IBufferView, AccessorComponentType, IAccessor } from \"babylonjs-gltf2interface\";\r\nimport { AccessorType } from \"babylonjs-gltf2interface\";\r\n\r\nimport type { FloatArray, Nullable } from \"core/types\";\r\nimport type { Vector4, Quaternion } from \"core/Maths/math.vector\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class _GLTFUtilities {\r\n /**\r\n * Creates a buffer view based on the supplied arguments\r\n * @param bufferIndex index value of the specified buffer\r\n * @param byteOffset byte offset value\r\n * @param byteLength byte length of the bufferView\r\n * @param byteStride byte distance between conequential elements\r\n * @param name name of the buffer view\r\n * @returns bufferView for glTF\r\n */\r\n public static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView {\r\n const bufferview: IBufferView = { buffer: bufferIndex, byteLength: byteLength };\r\n if (byteOffset) {\r\n bufferview.byteOffset = byteOffset;\r\n }\r\n if (name) {\r\n bufferview.name = name;\r\n }\r\n if (byteStride) {\r\n bufferview.byteStride = byteStride;\r\n }\r\n\r\n return bufferview;\r\n }\r\n\r\n /**\r\n * Creates an accessor based on the supplied arguments\r\n * @param bufferviewIndex The index of the bufferview referenced by this accessor\r\n * @param name The name of the accessor\r\n * @param type The type of the accessor\r\n * @param componentType The datatype of components in the attribute\r\n * @param count The number of attributes referenced by this accessor\r\n * @param byteOffset The offset relative to the start of the bufferView in bytes\r\n * @param min Minimum value of each component in this attribute\r\n * @param max Maximum value of each component in this attribute\r\n * @returns accessor for glTF\r\n */\r\n public static _CreateAccessor(\r\n bufferviewIndex: number,\r\n name: string,\r\n type: AccessorType,\r\n componentType: AccessorComponentType,\r\n count: number,\r\n byteOffset: Nullable<number>,\r\n min: Nullable<number[]>,\r\n max: Nullable<number[]>\r\n ): IAccessor {\r\n const accessor: IAccessor = { name: name, bufferView: bufferviewIndex, componentType: componentType, count: count, type: type };\r\n\r\n if (min != null) {\r\n accessor.min = min;\r\n }\r\n if (max != null) {\r\n accessor.max = max;\r\n }\r\n if (byteOffset != null) {\r\n accessor.byteOffset = byteOffset;\r\n }\r\n\r\n return accessor;\r\n }\r\n\r\n /**\r\n * Calculates the minimum and maximum values of an array of position floats\r\n * @param positions Positions array of a mesh\r\n * @param vertexStart Starting vertex offset to calculate min and max values\r\n * @param vertexCount Number of vertices to check for min and max values\r\n * @param convertToRightHandedSystem\r\n * @returns min number array and max number array\r\n */\r\n public static _CalculateMinMaxPositions(\r\n positions: FloatArray,\r\n vertexStart: number,\r\n vertexCount: number,\r\n convertToRightHandedSystem: boolean\r\n ): { min: number[]; max: number[] } {\r\n const min = [Infinity, Infinity, Infinity];\r\n const max = [-Infinity, -Infinity, -Infinity];\r\n const positionStrideSize = 3;\r\n let indexOffset: number;\r\n let position: Vector3;\r\n let vector: number[];\r\n\r\n if (vertexCount) {\r\n for (let i = vertexStart, length = vertexStart + vertexCount; i < length; ++i) {\r\n indexOffset = positionStrideSize * i;\r\n\r\n position = Vector3.FromArray(positions, indexOffset);\r\n if (convertToRightHandedSystem) {\r\n _GLTFUtilities._GetRightHandedPositionVector3FromRef(position);\r\n }\r\n vector = position.asArray();\r\n\r\n for (let j = 0; j < positionStrideSize; ++j) {\r\n const num = vector[j];\r\n if (num < min[j]) {\r\n min[j] = num;\r\n }\r\n if (num > max[j]) {\r\n max[j] = num;\r\n }\r\n ++indexOffset;\r\n }\r\n }\r\n }\r\n return { min, max };\r\n }\r\n\r\n /**\r\n * Converts a new right-handed Vector3\r\n * @param vector vector3 array\r\n * @returns right-handed Vector3\r\n */\r\n public static _GetRightHandedPositionVector3(vector: Vector3): Vector3 {\r\n return new Vector3(vector.x, vector.y, -vector.z);\r\n }\r\n\r\n /**\r\n * Converts a Vector3 to right-handed\r\n * @param vector Vector3 to convert to right-handed\r\n */\r\n public static _GetRightHandedPositionVector3FromRef(vector: Vector3) {\r\n vector.z *= -1;\r\n }\r\n\r\n /**\r\n * Converts a three element number array to right-handed\r\n * @param vector number array to convert to right-handed\r\n */\r\n public static _GetRightHandedPositionArray3FromRef(vector: number[]) {\r\n vector[2] *= -1;\r\n }\r\n\r\n /**\r\n * Converts a new right-handed Vector3\r\n * @param vector vector3 array\r\n * @returns right-handed Vector3\r\n */\r\n public static _GetRightHandedNormalVector3(vector: Vector3): Vector3 {\r\n return new Vector3(vector.x, vector.y, -vector.z);\r\n }\r\n\r\n /**\r\n * Converts a Vector3 to right-handed\r\n * @param vector Vector3 to convert to right-handed\r\n */\r\n public static _GetRightHandedNormalVector3FromRef(vector: Vector3) {\r\n vector.z *= -1;\r\n }\r\n\r\n /**\r\n * Converts a three element number array to right-handed\r\n * @param vector number array to convert to right-handed\r\n */\r\n public static _GetRightHandedNormalArray3FromRef(vector: number[]) {\r\n vector[2] *= -1;\r\n }\r\n\r\n /**\r\n * Converts a Vector4 to right-handed\r\n * @param vector Vector4 to convert to right-handed\r\n */\r\n public static _GetRightHandedVector4FromRef(vector: Vector4) {\r\n vector.z *= -1;\r\n vector.w *= -1;\r\n }\r\n\r\n /**\r\n * Converts a Vector4 to right-handed\r\n * @param vector Vector4 to convert to right-handed\r\n */\r\n public static _GetRightHandedArray4FromRef(vector: number[]) {\r\n vector[2] *= -1;\r\n vector[3] *= -1;\r\n }\r\n\r\n /**\r\n * Converts a Quaternion to right-handed\r\n * @param quaternion Source quaternion to convert to right-handed\r\n */\r\n public static _GetRightHandedQuaternionFromRef(quaternion: Quaternion) {\r\n quaternion.x *= -1;\r\n quaternion.y *= -1;\r\n }\r\n\r\n /**\r\n * Converts a Quaternion to right-handed\r\n * @param quaternion Source quaternion to convert to right-handed\r\n */\r\n public static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]) {\r\n quaternion[0] *= -1;\r\n quaternion[1] *= -1;\r\n }\r\n\r\n public static _NormalizeTangentFromRef(tangent: Vector4) {\r\n const length = Math.sqrt(tangent.x * tangent.x + tangent.y * tangent.y + tangent.z * tangent.z);\r\n if (length > 0) {\r\n tangent.x /= length;\r\n tangent.y /= length;\r\n tangent.z /= length;\r\n }\r\n }\r\n\r\n public static _GetDataAccessorElementCount(accessorType: AccessorType) {\r\n switch (accessorType) {\r\n case AccessorType.MAT2:\r\n return 4;\r\n case AccessorType.MAT3:\r\n return 9;\r\n case AccessorType.MAT4:\r\n return 16;\r\n case AccessorType.SCALAR:\r\n return 1;\r\n case AccessorType.VEC2:\r\n return 2;\r\n case AccessorType.VEC3:\r\n return 3;\r\n case AccessorType.VEC4:\r\n return 4;\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"glTFUtilities.js","sourceRoot":"","sources":["../../../../../lts/serializers/generated/glTF/2.0/glTFUtilities.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,6CAA+B;AAEjD;;GAEG;AACH,MAAM,OAAO,cAAc;IACvB;;;;;;;;OAQG;IACI,MAAM,CAAC,iBAAiB,CAAC,WAAmB,EAAE,UAAkB,EAAE,UAAkB,EAAE,UAAmB,EAAE,IAAa;QAC3H,MAAM,UAAU,GAAgB,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;QAChF,IAAI,UAAU,EAAE;YACZ,UAAU,CAAC,UAAU,GAAG,UAAU,CAAC;SACtC;QACD,IAAI,IAAI,EAAE;YACN,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC;SAC1B;QACD,IAAI,UAAU,EAAE;YACZ,UAAU,CAAC,UAAU,GAAG,UAAU,CAAC;SACtC;QAED,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;;;;;;;;;;OAWG;IACI,MAAM,CAAC,eAAe,CACzB,eAAuB,EACvB,IAAY,EACZ,IAAkB,EAClB,aAAoC,EACpC,KAAa,EACb,UAA4B,EAC5B,GAAuB,EACvB,GAAuB;QAEvB,MAAM,QAAQ,GAAc,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QAEhI,IAAI,GAAG,IAAI,IAAI,EAAE;YACb,QAAQ,CAAC,GAAG,GAAG,GAAG,CAAC;SACtB;QACD,IAAI,GAAG,IAAI,IAAI,EAAE;YACb,QAAQ,CAAC,GAAG,GAAG,GAAG,CAAC;SACtB;Q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G,EAAE,GAAG,EAAE,CAAC;IACxB,CAAC;IAEM,MAAM,CAAC,wBAAwB,CAAC,OAAgB;QACnD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAChG,IAAI,MAAM,GAAG,CAAC,EAAE;YACZ,OAAO,CAAC,CAAC,IAAI,MAAM,CAAC;YACpB,OAAO,CAAC,CAAC,IAAI,MAAM,CAAC;YACpB,OAAO,CAAC,CAAC,IAAI,MAAM,CAAC;SACvB;IACL,CAAC;IAEM,MAAM,CAAC,4BAA4B,CAAC,YAA0B;QACjE,QAAQ,YAAY,EAAE;YAClB;gBACI,OAAO,CAAC,CAAC;YACb;gBACI,OAAO,CAAC,CAAC;YACb;gBACI,OAAO,EAAE,CAAC;YACd;gBACI,OAAO,CAAC,CAAC;YACb;gBACI,OAAO,CAAC,CAAC;YACb;gBACI,OAAO,CAAC,CAAC;YACb;gBACI,OAAO,CAAC,CAAC;SAChB;IACL,CAAC;CACJ","sourcesContent":["import type { IBufferView, AccessorComponentType, IAccessor } from \"babylonjs-gltf2interface\";\r\nimport { AccessorType } from \"babylonjs-gltf2interface\";\r\n\r\nimport type { FloatArray, Nullable } from \"core/types\";\r\nimport type { Vector4 } from \"core/Maths/math.vector\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class _GLTFUtilities {\r\n /**\r\n * Creates a buffer view based on the supplied arguments\r\n * @param bufferIndex index value of the specified buffer\r\n * @param byteOffset byte offset value\r\n * @param byteLength byte length of the bufferView\r\n * @param byteStride byte distance between conequential elements\r\n * @param name name of the buffer view\r\n * @returns bufferView for glTF\r\n */\r\n public static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView {\r\n const bufferview: IBufferView = { buffer: bufferIndex, byteLength: byteLength };\r\n if (byteOffset) {\r\n bufferview.byteOffset = byteOffset;\r\n }\r\n if (name) {\r\n bufferview.name = name;\r\n }\r\n if (byteStride) {\r\n bufferview.byteStride = byteStride;\r\n }\r\n\r\n return bufferview;\r\n }\r\n\r\n /**\r\n * Creates an accessor based on the supplied arguments\r\n * @param bufferviewIndex The index of the bufferview referenced by this accessor\r\n * @param name The name of the accessor\r\n * @param type The type of the accessor\r\n * @param componentType The datatype of components in the attribute\r\n * @param count The number of attributes referenced by this accessor\r\n * @param byteOffset The offset relative to the start of the bufferView in bytes\r\n * @param min Minimum value of each component in this attribute\r\n * @param max Maximum value of each component in this attribute\r\n * @returns accessor for glTF\r\n */\r\n public static _CreateAccessor(\r\n bufferviewIndex: number,\r\n name: string,\r\n type: AccessorType,\r\n componentType: AccessorComponentType,\r\n count: number,\r\n byteOffset: Nullable<number>,\r\n min: Nullable<number[]>,\r\n max: Nullable<number[]>\r\n ): IAccessor {\r\n const accessor: IAccessor = { name: name, bufferView: bufferviewIndex, componentType: componentType, count: count, type: type };\r\n\r\n if (min != null) {\r\n accessor.min = min;\r\n }\r\n if (max != null) {\r\n accessor.max = max;\r\n }\r\n if (byteOffset != null) {\r\n accessor.byteOffset = byteOffset;\r\n }\r\n\r\n return accessor;\r\n }\r\n\r\n /**\r\n * Calculates the minimum and maximum values of an array of position floats\r\n * @param positions Positions array of a mesh\r\n * @param vertexStart Starting vertex offset to calculate min and max values\r\n * @param vertexCount Number of vertices to check for min and max values\r\n * @returns min number array and max number array\r\n */\r\n public static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number): { min: number[]; max: number[] } {\r\n const min = [Infinity, Infinity, Infinity];\r\n const max = [-Infinity, -Infinity, -Infinity];\r\n const positionStrideSize = 3;\r\n let indexOffset: number;\r\n let position: Vector3;\r\n let vector: number[];\r\n\r\n if (vertexCount) {\r\n for (let i = vertexStart, length = vertexStart + vertexCount; i < length; ++i) {\r\n indexOffset = positionStrideSize * i;\r\n\r\n position = Vector3.FromArray(positions, indexOffset);\r\n vector = position.asArray();\r\n\r\n for (let j = 0; j < positionStrideSize; ++j) {\r\n const num = vector[j];\r\n if (num < min[j]) {\r\n min[j] = num;\r\n }\r\n if (num > max[j]) {\r\n max[j] = num;\r\n }\r\n ++indexOffset;\r\n }\r\n }\r\n }\r\n return { min, max };\r\n }\r\n\r\n public static _NormalizeTangentFromRef(tangent: Vector4) {\r\n const length = Math.sqrt(tangent.x * tangent.x + tangent.y * tangent.y + tangent.z * tangent.z);\r\n if (length > 0) {\r\n tangent.x /= length;\r\n tangent.y /= length;\r\n tangent.z /= length;\r\n }\r\n }\r\n\r\n public static _GetDataAccessorElementCount(accessorType: AccessorType) {\r\n switch (accessorType) {\r\n case AccessorType.MAT2:\r\n return 4;\r\n case AccessorType.MAT3:\r\n return 9;\r\n case AccessorType.MAT4:\r\n return 16;\r\n case AccessorType.SCALAR:\r\n return 1;\r\n case AccessorType.VEC2:\r\n return 2;\r\n case AccessorType.VEC3:\r\n return 3;\r\n case AccessorType.VEC4:\r\n return 4;\r\n }\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs/serializers",
3
- "version": "6.6.1",
3
+ "version": "6.8.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": "^6.6.1",
21
+ "@babylonjs/core": "^6.8.0",
22
22
  "@dev/build-tools": "^1.0.0",
23
23
  "@lts/serializers": "^1.0.0",
24
- "babylonjs-gltf2interface": "^6.6.1",
24
+ "babylonjs-gltf2interface": "^6.8.0",
25
25
  "rimraf": "^3.0.2",
26
26
  "typescript": "^4.4.4"
27
27
  },