@babylonjs/loaders 8.5.0 → 8.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BVH/bvhFileLoader.d.ts +66 -0
- package/BVH/bvhFileLoader.js +105 -0
- package/BVH/bvhFileLoader.js.map +1 -0
- package/BVH/bvhFileLoader.metadata.d.ts +8 -0
- package/BVH/bvhFileLoader.metadata.js +8 -0
- package/BVH/bvhFileLoader.metadata.js.map +1 -0
- package/BVH/bvhLoader.d.ts +11 -0
- package/BVH/bvhLoader.js +329 -0
- package/BVH/bvhLoader.js.map +1 -0
- package/BVH/bvhLoadingOptions.d.ts +9 -0
- package/BVH/bvhLoadingOptions.js +2 -0
- package/BVH/bvhLoadingOptions.js.map +1 -0
- package/BVH/index.d.ts +1 -0
- package/BVH/index.js +3 -0
- package/BVH/index.js.map +1 -0
- package/OBJ/mtlFileLoader.js +6 -6
- package/OBJ/mtlFileLoader.js.map +1 -1
- package/OBJ/objFileLoader.d.ts +1 -1
- package/OBJ/objFileLoader.js +2 -2
- package/OBJ/objFileLoader.js.map +1 -1
- package/OBJ/solidParser.js +4 -2
- package/OBJ/solidParser.js.map +1 -1
- package/SPLAT/splatFileLoader.d.ts +2 -2
- package/SPLAT/splatFileLoader.js +7 -7
- package/SPLAT/splatFileLoader.js.map +1 -1
- package/bvh/license.md +21 -0
- package/dynamic.js +9 -0
- package/dynamic.js.map +1 -1
- package/glTF/1.0/glTFBinaryExtension.js +4 -0
- package/glTF/1.0/glTFBinaryExtension.js.map +1 -1
- package/glTF/1.0/glTFLoader.js +114 -86
- package/glTF/1.0/glTFLoader.js.map +1 -1
- package/glTF/1.0/glTFLoaderInterfaces.d.ts +3 -3
- package/glTF/1.0/glTFLoaderInterfaces.js.map +1 -1
- package/glTF/1.0/glTFMaterialsCommonExtension.js +2 -0
- package/glTF/1.0/glTFMaterialsCommonExtension.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_lights_ies.js +2 -0
- package/glTF/2.0/Extensions/EXT_lights_ies.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_lights_image_based.js +1 -0
- package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +1 -0
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js +1 -0
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_texture_avif.js +1 -0
- package/glTF/2.0/Extensions/EXT_texture_avif.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_texture_webp.js +2 -1
- package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js +2 -0
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_animation_pointer.data.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_animation_pointer.js +1 -0
- package/glTF/2.0/Extensions/KHR_animation_pointer.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +1 -0
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js +1 -0
- package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_interactivity.js +1 -0
- package/glTF/2.0/Extensions/KHR_interactivity.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.js +1 -0
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_anisotropy.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_anisotropy.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_dispersion.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_dispersion.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_ior.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_iridescence.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_iridescence.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_unlit.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_variants.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.js +1 -0
- package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_node_hoverability.js +7 -6
- package/glTF/2.0/Extensions/KHR_node_hoverability.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_node_selectability.js +1 -0
- package/glTF/2.0/Extensions/KHR_node_selectability.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_node_visibility.js +1 -0
- package/glTF/2.0/Extensions/KHR_node_visibility.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_basisu.js +1 -0
- package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.js +1 -0
- package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +6 -6
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js +3 -0
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_lod.js +5 -0
- package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +1 -0
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.d.ts +1 -1
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +2 -1
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
- package/glTF/2.0/Extensions/objectModelMapping.js +120 -118
- package/glTF/2.0/Extensions/objectModelMapping.js.map +1 -1
- package/glTF/2.0/glTFLoader.js +18 -1
- package/glTF/2.0/glTFLoader.js.map +1 -1
- package/glTF/2.0/glTFLoaderAnimation.js +3 -0
- package/glTF/2.0/glTFLoaderAnimation.js.map +1 -1
- package/glTF/2.0/glTFLoaderExtensionRegistry.js +7 -4
- package/glTF/2.0/glTFLoaderExtensionRegistry.js.map +1 -1
- package/glTF/glTFFileLoader.d.ts +2 -2
- package/glTF/glTFFileLoader.js.map +1 -1
- package/glTF/glTFValidation.js +5 -5
- package/glTF/glTFValidation.js.map +1 -1
- package/legacy/legacy-glTF.js +5 -5
- package/legacy/legacy-glTF.js.map +1 -1
- package/legacy/legacy-glTF1.js +5 -5
- package/legacy/legacy-glTF1.js.map +1 -1
- package/legacy/legacy-glTF2.js +5 -4
- package/legacy/legacy-glTF2.js.map +1 -1
- package/legacy/legacy-objFileLoader.js +4 -4
- package/legacy/legacy-objFileLoader.js.map +1 -1
- package/legacy/legacy-stlFileLoader.js +4 -4
- package/legacy/legacy-stlFileLoader.js.map +1 -1
- package/package.json +3 -3
@@ -0,0 +1,66 @@
|
|
1
|
+
import type { ISceneLoaderPluginAsync, ISceneLoaderPluginFactory, ISceneLoaderAsyncResult, SceneLoaderPluginOptions } from "@babylonjs/core/Loading/sceneLoader.js";
|
2
|
+
import { AssetContainer } from "@babylonjs/core/assetContainer.js";
|
3
|
+
import type { Scene } from "@babylonjs/core/scene.js";
|
4
|
+
import type { BVHLoadingOptions } from "./bvhLoadingOptions.js";
|
5
|
+
import { BVHFileLoaderMetadata } from "./bvhFileLoader.metadata.js";
|
6
|
+
declare module "@babylonjs/core/Loading/sceneLoader.js" {
|
7
|
+
interface SceneLoaderPluginOptions {
|
8
|
+
/**
|
9
|
+
* Defines options for the bvh loader.
|
10
|
+
*/
|
11
|
+
[BVHFileLoaderMetadata.name]: Partial<BVHLoadingOptions>;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
/**
|
15
|
+
* @experimental
|
16
|
+
* BVH file type loader.
|
17
|
+
* This is a babylon scene loader plugin.
|
18
|
+
*/
|
19
|
+
export declare class BVHFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
|
20
|
+
/**
|
21
|
+
* Name of the loader ("bvh")
|
22
|
+
*/
|
23
|
+
readonly name: "bvh";
|
24
|
+
/** @internal */
|
25
|
+
readonly extensions: {
|
26
|
+
readonly ".bvh": {
|
27
|
+
readonly isBinary: false;
|
28
|
+
};
|
29
|
+
};
|
30
|
+
private readonly _loadingOptions;
|
31
|
+
/**
|
32
|
+
* Creates loader for bvh motion files
|
33
|
+
* @param loadingOptions - Options for the bvh loader
|
34
|
+
*/
|
35
|
+
constructor(loadingOptions?: Partial<Readonly<BVHLoadingOptions>>);
|
36
|
+
private static get _DefaultLoadingOptions();
|
37
|
+
/** @internal */
|
38
|
+
createPlugin(options: SceneLoaderPluginOptions): ISceneLoaderPluginAsync;
|
39
|
+
/**
|
40
|
+
* If the data string can be loaded directly.
|
41
|
+
* @returns if the data can be loaded directly
|
42
|
+
*/
|
43
|
+
canDirectLoad(): boolean;
|
44
|
+
/**
|
45
|
+
* Imports from the loaded gaussian splatting data and adds them to the scene
|
46
|
+
* @param _meshesNames a string or array of strings of the mesh names that should be loaded from the file
|
47
|
+
* @param scene the scene the meshes should be added to
|
48
|
+
* @param data the bvh data to load
|
49
|
+
* @returns a promise containing the loaded skeletons and animations
|
50
|
+
*/
|
51
|
+
importMeshAsync(_meshesNames: string | readonly string[] | null | undefined, scene: Scene, data: unknown): Promise<ISceneLoaderAsyncResult>;
|
52
|
+
/**
|
53
|
+
* Imports all objects from the loaded bvh data and adds them to the scene
|
54
|
+
* @param scene the scene the objects should be added to
|
55
|
+
* @param data the bvh data to load
|
56
|
+
* @returns a promise which completes when objects have been loaded to the scene
|
57
|
+
*/
|
58
|
+
loadAsync(scene: Scene, data: unknown): Promise<void>;
|
59
|
+
/**
|
60
|
+
* Load into an asset container.
|
61
|
+
* @param scene The scene to load into
|
62
|
+
* @param data The data to import
|
63
|
+
* @returns The loaded asset container
|
64
|
+
*/
|
65
|
+
loadAssetContainerAsync(scene: Scene, data: unknown): Promise<AssetContainer>;
|
66
|
+
}
|
@@ -0,0 +1,105 @@
|
|
1
|
+
import { RegisterSceneLoaderPlugin } from "@babylonjs/core/Loading/sceneLoader.js";
|
2
|
+
import { AssetContainer } from "@babylonjs/core/assetContainer.js";
|
3
|
+
import { Animation } from "@babylonjs/core/Animations/animation.js";
|
4
|
+
import { BVHFileLoaderMetadata } from "./bvhFileLoader.metadata.js";
|
5
|
+
import { ReadBvh } from "./bvhLoader.js";
|
6
|
+
/**
|
7
|
+
* @experimental
|
8
|
+
* BVH file type loader.
|
9
|
+
* This is a babylon scene loader plugin.
|
10
|
+
*/
|
11
|
+
export class BVHFileLoader {
|
12
|
+
/**
|
13
|
+
* Creates loader for bvh motion files
|
14
|
+
* @param loadingOptions - Options for the bvh loader
|
15
|
+
*/
|
16
|
+
constructor(loadingOptions) {
|
17
|
+
/**
|
18
|
+
* Name of the loader ("bvh")
|
19
|
+
*/
|
20
|
+
this.name = BVHFileLoaderMetadata.name;
|
21
|
+
/** @internal */
|
22
|
+
this.extensions = BVHFileLoaderMetadata.extensions;
|
23
|
+
this._loadingOptions = { ...BVHFileLoader._DefaultLoadingOptions, ...(loadingOptions ?? {}) };
|
24
|
+
}
|
25
|
+
static get _DefaultLoadingOptions() {
|
26
|
+
return {
|
27
|
+
loopMode: Animation.ANIMATIONLOOPMODE_CYCLE,
|
28
|
+
};
|
29
|
+
}
|
30
|
+
/** @internal */
|
31
|
+
createPlugin(options) {
|
32
|
+
return new BVHFileLoader(options[BVHFileLoaderMetadata.name]);
|
33
|
+
}
|
34
|
+
/**
|
35
|
+
* If the data string can be loaded directly.
|
36
|
+
* @returns if the data can be loaded directly
|
37
|
+
*/
|
38
|
+
canDirectLoad() {
|
39
|
+
return true;
|
40
|
+
}
|
41
|
+
/**
|
42
|
+
* Imports from the loaded gaussian splatting data and adds them to the scene
|
43
|
+
* @param _meshesNames a string or array of strings of the mesh names that should be loaded from the file
|
44
|
+
* @param scene the scene the meshes should be added to
|
45
|
+
* @param data the bvh data to load
|
46
|
+
* @returns a promise containing the loaded skeletons and animations
|
47
|
+
*/
|
48
|
+
importMeshAsync(_meshesNames, scene, data) {
|
49
|
+
if (typeof data !== "string") {
|
50
|
+
return Promise.reject("BVH loader expects string data.");
|
51
|
+
}
|
52
|
+
try {
|
53
|
+
const skeleton = ReadBvh(data, scene, this._loadingOptions);
|
54
|
+
return Promise.resolve({
|
55
|
+
meshes: [],
|
56
|
+
particleSystems: [],
|
57
|
+
skeletons: [skeleton],
|
58
|
+
animationGroups: [],
|
59
|
+
transformNodes: [],
|
60
|
+
geometries: [],
|
61
|
+
lights: [],
|
62
|
+
spriteManagers: [],
|
63
|
+
});
|
64
|
+
}
|
65
|
+
catch (e) {
|
66
|
+
return Promise.reject(e);
|
67
|
+
}
|
68
|
+
}
|
69
|
+
/**
|
70
|
+
* Imports all objects from the loaded bvh data and adds them to the scene
|
71
|
+
* @param scene the scene the objects should be added to
|
72
|
+
* @param data the bvh data to load
|
73
|
+
* @returns a promise which completes when objects have been loaded to the scene
|
74
|
+
*/
|
75
|
+
loadAsync(scene, data) {
|
76
|
+
if (typeof data !== "string") {
|
77
|
+
return Promise.reject("BVH loader expects string data.");
|
78
|
+
}
|
79
|
+
return this.importMeshAsync(null, scene, data).then(() => {
|
80
|
+
// return void
|
81
|
+
});
|
82
|
+
}
|
83
|
+
/**
|
84
|
+
* Load into an asset container.
|
85
|
+
* @param scene The scene to load into
|
86
|
+
* @param data The data to import
|
87
|
+
* @returns The loaded asset container
|
88
|
+
*/
|
89
|
+
loadAssetContainerAsync(scene, data) {
|
90
|
+
if (typeof data !== "string") {
|
91
|
+
return Promise.reject("BVH loader expects string data.");
|
92
|
+
}
|
93
|
+
const assetContainer = new AssetContainer(scene);
|
94
|
+
try {
|
95
|
+
const skeleton = ReadBvh(data, scene, this._loadingOptions);
|
96
|
+
assetContainer.skeletons.push(skeleton);
|
97
|
+
return Promise.resolve(assetContainer);
|
98
|
+
}
|
99
|
+
catch (e) {
|
100
|
+
return Promise.reject(e);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
}
|
104
|
+
RegisterSceneLoaderPlugin(new BVHFileLoader());
|
105
|
+
//# sourceMappingURL=bvhFileLoader.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"bvhFileLoader.js","sourceRoot":"","sources":["../../../../dev/loaders/src/BVH/bvhFileLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,+CAAiC;AACrE,OAAO,EAAE,cAAc,EAAE,0CAA4B;AACrD,OAAO,EA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neLoader\";\nimport { RegisterSceneLoaderPlugin } from \"core/Loading/sceneLoader\";\nimport { AssetContainer } from \"core/assetContainer\";\nimport { Animation } from \"core/Animations/animation\";\nimport type { Scene } from \"core/scene\";\nimport type { BVHLoadingOptions } from \"./bvhLoadingOptions\";\nimport { BVHFileLoaderMetadata } from \"./bvhFileLoader.metadata\";\nimport { ReadBvh } from \"./bvhLoader\";\n\ndeclare module \"core/Loading/sceneLoader\" {\n // eslint-disable-next-line jsdoc/require-jsdoc, @typescript-eslint/naming-convention\n export interface SceneLoaderPluginOptions {\n /**\n * Defines options for the bvh loader.\n */\n [BVHFileLoaderMetadata.name]: Partial<BVHLoadingOptions>;\n }\n}\n\n/**\n * @experimental\n * BVH file type loader.\n * This is a babylon scene loader plugin.\n */\nexport class BVHFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {\n /**\n * Name of the loader (\"bvh\")\n */\n public readonly name = BVHFileLoaderMetadata.name;\n\n /** @internal */\n public readonly extensions = BVHFileLoaderMetadata.extensions;\n\n private readonly _loadingOptions: BVHLoadingOptions;\n\n /**\n * Creates loader for bvh motion files\n * @param loadingOptions - Options for the bvh loader\n */\n constructor(loadingOptions?: Partial<Readonly<BVHLoadingOptions>>) {\n this._loadingOptions = { ...BVHFileLoader._DefaultLoadingOptions, ...(loadingOptions ?? {}) };\n }\n\n private static get _DefaultLoadingOptions(): BVHLoadingOptions {\n return {\n loopMode: Animation.ANIMATIONLOOPMODE_CYCLE,\n };\n }\n\n /** @internal */\n public createPlugin(options: SceneLoaderPluginOptions): ISceneLoaderPluginAsync {\n return new BVHFileLoader(options[BVHFileLoaderMetadata.name]);\n }\n\n /**\n * If the data string can be loaded directly.\n * @returns if the data can be loaded directly\n */\n public canDirectLoad(): boolean {\n return true;\n }\n\n /**\n * Imports from the loaded gaussian splatting data and adds them to the scene\n * @param _meshesNames a string or array of strings of the mesh names that should be loaded from the file\n * @param scene the scene the meshes should be added to\n * @param data the bvh data to load\n * @returns a promise containing the loaded skeletons and animations\n */\n public importMeshAsync(_meshesNames: string | readonly string[] | null | undefined, scene: Scene, data: unknown): Promise<ISceneLoaderAsyncResult> {\n if (typeof data !== \"string\") {\n return Promise.reject(\"BVH loader expects string data.\");\n }\n try {\n const skeleton = ReadBvh(data, scene, this._loadingOptions);\n return Promise.resolve({\n meshes: [],\n particleSystems: [],\n skeletons: [skeleton],\n animationGroups: [],\n transformNodes: [],\n geometries: [],\n lights: [],\n spriteManagers: [],\n });\n } catch (e) {\n return Promise.reject(e);\n }\n }\n\n /**\n * Imports all objects from the loaded bvh data and adds them to the scene\n * @param scene the scene the objects should be added to\n * @param data the bvh data to load\n * @returns a promise which completes when objects have been loaded to the scene\n */\n public loadAsync(scene: Scene, data: unknown): Promise<void> {\n if (typeof data !== \"string\") {\n return Promise.reject(\"BVH loader expects string data.\");\n }\n\n return this.importMeshAsync(null, scene, data).then(() => {\n // return void\n });\n }\n\n /**\n * Load into an asset container.\n * @param scene The scene to load into\n * @param data The data to import\n * @returns The loaded asset container\n */\n public loadAssetContainerAsync(scene: Scene, data: unknown): Promise<AssetContainer> {\n if (typeof data !== \"string\") {\n return Promise.reject(\"BVH loader expects string data.\");\n }\n const assetContainer = new AssetContainer(scene);\n try {\n const skeleton = ReadBvh(data, scene, this._loadingOptions);\n assetContainer.skeletons.push(skeleton);\n return Promise.resolve(assetContainer);\n } catch (e) {\n return Promise.reject(e);\n }\n }\n}\n\nRegisterSceneLoaderPlugin(new BVHFileLoader());\n"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"bvhFileLoader.metadata.js","sourceRoot":"","sources":["../../../../dev/loaders/src/BVH/bvhFileLoader.metadata.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACjC,IAAI,EAAE,KAAK;IACX,UAAU,EAAE;QACR,gEAAgE;QAChE,MAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE;KACkB;CACN,CAAC","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { ISceneLoaderPluginExtensions, ISceneLoaderPluginMetadata } from \"core/index\";\r\n\r\nexport const BVHFileLoaderMetadata = {\r\n name: \"bvh\",\r\n extensions: {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \".bvh\": { isBinary: false },\r\n } as const satisfies ISceneLoaderPluginExtensions,\r\n} as const satisfies ISceneLoaderPluginMetadata;\r\n"]}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { Skeleton } from "@babylonjs/core/Bones/skeleton.js";
|
2
|
+
import type { Scene } from "@babylonjs/core/scene.js";
|
3
|
+
import type { BVHLoadingOptions } from "./bvhLoadingOptions.js";
|
4
|
+
/**
|
5
|
+
* Reads a BVH file, returns a skeleton
|
6
|
+
* @param text - The BVH file content
|
7
|
+
* @param scene - The scene to add the skeleton to
|
8
|
+
* @param loadingOptions - The loading options
|
9
|
+
* @returns The skeleton
|
10
|
+
*/
|
11
|
+
export declare function ReadBvh(text: string, scene: Scene, loadingOptions: BVHLoadingOptions): Skeleton;
|
package/BVH/bvhLoader.js
ADDED
@@ -0,0 +1,329 @@
|
|
1
|
+
import { Animation } from "@babylonjs/core/Animations/animation.js";
|
2
|
+
import { Bone } from "@babylonjs/core/Bones/bone.js";
|
3
|
+
import { Skeleton } from "@babylonjs/core/Bones/skeleton.js";
|
4
|
+
import { Axis } from "@babylonjs/core/Maths/math.axis.js";
|
5
|
+
import { Matrix, Quaternion, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
6
|
+
import { Tools } from "@babylonjs/core/Misc/tools.js";
|
7
|
+
const _XPosition = "Xposition";
|
8
|
+
const _YPosition = "Yposition";
|
9
|
+
const _ZPosition = "Zposition";
|
10
|
+
const _XRotation = "Xrotation";
|
11
|
+
const _YRotation = "Yrotation";
|
12
|
+
const _ZRotation = "Zrotation";
|
13
|
+
const _HierarchyNode = "HIERARCHY";
|
14
|
+
const _MotionNode = "MOTION";
|
15
|
+
class LoaderContext {
|
16
|
+
constructor(skeleton) {
|
17
|
+
this.loopMode = Animation.ANIMATIONLOOPMODE_CYCLE;
|
18
|
+
this.list = [];
|
19
|
+
this.root = CreateBVHNode();
|
20
|
+
this.numFrames = 0;
|
21
|
+
this.frameRate = 0;
|
22
|
+
this.skeleton = skeleton;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
function CreateBVHNode() {
|
26
|
+
return {
|
27
|
+
name: "",
|
28
|
+
type: "",
|
29
|
+
offset: new Vector3(),
|
30
|
+
channels: [],
|
31
|
+
children: [],
|
32
|
+
frames: [],
|
33
|
+
parent: null,
|
34
|
+
};
|
35
|
+
}
|
36
|
+
function CreateBVHKeyFrame() {
|
37
|
+
return {
|
38
|
+
time: 0,
|
39
|
+
position: new Vector3(),
|
40
|
+
rotation: new Quaternion(),
|
41
|
+
};
|
42
|
+
}
|
43
|
+
/**
|
44
|
+
* Converts the BVH node's offset to a Babylon matrix
|
45
|
+
* @param node - The BVH node to convert
|
46
|
+
* @returns The converted matrix
|
47
|
+
*/
|
48
|
+
function BoneOffset(node) {
|
49
|
+
const x = node.offset.x;
|
50
|
+
const y = node.offset.y;
|
51
|
+
// Flip Z axis to convert handedness.
|
52
|
+
const z = -node.offset.z;
|
53
|
+
return Matrix.Translation(x, y, z);
|
54
|
+
}
|
55
|
+
/**
|
56
|
+
* Creates animations for the BVH node
|
57
|
+
* @param node - The BVH node to create animations for
|
58
|
+
* @param context - The loader context
|
59
|
+
* @returns The created animations
|
60
|
+
*/
|
61
|
+
function CreateAnimations(node, context) {
|
62
|
+
if (node.frames.length === 0) {
|
63
|
+
return null;
|
64
|
+
}
|
65
|
+
const keyFrames = [];
|
66
|
+
// Create position animation if there are position channels
|
67
|
+
const hasPosition = node.channels.some((c) => c === _XPosition || c === _YPosition || c === _ZPosition);
|
68
|
+
// Create rotation animation if there are rotation channels
|
69
|
+
const hasRotation = node.channels.some((c) => c === _XRotation || c === _YRotation || c === _ZRotation);
|
70
|
+
for (let i = 0; i < node.frames.length; i++) {
|
71
|
+
const frame = node.frames[i];
|
72
|
+
const time = i * context.frameRate * 1000; // Convert to milliseconds
|
73
|
+
if (hasPosition || hasRotation) {
|
74
|
+
let matrix = Matrix.Identity();
|
75
|
+
if (hasRotation) {
|
76
|
+
const rotationMatrix = new Matrix();
|
77
|
+
frame.rotation.toRotationMatrix(rotationMatrix);
|
78
|
+
matrix = rotationMatrix;
|
79
|
+
}
|
80
|
+
if (hasPosition) {
|
81
|
+
const position = frame.position;
|
82
|
+
matrix.setTranslation(new Vector3(position.x, position.y, position.z));
|
83
|
+
}
|
84
|
+
keyFrames.push({
|
85
|
+
frame: time,
|
86
|
+
value: matrix,
|
87
|
+
});
|
88
|
+
}
|
89
|
+
}
|
90
|
+
if (keyFrames.length === 0) {
|
91
|
+
return null;
|
92
|
+
}
|
93
|
+
const fps = 60 / context.frameRate;
|
94
|
+
const animation = new Animation(node.name + "_anim", "_matrix", fps, Animation.ANIMATIONTYPE_MATRIX, context.loopMode);
|
95
|
+
animation.setKeys(keyFrames);
|
96
|
+
return animation;
|
97
|
+
}
|
98
|
+
/**
|
99
|
+
* Converts a BVH node to a Babylon bone
|
100
|
+
* @param node - The BVH node to convert
|
101
|
+
* @param parent - The parent bone
|
102
|
+
* @param context - The loader context
|
103
|
+
*/
|
104
|
+
function ConvertNode(node, parent, context) {
|
105
|
+
const matrix = BoneOffset(node);
|
106
|
+
const bone = new Bone(node.name, context.skeleton, parent, matrix);
|
107
|
+
// Create animation for this bone
|
108
|
+
const animation = CreateAnimations(node, context);
|
109
|
+
if (animation) {
|
110
|
+
// Apply rotation correction to the root bone's animation keys
|
111
|
+
if (!parent) {
|
112
|
+
// Check if it's the root node
|
113
|
+
const correctionMatrix = Matrix.RotationAxis(Axis.X, Math.PI / 2); // -90 degrees on X-axis
|
114
|
+
const correctedKeys = animation.getKeys().map((key) => {
|
115
|
+
const originalMatrix = key.value;
|
116
|
+
// Apply correction: We want to rotate the final orientation, so post-multiply
|
117
|
+
const correctedMatrix = originalMatrix.multiply(correctionMatrix);
|
118
|
+
return { frame: key.frame, value: correctedMatrix };
|
119
|
+
});
|
120
|
+
animation.setKeys(correctedKeys);
|
121
|
+
}
|
122
|
+
bone.animations.push(animation);
|
123
|
+
}
|
124
|
+
for (const child of node.children) {
|
125
|
+
ConvertNode(child, bone, context);
|
126
|
+
}
|
127
|
+
}
|
128
|
+
/**
|
129
|
+
* Recursively reads data from a single frame into the bone hierarchy.
|
130
|
+
* The bone hierarchy has to be structured in the same order as the BVH file.
|
131
|
+
* keyframe data is stored in bone.frames.
|
132
|
+
* @param data - splitted string array (frame values), values are shift()ed
|
133
|
+
* @param frameTime - playback time for this keyframe
|
134
|
+
* @param bone - the bone to read frame data from
|
135
|
+
*/
|
136
|
+
function ReadFrameData(data, frameTime, bone) {
|
137
|
+
if (bone.type === "ENDSITE") {
|
138
|
+
// end sites have no motion data
|
139
|
+
return;
|
140
|
+
}
|
141
|
+
// add keyframe
|
142
|
+
const keyframe = CreateBVHKeyFrame();
|
143
|
+
keyframe.time = frameTime;
|
144
|
+
keyframe.position = new Vector3();
|
145
|
+
keyframe.rotation = new Quaternion();
|
146
|
+
bone.frames.push(keyframe);
|
147
|
+
let pitch = 0, yaw = 0, roll = 0;
|
148
|
+
// parse values for each channel in node
|
149
|
+
for (let i = 0; i < bone.channels.length; ++i) {
|
150
|
+
const value = data.shift();
|
151
|
+
if (!value) {
|
152
|
+
continue;
|
153
|
+
}
|
154
|
+
switch (bone.channels[i]) {
|
155
|
+
case _XPosition:
|
156
|
+
keyframe.position.x = parseFloat(value.trim());
|
157
|
+
break;
|
158
|
+
case _YPosition:
|
159
|
+
keyframe.position.y = parseFloat(value.trim());
|
160
|
+
break;
|
161
|
+
case _ZPosition:
|
162
|
+
keyframe.position.z = -parseFloat(value.trim()); // Flip Z axis to convert handedness.
|
163
|
+
break;
|
164
|
+
case _XRotation:
|
165
|
+
pitch = Tools.ToRadians(+value);
|
166
|
+
break;
|
167
|
+
case _YRotation:
|
168
|
+
yaw = Tools.ToRadians(+value);
|
169
|
+
break;
|
170
|
+
case _ZRotation:
|
171
|
+
roll = Tools.ToRadians(+value);
|
172
|
+
break;
|
173
|
+
default:
|
174
|
+
throw new Error("invalid channel type");
|
175
|
+
}
|
176
|
+
}
|
177
|
+
if (yaw !== 0 || pitch !== 0 || roll !== 0) {
|
178
|
+
// Create rotation matrix in proper order
|
179
|
+
const rotationMatrix = Matrix.Identity();
|
180
|
+
Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, rotationMatrix);
|
181
|
+
keyframe.rotation.fromRotationMatrix(rotationMatrix);
|
182
|
+
}
|
183
|
+
// parse child nodes
|
184
|
+
for (let i = 0; i < bone.children.length; ++i) {
|
185
|
+
ReadFrameData(data, frameTime, bone.children[i]);
|
186
|
+
}
|
187
|
+
}
|
188
|
+
/**
|
189
|
+
* Recursively parses the HIERARCHY section of the BVH file
|
190
|
+
* @param lines - all lines of the file. lines are consumed as we go along
|
191
|
+
* @param firstLine - line containing the node type and name e.g. "JOINT hip"
|
192
|
+
* @param parent - the parent node for hierarchy
|
193
|
+
* @param context - the loader context containing the list of nodes and other data
|
194
|
+
* @returns a BVH node including children
|
195
|
+
*/
|
196
|
+
function ReadNode(lines, firstLine, parent, context) {
|
197
|
+
const node = CreateBVHNode();
|
198
|
+
node.parent = parent;
|
199
|
+
context.list.push(node);
|
200
|
+
// parse node type and name.
|
201
|
+
let tokens = firstLine.trim().split(/\s+/);
|
202
|
+
if (tokens[0].toUpperCase() === "END" && tokens[1].toUpperCase() === "SITE") {
|
203
|
+
node.type = "ENDSITE";
|
204
|
+
node.name = "ENDSITE"; // bvh end sites have no name
|
205
|
+
}
|
206
|
+
else {
|
207
|
+
node.name = tokens[1];
|
208
|
+
node.type = tokens[0].toUpperCase();
|
209
|
+
}
|
210
|
+
// opening bracket
|
211
|
+
if (lines.shift()?.trim() != "{") {
|
212
|
+
throw new Error("Expected opening { after type & name");
|
213
|
+
}
|
214
|
+
// parse OFFSET
|
215
|
+
const tokensSplit = lines.shift()?.trim().split(/\s+/);
|
216
|
+
if (!tokensSplit) {
|
217
|
+
throw new Error("Unexpected end of file: missing OFFSET");
|
218
|
+
}
|
219
|
+
tokens = tokensSplit;
|
220
|
+
// check for OFFSET
|
221
|
+
if (tokens[0].toUpperCase() != "OFFSET") {
|
222
|
+
throw new Error("Expected OFFSET, but got: " + tokens[0]);
|
223
|
+
}
|
224
|
+
if (tokens.length != 4) {
|
225
|
+
throw new Error("OFFSET: Invalid number of values");
|
226
|
+
}
|
227
|
+
const offset = new Vector3(parseFloat(tokens[1]), parseFloat(tokens[2]), parseFloat(tokens[3]));
|
228
|
+
if (isNaN(offset.x) || isNaN(offset.y) || isNaN(offset.z)) {
|
229
|
+
throw new Error("OFFSET: Invalid values");
|
230
|
+
}
|
231
|
+
node.offset = offset;
|
232
|
+
// parse CHANNELS definitions
|
233
|
+
if (node.type != "ENDSITE") {
|
234
|
+
tokens = lines.shift()?.trim().split(/\s+/);
|
235
|
+
if (!tokens) {
|
236
|
+
throw new Error("Unexpected end of file: missing CHANNELS");
|
237
|
+
}
|
238
|
+
if (tokens[0].toUpperCase() != "CHANNELS") {
|
239
|
+
throw new Error("Expected CHANNELS definition");
|
240
|
+
}
|
241
|
+
const numChannels = parseInt(tokens[1]);
|
242
|
+
// Skip CHANNELS and the number of channels
|
243
|
+
node.channels = tokens.splice(2, numChannels);
|
244
|
+
node.children = [];
|
245
|
+
}
|
246
|
+
// read children
|
247
|
+
while (lines.length > 0) {
|
248
|
+
const line = lines.shift()?.trim();
|
249
|
+
if (line === "}") {
|
250
|
+
// Finish reading the node
|
251
|
+
return node;
|
252
|
+
}
|
253
|
+
else if (line) {
|
254
|
+
node.children.push(ReadNode(lines, line, node, context));
|
255
|
+
}
|
256
|
+
}
|
257
|
+
throw new Error("Unexpected end of file: missing closing brace");
|
258
|
+
}
|
259
|
+
/**
|
260
|
+
* Reads a BVH file, returns a skeleton
|
261
|
+
* @param text - The BVH file content
|
262
|
+
* @param scene - The scene to add the skeleton to
|
263
|
+
* @param loadingOptions - The loading options
|
264
|
+
* @returns The skeleton
|
265
|
+
*/
|
266
|
+
export function ReadBvh(text, scene, loadingOptions) {
|
267
|
+
const lines = text.split("\n");
|
268
|
+
const { loopMode } = loadingOptions;
|
269
|
+
const skeleton = new Skeleton("", "", scene);
|
270
|
+
const context = new LoaderContext(skeleton);
|
271
|
+
context.loopMode = loopMode;
|
272
|
+
// read model structure
|
273
|
+
const firstLine = lines.shift();
|
274
|
+
if (!firstLine || firstLine.trim().toUpperCase() !== _HierarchyNode) {
|
275
|
+
throw new Error("HIERARCHY expected");
|
276
|
+
}
|
277
|
+
const nodeLine = lines.shift();
|
278
|
+
if (!nodeLine) {
|
279
|
+
throw new Error("Unexpected end of file after HIERARCHY");
|
280
|
+
}
|
281
|
+
const root = ReadNode(lines, nodeLine.trim(), null, context);
|
282
|
+
// read motion data
|
283
|
+
const motionLine = lines.shift();
|
284
|
+
if (!motionLine || motionLine.trim().toUpperCase() !== _MotionNode) {
|
285
|
+
throw new Error("MOTION expected");
|
286
|
+
}
|
287
|
+
const framesLine = lines.shift();
|
288
|
+
if (!framesLine) {
|
289
|
+
throw new Error("Unexpected end of file before frame count");
|
290
|
+
}
|
291
|
+
const framesTokens = framesLine.trim().split(/[\s]+/);
|
292
|
+
if (framesTokens.length < 2) {
|
293
|
+
throw new Error("Invalid frame count line");
|
294
|
+
}
|
295
|
+
// number of frames
|
296
|
+
const numFrames = parseInt(framesTokens[1]);
|
297
|
+
if (isNaN(numFrames)) {
|
298
|
+
throw new Error("Failed to read number of frames.");
|
299
|
+
}
|
300
|
+
context.numFrames = numFrames;
|
301
|
+
// frame time
|
302
|
+
const frameTimeLine = lines.shift();
|
303
|
+
if (!frameTimeLine) {
|
304
|
+
throw new Error("Unexpected end of file before frame time");
|
305
|
+
}
|
306
|
+
const frameTimeTokens = frameTimeLine.trim().split(/[\s]+/);
|
307
|
+
if (frameTimeTokens.length < 3) {
|
308
|
+
throw new Error("Invalid frame time line");
|
309
|
+
}
|
310
|
+
const frameTime = parseFloat(frameTimeTokens[2]);
|
311
|
+
if (isNaN(frameTime)) {
|
312
|
+
throw new Error("Failed to read frame time.");
|
313
|
+
}
|
314
|
+
context.frameRate = frameTime;
|
315
|
+
// read frame data line by line
|
316
|
+
for (let i = 0; i < numFrames; ++i) {
|
317
|
+
const frameLine = lines.shift();
|
318
|
+
if (!frameLine) {
|
319
|
+
continue;
|
320
|
+
}
|
321
|
+
const tokens = frameLine.trim().split(/[\s]+/);
|
322
|
+
ReadFrameData(tokens, i * frameTime, root);
|
323
|
+
}
|
324
|
+
context.root = root;
|
325
|
+
ConvertNode(context.root, null, context);
|
326
|
+
context.skeleton.returnToRest();
|
327
|
+
return context.skeleton;
|
328
|
+
}
|
329
|
+
//# sourceMappingURL=bvhLoader.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"bvhLoader.js","sourceRoot":"","sources":["../../../../dev/loaders/src/BVH/bvhLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,gDAAkC;AACtD,OAAO,EAAE,IAAI,EAAE,sCAAwB;AACvC,OAAO,EAAE,QAAQ,EAAE,0CAA4B;AAC/C,OAAO,EAAE,IAAI,EAAE,2CAA6B;AAC5C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,6CAA+B;AAIrE,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAExC,MAAM,UAAU,GAAG,WAAW,CAAC;AAC/B,MAAM,UAAU,GAAG,WAAW,CAAC;AAC/B,MAAM,UAAU,GAAG,WAAW,CAAC;AAC/B,MAAM,UAAU,GAAG,WAAW,CAAC;AAC/B,MAAM,UAAU,GAAG,WAAW,CAAC;AAC/B,MAAM,UAAU,GAAG,WAAW,CAAC;AAE/B,MAAM,cAAc,GAAG,WAAW,CAAC;AACnC,MAAM,WAAW,GAAG,QAAQ,CAAC;AAE7B,MAAM,aAAa;IAQf,YAAY,QAAkB;QAP9B,aAAQ,GAAW,SA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AAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC;IACD,MAAM,SAAS,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IACjD,IAAI,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAE9B,+BAA+B;IAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC;QACjC,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;QAChC,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,SAAS;QACb,CAAC;QACD,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC/C,aAAa,CAAC,MAAM,EAAE,CAAC,GAAG,SAAS,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAEpB,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAEzC,OAAO,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;IAChC,OAAO,OAAO,CAAC,QAAQ,CAAC;AAC5B,CAAC","sourcesContent":["import type { IAnimationKey } from \"core/Animations\";\nimport { Animation } from \"core/Animations/animation\";\nimport { Bone } from \"core/Bones/bone\";\nimport { Skeleton } from \"core/Bones/skeleton\";\nimport { Axis } from \"core/Maths/math.axis\";\nimport { Matrix, Quaternion, Vector3 } from \"core/Maths/math.vector\";\nimport type { Scene } from \"core/scene\";\nimport type { Nullable } from \"core/types\";\nimport type { BVHLoadingOptions } from \"./bvhLoadingOptions\";\nimport { Tools } from \"core/Misc/tools\";\n\nconst _XPosition = \"Xposition\";\nconst _YPosition = \"Yposition\";\nconst _ZPosition = \"Zposition\";\nconst _XRotation = \"Xrotation\";\nconst _YRotation = \"Yrotation\";\nconst _ZRotation = \"Zrotation\";\n\nconst _HierarchyNode = \"HIERARCHY\";\nconst _MotionNode = \"MOTION\";\n\nclass LoaderContext {\n loopMode: number = Animation.ANIMATIONLOOPMODE_CYCLE;\n list: IBVHNode[] = [];\n root: IBVHNode = CreateBVHNode();\n numFrames: number = 0;\n frameRate: number = 0;\n skeleton: Skeleton;\n\n constructor(skeleton: Skeleton) {\n this.skeleton = skeleton;\n }\n}\n\ninterface IBVHNode {\n name: string;\n type: string;\n offset: Vector3;\n channels: string[];\n children: IBVHNode[];\n frames: IBVHKeyFrame[];\n parent: Nullable<IBVHNode>;\n}\n\ninterface IBVHKeyFrame {\n time: number;\n position: Vector3;\n rotation: Quaternion;\n}\n\nfunction CreateBVHNode(): IBVHNode {\n return {\n name: \"\",\n type: \"\",\n offset: new Vector3(),\n channels: [],\n children: [],\n frames: [],\n parent: null,\n };\n}\n\nfunction CreateBVHKeyFrame(): IBVHKeyFrame {\n return {\n time: 0,\n position: new Vector3(),\n rotation: new Quaternion(),\n };\n}\n\n/**\n * Converts the BVH node's offset to a Babylon matrix\n * @param node - The BVH node to convert\n * @returns The converted matrix\n */\nfunction BoneOffset(node: IBVHNode): Matrix {\n const x = node.offset.x;\n const y = node.offset.y;\n // Flip Z axis to convert handedness.\n const z = -node.offset.z;\n return Matrix.Translation(x, y, z);\n}\n\n/**\n * Creates animations for the BVH node\n * @param node - The BVH node to create animations for\n * @param context - The loader context\n * @returns The created animations\n */\nfunction CreateAnimations(node: IBVHNode, context: LoaderContext): Animation | null {\n if (node.frames.length === 0) {\n return null;\n }\n\n const keyFrames: IAnimationKey[] = [];\n\n // Create position animation if there are position channels\n const hasPosition = node.channels.some((c) => c === _XPosition || c === _YPosition || c === _ZPosition);\n\n // Create rotation animation if there are rotation channels\n const hasRotation = node.channels.some((c) => c === _XRotation || c === _YRotation || c === _ZRotation);\n\n for (let i = 0; i < node.frames.length; i++) {\n const frame = node.frames[i];\n const time = i * context.frameRate * 1000; // Convert to milliseconds\n\n if (hasPosition || hasRotation) {\n let matrix = Matrix.Identity();\n\n if (hasRotation) {\n const rotationMatrix = new Matrix();\n frame.rotation.toRotationMatrix(rotationMatrix);\n matrix = rotationMatrix;\n }\n\n if (hasPosition) {\n const position = frame.position;\n matrix.setTranslation(new Vector3(position.x, position.y, position.z));\n }\n\n keyFrames.push({\n frame: time,\n value: matrix,\n });\n }\n }\n\n if (keyFrames.length === 0) {\n return null;\n }\n\n const fps = 60 / context.frameRate;\n const animation = new Animation(node.name + \"_anim\", \"_matrix\", fps, Animation.ANIMATIONTYPE_MATRIX, context.loopMode);\n animation.setKeys(keyFrames);\n\n return animation;\n}\n\n/**\n * Converts a BVH node to a Babylon bone\n * @param node - The BVH node to convert\n * @param parent - The parent bone\n * @param context - The loader context\n */\nfunction ConvertNode(node: IBVHNode, parent: Nullable<Bone>, context: LoaderContext) {\n const matrix = BoneOffset(node);\n const bone = new Bone(node.name, context.skeleton, parent, matrix);\n\n // Create animation for this bone\n const animation = CreateAnimations(node, context);\n if (animation) {\n // Apply rotation correction to the root bone's animation keys\n if (!parent) {\n // Check if it's the root node\n const correctionMatrix = Matrix.RotationAxis(Axis.X, Math.PI / 2); // -90 degrees on X-axis\n const correctedKeys = animation.getKeys().map((key: IAnimationKey) => {\n const originalMatrix = key.value as Matrix;\n // Apply correction: We want to rotate the final orientation, so post-multiply\n const correctedMatrix = originalMatrix.multiply(correctionMatrix);\n return { frame: key.frame, value: correctedMatrix };\n });\n animation.setKeys(correctedKeys);\n }\n bone.animations.push(animation);\n }\n\n for (const child of node.children) {\n ConvertNode(child, bone, context);\n }\n}\n\n/**\n * Recursively reads data from a single frame into the bone hierarchy.\n * The bone hierarchy has to be structured in the same order as the BVH file.\n * keyframe data is stored in bone.frames.\n * @param data - splitted string array (frame values), values are shift()ed\n * @param frameTime - playback time for this keyframe\n * @param bone - the bone to read frame data from\n */\nfunction ReadFrameData(data: string[], frameTime: number, bone: IBVHNode) {\n if (bone.type === \"ENDSITE\") {\n // end sites have no motion data\n return;\n }\n\n // add keyframe\n const keyframe = CreateBVHKeyFrame();\n keyframe.time = frameTime;\n keyframe.position = new Vector3();\n keyframe.rotation = new Quaternion();\n\n bone.frames.push(keyframe);\n\n let pitch = 0,\n yaw = 0,\n roll = 0;\n\n // parse values for each channel in node\n for (let i = 0; i < bone.channels.length; ++i) {\n const value = data.shift();\n if (!value) {\n continue;\n }\n\n switch (bone.channels[i]) {\n case _XPosition:\n keyframe.position.x = parseFloat(value.trim());\n break;\n case _YPosition:\n keyframe.position.y = parseFloat(value.trim());\n break;\n case _ZPosition:\n keyframe.position.z = -parseFloat(value.trim()); // Flip Z axis to convert handedness.\n break;\n case _XRotation:\n pitch = Tools.ToRadians(+value);\n break;\n case _YRotation:\n yaw = Tools.ToRadians(+value);\n break;\n case _ZRotation:\n roll = Tools.ToRadians(+value);\n break;\n default:\n throw new Error(\"invalid channel type\");\n }\n }\n\n if (yaw !== 0 || pitch !== 0 || roll !== 0) {\n // Create rotation matrix in proper order\n const rotationMatrix = Matrix.Identity();\n Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, rotationMatrix);\n keyframe.rotation.fromRotationMatrix(rotationMatrix);\n }\n\n // parse child nodes\n for (let i = 0; i < bone.children.length; ++i) {\n ReadFrameData(data, frameTime, bone.children[i]);\n }\n}\n\n/**\n * Recursively parses the HIERARCHY section of the BVH file\n * @param lines - all lines of the file. lines are consumed as we go along\n * @param firstLine - line containing the node type and name e.g. \"JOINT hip\"\n * @param parent - the parent node for hierarchy\n * @param context - the loader context containing the list of nodes and other data\n * @returns a BVH node including children\n */\nfunction ReadNode(lines: string[], firstLine: string, parent: Nullable<IBVHNode>, context: LoaderContext): IBVHNode {\n const node = CreateBVHNode();\n node.parent = parent;\n context.list.push(node);\n\n // parse node type and name.\n let tokens: string[] | undefined = firstLine.trim().split(/\\s+/);\n\n if (tokens[0].toUpperCase() === \"END\" && tokens[1].toUpperCase() === \"SITE\") {\n node.type = \"ENDSITE\";\n node.name = \"ENDSITE\"; // bvh end sites have no name\n } else {\n node.name = tokens[1];\n node.type = tokens[0].toUpperCase();\n }\n\n // opening bracket\n if (lines.shift()?.trim() != \"{\") {\n throw new Error(\"Expected opening { after type & name\");\n }\n\n // parse OFFSET\n const tokensSplit = lines.shift()?.trim().split(/\\s+/);\n if (!tokensSplit) {\n throw new Error(\"Unexpected end of file: missing OFFSET\");\n }\n tokens = tokensSplit;\n // check for OFFSET\n\n if (tokens[0].toUpperCase() != \"OFFSET\") {\n throw new Error(\"Expected OFFSET, but got: \" + tokens[0]);\n }\n if (tokens.length != 4) {\n throw new Error(\"OFFSET: Invalid number of values\");\n }\n\n const offset = new Vector3(parseFloat(tokens[1]), parseFloat(tokens[2]), parseFloat(tokens[3]));\n\n if (isNaN(offset.x) || isNaN(offset.y) || isNaN(offset.z)) {\n throw new Error(\"OFFSET: Invalid values\");\n }\n\n node.offset = offset;\n\n // parse CHANNELS definitions\n if (node.type != \"ENDSITE\") {\n tokens = lines.shift()?.trim().split(/\\s+/);\n if (!tokens) {\n throw new Error(\"Unexpected end of file: missing CHANNELS\");\n }\n\n if (tokens[0].toUpperCase() != \"CHANNELS\") {\n throw new Error(\"Expected CHANNELS definition\");\n }\n\n const numChannels = parseInt(tokens[1]);\n // Skip CHANNELS and the number of channels\n node.channels = tokens.splice(2, numChannels);\n node.children = [];\n }\n\n // read children\n while (lines.length > 0) {\n const line = lines.shift()?.trim();\n\n if (line === \"}\") {\n // Finish reading the node\n return node;\n } else if (line) {\n node.children.push(ReadNode(lines, line, node, context));\n }\n }\n\n throw new Error(\"Unexpected end of file: missing closing brace\");\n}\n\n/**\n * Reads a BVH file, returns a skeleton\n * @param text - The BVH file content\n * @param scene - The scene to add the skeleton to\n * @param loadingOptions - The loading options\n * @returns The skeleton\n */\nexport function ReadBvh(text: string, scene: Scene, loadingOptions: BVHLoadingOptions): Skeleton {\n const lines = text.split(\"\\n\");\n\n const { loopMode } = loadingOptions;\n\n const skeleton = new Skeleton(\"\", \"\", scene);\n\n const context = new LoaderContext(skeleton);\n context.loopMode = loopMode;\n\n // read model structure\n const firstLine = lines.shift();\n if (!firstLine || firstLine.trim().toUpperCase() !== _HierarchyNode) {\n throw new Error(\"HIERARCHY expected\");\n }\n\n const nodeLine = lines.shift();\n if (!nodeLine) {\n throw new Error(\"Unexpected end of file after HIERARCHY\");\n }\n const root = ReadNode(lines, nodeLine.trim(), null, context);\n\n // read motion data\n const motionLine = lines.shift();\n if (!motionLine || motionLine.trim().toUpperCase() !== _MotionNode) {\n throw new Error(\"MOTION expected\");\n }\n\n const framesLine = lines.shift();\n if (!framesLine) {\n throw new Error(\"Unexpected end of file before frame count\");\n }\n const framesTokens = framesLine.trim().split(/[\\s]+/);\n if (framesTokens.length < 2) {\n throw new Error(\"Invalid frame count line\");\n }\n\n // number of frames\n const numFrames = parseInt(framesTokens[1]);\n if (isNaN(numFrames)) {\n throw new Error(\"Failed to read number of frames.\");\n }\n context.numFrames = numFrames;\n\n // frame time\n const frameTimeLine = lines.shift();\n if (!frameTimeLine) {\n throw new Error(\"Unexpected end of file before frame time\");\n }\n const frameTimeTokens = frameTimeLine.trim().split(/[\\s]+/);\n if (frameTimeTokens.length < 3) {\n throw new Error(\"Invalid frame time line\");\n }\n const frameTime = parseFloat(frameTimeTokens[2]);\n if (isNaN(frameTime)) {\n throw new Error(\"Failed to read frame time.\");\n }\n\n context.frameRate = frameTime;\n\n // read frame data line by line\n for (let i = 0; i < numFrames; ++i) {\n const frameLine = lines.shift();\n if (!frameLine) {\n continue;\n }\n const tokens = frameLine.trim().split(/[\\s]+/);\n ReadFrameData(tokens, i * frameTime, root);\n }\n\n context.root = root;\n\n ConvertNode(context.root, null, context);\n\n context.skeleton.returnToRest();\n return context.skeleton;\n}\n"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"bvhLoadingOptions.js","sourceRoot":"","sources":["../../../../dev/loaders/src/BVH/bvhLoadingOptions.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Options for loading BVH files\n */\nexport type BVHLoadingOptions = {\n /**\n * Defines the loop mode of the animation to load.\n */\n loopMode: number;\n};\n"]}
|
package/BVH/index.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./bvhLoader.js";
|
package/BVH/index.js
ADDED
package/BVH/index.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/loaders/src/BVH/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,aAAa,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\nexport * from \"./bvhLoader\";\n"]}
|