@babylonjs/serializers 8.1.1 → 8.2.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/OBJ/index.d.ts +1 -1
- package/USDZ/index.d.ts +1 -1
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +3 -3
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.d.ts +3 -3
- package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +2 -2
- package/glTF/2.0/Extensions/KHR_materials_anisotropy.d.ts +2 -2
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +2 -2
- package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.d.ts +2 -2
- package/glTF/2.0/Extensions/KHR_materials_dispersion.d.ts +1 -1
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +1 -1
- package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +1 -1
- package/glTF/2.0/Extensions/KHR_materials_iridescence.d.ts +2 -2
- package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +2 -2
- package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +2 -2
- package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +2 -2
- package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +2 -2
- package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +1 -1
- package/glTF/2.0/Extensions/index.d.ts +16 -16
- package/glTF/2.0/glTFAnimation.d.ts +1 -1
- package/glTF/2.0/glTFData.js +1 -21
- package/glTF/2.0/glTFData.js.map +1 -1
- package/glTF/2.0/glTFExporter.d.ts +5 -5
- package/glTF/2.0/glTFExporter.js +39 -39
- package/glTF/2.0/glTFExporter.js.map +1 -1
- package/glTF/2.0/glTFExporterExtension.d.ts +2 -2
- package/glTF/2.0/glTFMaterialExporter.d.ts +2 -2
- package/glTF/2.0/glTFMorphTargetsUtilities.d.ts +3 -3
- package/glTF/2.0/glTFMorphTargetsUtilities.js +10 -5
- package/glTF/2.0/glTFMorphTargetsUtilities.js.map +1 -1
- package/glTF/2.0/glTFSerializer.d.ts +4 -3
- package/glTF/2.0/glTFSerializer.js.map +1 -1
- package/glTF/2.0/glTFUtilities.d.ts +17 -0
- package/glTF/2.0/glTFUtilities.js +18 -3
- package/glTF/2.0/glTFUtilities.js.map +1 -1
- package/glTF/2.0/index.d.ts +4 -4
- package/glTF/index.d.ts +2 -2
- package/index.d.ts +4 -4
- package/legacy/legacy.d.ts +4 -4
- package/package.json +3 -3
- package/stl/index.d.ts +1 -1
package/OBJ/index.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export * from "./objSerializer";
|
1
|
+
export * from "./objSerializer.js";
|
package/USDZ/index.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export * from "./usdzExporter";
|
1
|
+
export * from "./usdzExporter.js";
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { INode } from "babylonjs-gltf2interface";
|
2
|
-
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension";
|
3
|
-
import type { BufferManager } from "../bufferManager";
|
4
|
-
import { GLTFExporter } from "../glTFExporter";
|
2
|
+
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
|
3
|
+
import type { BufferManager } from "../bufferManager.js";
|
4
|
+
import { GLTFExporter } from "../glTFExporter.js";
|
5
5
|
import type { Nullable } from "@babylonjs/core/types.js";
|
6
6
|
import type { Node } from "@babylonjs/core/node.js";
|
7
7
|
import "@babylonjs/core/Meshes/thinInstanceMesh.js";
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension";
|
2
|
-
import { GLTFExporter } from "../glTFExporter";
|
1
|
+
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
|
2
|
+
import { GLTFExporter } from "../glTFExporter.js";
|
3
3
|
import type { IAccessor, IMeshPrimitive } from "babylonjs-gltf2interface";
|
4
|
-
import type { BufferManager } from "../bufferManager";
|
4
|
+
import type { BufferManager } from "../bufferManager.js";
|
5
5
|
/**
|
6
6
|
* [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_draco_mesh_compression/README.md)
|
7
7
|
*/
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import type { Nullable } from "@babylonjs/core/types.js";
|
2
2
|
import type { Node } from "@babylonjs/core/node.js";
|
3
3
|
import type { INode } from "babylonjs-gltf2interface";
|
4
|
-
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension";
|
5
|
-
import { GLTFExporter } from "../glTFExporter";
|
4
|
+
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
|
5
|
+
import { GLTFExporter } from "../glTFExporter.js";
|
6
6
|
/**
|
7
7
|
* [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
|
8
8
|
*/
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { IMaterial } from "babylonjs-gltf2interface";
|
2
|
-
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension";
|
3
|
-
import { GLTFExporter } from "../glTFExporter";
|
2
|
+
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
|
3
|
+
import { GLTFExporter } from "../glTFExporter.js";
|
4
4
|
import type { Material } from "@babylonjs/core/Materials/material.js";
|
5
5
|
import type { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
|
6
6
|
/**
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { IMaterial } from "babylonjs-gltf2interface";
|
2
|
-
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension";
|
3
|
-
import { GLTFExporter } from "../glTFExporter";
|
2
|
+
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
|
3
|
+
import { GLTFExporter } from "../glTFExporter.js";
|
4
4
|
import type { Material } from "@babylonjs/core/Materials/material.js";
|
5
5
|
import type { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
|
6
6
|
/**
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { IMaterial } from "babylonjs-gltf2interface";
|
2
|
-
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension";
|
3
|
-
import { GLTFExporter } from "../glTFExporter";
|
2
|
+
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
|
3
|
+
import { GLTFExporter } from "../glTFExporter.js";
|
4
4
|
import type { Material } from "@babylonjs/core/Materials/material.js";
|
5
5
|
import type { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
|
6
6
|
/**
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { IMaterial } from "babylonjs-gltf2interface";
|
2
|
-
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension";
|
2
|
+
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
|
3
3
|
import type { Material } from "@babylonjs/core/Materials/material.js";
|
4
4
|
/**
|
5
5
|
* [Specification](https://github.com/KhronosGroup/glTF/blob/87bd64a7f5e23c84b6aef2e6082069583ed0ddb4/extensions/2.0/Khronos/KHR_materials_dispersion/README.md)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension";
|
1
|
+
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
|
2
2
|
import type { Material } from "@babylonjs/core/Materials/material.js";
|
3
3
|
import type { IMaterial } from "babylonjs-gltf2interface";
|
4
4
|
/**
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { IMaterial } from "babylonjs-gltf2interface";
|
2
|
-
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension";
|
2
|
+
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
|
3
3
|
import type { Material } from "@babylonjs/core/Materials/material.js";
|
4
4
|
/**
|
5
5
|
* [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_ior/README.md)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { IMaterial } from "babylonjs-gltf2interface";
|
2
|
-
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension";
|
3
|
-
import { GLTFExporter } from "../glTFExporter";
|
2
|
+
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
|
3
|
+
import { GLTFExporter } from "../glTFExporter.js";
|
4
4
|
import type { Material } from "@babylonjs/core/Materials/material.js";
|
5
5
|
import type { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
|
6
6
|
/**
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { IMaterial } from "babylonjs-gltf2interface";
|
2
|
-
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension";
|
3
|
-
import { GLTFExporter } from "../glTFExporter";
|
2
|
+
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
|
3
|
+
import { GLTFExporter } from "../glTFExporter.js";
|
4
4
|
import type { Material } from "@babylonjs/core/Materials/material.js";
|
5
5
|
import type { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
|
6
6
|
/**
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { IMaterial } from "babylonjs-gltf2interface";
|
2
|
-
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension";
|
3
|
-
import { GLTFExporter } from "../glTFExporter";
|
2
|
+
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
|
3
|
+
import { GLTFExporter } from "../glTFExporter.js";
|
4
4
|
import type { Material } from "@babylonjs/core/Materials/material.js";
|
5
5
|
import type { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
|
6
6
|
/**
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { IMaterial } from "babylonjs-gltf2interface";
|
2
|
-
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension";
|
3
|
-
import { GLTFExporter } from "../glTFExporter";
|
2
|
+
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
|
3
|
+
import { GLTFExporter } from "../glTFExporter.js";
|
4
4
|
import type { Material } from "@babylonjs/core/Materials/material.js";
|
5
5
|
import type { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
|
6
6
|
/**
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { IMaterial } from "babylonjs-gltf2interface";
|
2
|
-
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension";
|
2
|
+
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
|
3
3
|
import type { Material } from "@babylonjs/core/Materials/material.js";
|
4
4
|
/**
|
5
5
|
* @internal
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { IMaterial } from "babylonjs-gltf2interface";
|
2
|
-
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension";
|
3
|
-
import { GLTFExporter } from "../glTFExporter";
|
2
|
+
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
|
3
|
+
import { GLTFExporter } from "../glTFExporter.js";
|
4
4
|
import type { Material } from "@babylonjs/core/Materials/material.js";
|
5
5
|
import type { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
|
6
6
|
/**
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { ITextureInfo } from "babylonjs-gltf2interface";
|
2
2
|
import type { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
|
3
|
-
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension";
|
3
|
+
import type { IGLTFExporterExtensionV2 } from "../glTFExporterExtension.js";
|
4
4
|
/**
|
5
5
|
* @internal
|
6
6
|
*/
|
@@ -1,16 +1,16 @@
|
|
1
|
-
export * from "./EXT_mesh_gpu_instancing";
|
2
|
-
export * from "./KHR_draco_mesh_compression";
|
3
|
-
export * from "./KHR_lights_punctual";
|
4
|
-
export * from "./KHR_materials_anisotropy";
|
5
|
-
export * from "./KHR_materials_clearcoat";
|
6
|
-
export * from "./KHR_materials_diffuse_transmission";
|
7
|
-
export * from "./KHR_materials_dispersion";
|
8
|
-
export * from "./KHR_materials_emissive_strength";
|
9
|
-
export * from "./KHR_materials_ior";
|
10
|
-
export * from "./KHR_materials_iridescence";
|
11
|
-
export * from "./KHR_materials_sheen";
|
12
|
-
export * from "./KHR_materials_specular";
|
13
|
-
export * from "./KHR_materials_transmission";
|
14
|
-
export * from "./KHR_materials_unlit";
|
15
|
-
export * from "./KHR_materials_volume";
|
16
|
-
export * from "./KHR_texture_transform";
|
1
|
+
export * from "./EXT_mesh_gpu_instancing.js";
|
2
|
+
export * from "./KHR_draco_mesh_compression.js";
|
3
|
+
export * from "./KHR_lights_punctual.js";
|
4
|
+
export * from "./KHR_materials_anisotropy.js";
|
5
|
+
export * from "./KHR_materials_clearcoat.js";
|
6
|
+
export * from "./KHR_materials_diffuse_transmission.js";
|
7
|
+
export * from "./KHR_materials_dispersion.js";
|
8
|
+
export * from "./KHR_materials_emissive_strength.js";
|
9
|
+
export * from "./KHR_materials_ior.js";
|
10
|
+
export * from "./KHR_materials_iridescence.js";
|
11
|
+
export * from "./KHR_materials_sheen.js";
|
12
|
+
export * from "./KHR_materials_specular.js";
|
13
|
+
export * from "./KHR_materials_transmission.js";
|
14
|
+
export * from "./KHR_materials_unlit.js";
|
15
|
+
export * from "./KHR_materials_volume.js";
|
16
|
+
export * from "./KHR_texture_transform.js";
|
@@ -4,7 +4,7 @@ import type { Node } from "@babylonjs/core/node.js";
|
|
4
4
|
import type { Nullable } from "@babylonjs/core/types.js";
|
5
5
|
import { Animation } from "@babylonjs/core/Animations/animation.js";
|
6
6
|
import type { Scene } from "@babylonjs/core/scene.js";
|
7
|
-
import type { BufferManager } from "./bufferManager";
|
7
|
+
import type { BufferManager } from "./bufferManager.js";
|
8
8
|
/**
|
9
9
|
* @internal
|
10
10
|
* Interface to store animation data.
|
package/glTF/2.0/glTFData.js
CHANGED
@@ -1,25 +1,5 @@
|
|
1
|
+
import { GetMimeType } from "@babylonjs/core/Misc/fileTools.js";
|
1
2
|
import { Tools } from "@babylonjs/core/Misc/tools.js";
|
2
|
-
function GetMimeType(fileName) {
|
3
|
-
if (fileName.endsWith(".glb")) {
|
4
|
-
return "model/gltf-binary";
|
5
|
-
}
|
6
|
-
else if (fileName.endsWith(".bin")) {
|
7
|
-
return "application/octet-stream";
|
8
|
-
}
|
9
|
-
else if (fileName.endsWith(".gltf")) {
|
10
|
-
return "model/gltf+json";
|
11
|
-
}
|
12
|
-
else if (fileName.endsWith(".jpeg") || fileName.endsWith(".jpg")) {
|
13
|
-
return "image/jpeg" /* ImageMimeType.JPEG */;
|
14
|
-
}
|
15
|
-
else if (fileName.endsWith(".png")) {
|
16
|
-
return "image/png" /* ImageMimeType.PNG */;
|
17
|
-
}
|
18
|
-
else if (fileName.endsWith(".webp")) {
|
19
|
-
return "image/webp" /* ImageMimeType.WEBP */;
|
20
|
-
}
|
21
|
-
return undefined;
|
22
|
-
}
|
23
3
|
/**
|
24
4
|
* Class for holding and downloading glTF file data
|
25
5
|
*/
|
package/glTF/2.0/glTFData.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"glTFData.js","sourceRoot":"","sources":["../../../../../dev/serializers/src/glTF/2.0/glTFData.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"glTFData.js","sourceRoot":"","sources":["../../../../../dev/serializers/src/glTF/2.0/glTFData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,0CAA4B;AAClD,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAExC;;GAEG;AACH,MAAM,OAAO,QAAQ;IAArB;QACI;;WAEG;QACa,UAAK,GAA0C,EAAE,CAAC;IAmBtE,CAAC;IAjBG;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED;;OAEG;IACI,aAAa;QAChB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC9B,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC3D,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC9B,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { GetMimeType } from \"core/Misc/fileTools\";\r\nimport { Tools } from \"core/Misc/tools\";\r\n\r\n/**\r\n * Class for holding and downloading glTF file data\r\n */\r\nexport class GLTFData {\r\n /**\r\n * Object which contains the file name as the key and its data as the value\r\n */\r\n public readonly files: { [fileName: string]: string | Blob } = {};\r\n\r\n /**\r\n * @deprecated Use files instead\r\n */\r\n public get glTFFiles() {\r\n return this.files;\r\n }\r\n\r\n /**\r\n * Downloads the glTF data as files based on their names and data\r\n */\r\n public downloadFiles(): void {\r\n for (const key in this.files) {\r\n const value = this.files[key];\r\n const blob = new Blob([value], { type: GetMimeType(key) });\r\n Tools.Download(blob, key);\r\n }\r\n }\r\n}\r\n"]}
|
@@ -6,11 +6,11 @@ import type { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture
|
|
6
6
|
import type { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
|
7
7
|
import { Material } from "@babylonjs/core/Materials/material.js";
|
8
8
|
import type { Scene } from "@babylonjs/core/scene.js";
|
9
|
-
import type { IGLTFExporterExtensionV2 } from "./glTFExporterExtension";
|
10
|
-
import { GLTFMaterialExporter } from "./glTFMaterialExporter";
|
11
|
-
import type { IExportOptions } from "./glTFSerializer";
|
12
|
-
import { GLTFData } from "./glTFData";
|
13
|
-
import { BufferManager } from "./bufferManager";
|
9
|
+
import type { IGLTFExporterExtensionV2 } from "./glTFExporterExtension.js";
|
10
|
+
import { GLTFMaterialExporter } from "./glTFMaterialExporter.js";
|
11
|
+
import type { IExportOptions } from "./glTFSerializer.js";
|
12
|
+
import { GLTFData } from "./glTFData.js";
|
13
|
+
import { BufferManager } from "./bufferManager.js";
|
14
14
|
/** @internal */
|
15
15
|
export declare class GLTFExporter {
|
16
16
|
readonly _glTF: IGLTF;
|
package/glTF/2.0/glTFExporter.js
CHANGED
@@ -2,14 +2,14 @@ import { TmpVectors, Quaternion, Matrix } from "@babylonjs/core/Maths/math.vecto
|
|
2
2
|
import { Tools } from "@babylonjs/core/Misc/tools.js";
|
3
3
|
import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
|
4
4
|
import { TransformNode } from "@babylonjs/core/Meshes/transformNode.js";
|
5
|
-
import {
|
5
|
+
import { AbstractMesh } from "@babylonjs/core/Meshes/abstractMesh.js";
|
6
6
|
import { InstancedMesh } from "@babylonjs/core/Meshes/instancedMesh.js";
|
7
7
|
import { Material } from "@babylonjs/core/Materials/material.js";
|
8
8
|
import { Engine } from "@babylonjs/core/Engines/engine.js";
|
9
9
|
import { EngineStore } from "@babylonjs/core/Engines/engineStore.js";
|
10
10
|
import { GLTFMaterialExporter } from "./glTFMaterialExporter.js";
|
11
11
|
import { GLTFData } from "./glTFData.js";
|
12
|
-
import { ConvertToRightHandedPosition, ConvertToRightHandedRotation, DataArrayToUint8Array, GetAccessorType, GetAttributeType, GetMinMax, GetPrimitiveMode, IsNoopNode, IsTriangleFillMode, IsParentAddedByImporter, ConvertToRightHandedNode, RotateNode180Y, FloatsNeed16BitInteger, IsStandardVertexAttribute, IndicesArrayToTypedArray, } from "./glTFUtilities.js";
|
12
|
+
import { ConvertToRightHandedPosition, ConvertToRightHandedRotation, DataArrayToUint8Array, GetAccessorType, GetAttributeType, GetMinMax, GetPrimitiveMode, IsNoopNode, IsTriangleFillMode, IsParentAddedByImporter, ConvertToRightHandedNode, RotateNode180Y, FloatsNeed16BitInteger, IsStandardVertexAttribute, IndicesArrayToTypedArray, GetVertexBufferInfo, } from "./glTFUtilities.js";
|
13
13
|
import { BufferManager } from "./bufferManager.js";
|
14
14
|
import { Camera } from "@babylonjs/core/Cameras/camera.js";
|
15
15
|
import { MultiMaterial } from "@babylonjs/core/Materials/multiMaterial.js";
|
@@ -263,7 +263,7 @@ export class GLTFExporter {
|
|
263
263
|
this._options = {
|
264
264
|
shouldExportNode: () => true,
|
265
265
|
shouldExportAnimation: () => true,
|
266
|
-
metadataSelector: (metadata) => metadata,
|
266
|
+
metadataSelector: (metadata) => metadata?.gltf?.extras,
|
267
267
|
animationSampleRate: 1 / 60,
|
268
268
|
exportWithoutWaitingForScene: false,
|
269
269
|
exportUnusedUVs: false,
|
@@ -614,11 +614,9 @@ export class GLTFExporter {
|
|
614
614
|
const scene = { nodes: [] };
|
615
615
|
// Scene metadata
|
616
616
|
if (this._babylonScene.metadata) {
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
else if (this._babylonScene.metadata.gltf) {
|
621
|
-
scene.extras = this._babylonScene.metadata.gltf.extras;
|
617
|
+
const extras = this._options.metadataSelector(this._babylonScene.metadata);
|
618
|
+
if (extras) {
|
619
|
+
scene.extras = extras;
|
622
620
|
}
|
623
621
|
}
|
624
622
|
// TODO:
|
@@ -673,7 +671,7 @@ export class GLTFExporter {
|
|
673
671
|
return nodes;
|
674
672
|
}
|
675
673
|
_collectBuffers(babylonNode, bufferToVertexBuffersMap, vertexBufferToMeshesMap, morphTargetsToMeshesMap, state) {
|
676
|
-
if (this._shouldExportNode(babylonNode) && babylonNode instanceof
|
674
|
+
if (this._shouldExportNode(babylonNode) && babylonNode instanceof AbstractMesh && babylonNode.geometry) {
|
677
675
|
const vertexBuffers = babylonNode.geometry.getVertexBuffers();
|
678
676
|
if (vertexBuffers) {
|
679
677
|
for (const kind in vertexBuffers) {
|
@@ -714,9 +712,9 @@ export class GLTFExporter {
|
|
714
712
|
_exportBuffers(babylonRootNodes, state) {
|
715
713
|
const bufferToVertexBuffersMap = new Map();
|
716
714
|
const vertexBufferToMeshesMap = new Map();
|
717
|
-
const
|
715
|
+
const morphTargetsMeshesMap = new Map();
|
718
716
|
for (const babylonNode of babylonRootNodes) {
|
719
|
-
this._collectBuffers(babylonNode, bufferToVertexBuffersMap, vertexBufferToMeshesMap,
|
717
|
+
this._collectBuffers(babylonNode, bufferToVertexBuffersMap, vertexBufferToMeshesMap, morphTargetsMeshesMap, state);
|
720
718
|
}
|
721
719
|
const buffers = Array.from(bufferToVertexBuffersMap.keys());
|
722
720
|
for (const buffer of buffers) {
|
@@ -733,19 +731,15 @@ export class GLTFExporter {
|
|
733
731
|
throw new Error("Vertex buffers pointing to the same buffer must have the same byte stride");
|
734
732
|
}
|
735
733
|
const bytes = DataArrayToUint8Array(data).slice();
|
736
|
-
// Apply
|
734
|
+
// Apply normalizations and color corrections to buffer data in-place.
|
737
735
|
for (const vertexBuffer of vertexBuffers) {
|
738
|
-
const { byteOffset, byteStride, type, normalized } = vertexBuffer;
|
739
|
-
const size = vertexBuffer.getSize();
|
740
736
|
const meshes = vertexBufferToMeshesMap.get(vertexBuffer);
|
741
|
-
const
|
742
|
-
|
743
|
-
}, -Number.MAX_VALUE); // To ensure nothing is missed when enumerating, but may not be necessary.
|
744
|
-
switch (vertexBuffer.getKind()) {
|
737
|
+
const { byteOffset, byteStride, componentCount, type, count, normalized, kind } = GetVertexBufferInfo(vertexBuffer, meshes);
|
738
|
+
switch (kind) {
|
745
739
|
// Normalize normals and tangents.
|
746
740
|
case VertexBuffer.NormalKind:
|
747
741
|
case VertexBuffer.TangentKind: {
|
748
|
-
EnumerateFloatValues(bytes, byteOffset, byteStride,
|
742
|
+
EnumerateFloatValues(bytes, byteOffset, byteStride, componentCount, type, count, normalized, (values) => {
|
749
743
|
const length = Math.sqrt(values[0] * values[0] + values[1] * values[1] + values[2] * values[2]);
|
750
744
|
if (length > 0) {
|
751
745
|
const invLength = 1 / length;
|
@@ -773,7 +767,7 @@ export class GLTFExporter {
|
|
773
767
|
const vertexData3 = new Color3();
|
774
768
|
const vertexData4 = new Color4();
|
775
769
|
const useExactSrgbConversions = this._babylonScene.getEngine().useExactSrgbConversions;
|
776
|
-
EnumerateFloatValues(bytes, byteOffset, byteStride,
|
770
|
+
EnumerateFloatValues(bytes, byteOffset, byteStride, componentCount, type, count, normalized, (values) => {
|
777
771
|
// Using separate Color3 and Color4 objects to ensure the right functions are called.
|
778
772
|
if (values.length === 3) {
|
779
773
|
vertexData3.fromArray(values, 0);
|
@@ -789,20 +783,18 @@ export class GLTFExporter {
|
|
789
783
|
}
|
790
784
|
}
|
791
785
|
}
|
792
|
-
//
|
786
|
+
// Perform coordinate conversions, if needed, to buffer data in-place (only for positions, normals and tangents).
|
793
787
|
if (state.convertToRightHanded) {
|
794
788
|
for (const vertexBuffer of vertexBuffers) {
|
795
|
-
|
789
|
+
const meshes = vertexBufferToMeshesMap.get(vertexBuffer);
|
790
|
+
const { byteOffset, byteStride, componentCount, type, count, normalized, kind } = GetVertexBufferInfo(vertexBuffer, meshes);
|
791
|
+
switch (kind) {
|
796
792
|
case VertexBuffer.PositionKind:
|
797
793
|
case VertexBuffer.NormalKind:
|
798
794
|
case VertexBuffer.TangentKind: {
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
EnumerateFloatValues(bytes, byteOffset, byteStride, size, type, mesh.getTotalVertices() * size, normalized, (values) => {
|
803
|
-
values[0] = -values[0];
|
804
|
-
});
|
805
|
-
}
|
795
|
+
EnumerateFloatValues(bytes, byteOffset, byteStride, componentCount, type, count, normalized, (values) => {
|
796
|
+
values[0] = -values[0];
|
797
|
+
});
|
806
798
|
}
|
807
799
|
}
|
808
800
|
}
|
@@ -815,15 +807,15 @@ export class GLTFExporter {
|
|
815
807
|
const floatMatricesIndices = new Map();
|
816
808
|
// If buffers are of type MatricesIndicesKind and have float values, we need to create a new buffer instead.
|
817
809
|
for (const vertexBuffer of vertexBuffers) {
|
818
|
-
|
810
|
+
const meshes = vertexBufferToMeshesMap.get(vertexBuffer);
|
811
|
+
const { kind, totalVertices } = GetVertexBufferInfo(vertexBuffer, meshes);
|
812
|
+
switch (kind) {
|
819
813
|
case VertexBuffer.MatricesIndicesKind:
|
820
814
|
case VertexBuffer.MatricesIndicesExtraKind: {
|
821
815
|
if (vertexBuffer.type == VertexBuffer.FLOAT) {
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
floatMatricesIndices.set(vertexBuffer, floatData);
|
826
|
-
}
|
816
|
+
const floatData = vertexBuffer.getFloatData(totalVertices);
|
817
|
+
if (floatData !== null) {
|
818
|
+
floatMatricesIndices.set(vertexBuffer, floatData);
|
827
819
|
}
|
828
820
|
}
|
829
821
|
}
|
@@ -847,9 +839,10 @@ export class GLTFExporter {
|
|
847
839
|
state.setRemappedBufferView(buffer, vertexBuffer, bufferView);
|
848
840
|
}
|
849
841
|
}
|
850
|
-
|
842
|
+
// Build morph targets buffers
|
843
|
+
const morphTargets = Array.from(morphTargetsMeshesMap.keys());
|
851
844
|
for (const morphTarget of morphTargets) {
|
852
|
-
const meshes =
|
845
|
+
const meshes = morphTargetsMeshesMap.get(morphTarget);
|
853
846
|
if (!meshes) {
|
854
847
|
continue;
|
855
848
|
}
|
@@ -922,10 +915,17 @@ export class GLTFExporter {
|
|
922
915
|
if (babylonNode.name) {
|
923
916
|
node.name = babylonNode.name;
|
924
917
|
}
|
918
|
+
// Node metadata
|
919
|
+
if (babylonNode.metadata) {
|
920
|
+
const extras = this._options.metadataSelector(babylonNode.metadata);
|
921
|
+
if (extras) {
|
922
|
+
node.extras = extras;
|
923
|
+
}
|
924
|
+
}
|
925
925
|
if (babylonNode instanceof TransformNode) {
|
926
926
|
this._setNodeTransformation(node, babylonNode, state.convertToRightHanded);
|
927
|
-
if (babylonNode instanceof
|
928
|
-
const babylonMesh = babylonNode instanceof
|
927
|
+
if (babylonNode instanceof AbstractMesh) {
|
928
|
+
const babylonMesh = babylonNode instanceof InstancedMesh ? babylonNode.sourceMesh : babylonNode;
|
929
929
|
if (babylonMesh.subMeshes && babylonMesh.subMeshes.length > 0) {
|
930
930
|
node.mesh = await this._exportMeshAsync(babylonMesh, state);
|
931
931
|
}
|