That one seems to work, so that’s a typo because the method search for “skeleton” whereas the glb has “skeletons” set.
Defining skeleton will enable the method to proceed.
if (!this._mesh.skeleton) {
if (!this._mesh.skeletons) {
throw new Error("No skeleton in this mesh.");
}
else{
throw new Error("Please select one of the skeletons of your mesh, and assign it to the skeleton key");
}
}
It is possible to add a control for length 1 and assign it directly but…
if (!this._mesh.skeleton) {
if (!this._mesh.skeletons) {
throw new Error("No skeleton in this mesh.");
}
else{
if (this._mesh.skeletons.length == 1){
this._mesh.skeleton = this._mesh.skeletons[0];
}
else{
throw new Error("Please select one of the skeletons of your mesh, and assign it to the skeleton key");
}
}
}
I may have missed something in the proper process though…
Note that importResult is not a mesh, loaded meshes are in importResult.meshes instead (note that it is an array as multiple meshes may have been loaded).
Is it expected to have the exact same CPU usage between baked and non baked animation?
I was hoping to see it decrease, but not at all:
let importResult = await SceneLoader.ImportMeshAsync("", "/", my_obj, scene, undefined);
for (let x = 0; x < importResult.meshes.length; ++ x ) {
const mesh = importResult.meshes[x];
if (! mesh.skeleton) {
continue;
}
let response = await fetch("/BV_" + (x) + ".json");
if (! response.ok) {
throw new Error("HTTP error " + response.status);
}
const json = await response.json()
const baker = new VertexAnimationBaker(scene, mesh);
// vertex related
const vertexData = json["vertexData"]
const vertexTexture = baker.textureFromBakedVertexData(vertexData);
//Bake management
const manager = new BakedVertexAnimationManager(scene);
// store the texture
manager.texture = vertexTexture;
// set the animation parameters.
manager.setAnimationParameters(
1, // first frame
10, // last frame
0, // offset
30 // frames per second
);
// associate the manager with the mesh
mesh.bakedVertexAnimationManager = manager;
// update the time to play the animation
globalThis.scene.registerBeforeRender(() => {
manager.time += engine.getDeltaTime() / 1000.0;
});
}
};
With or without the part after ImportMeshAsync, the animation runs the same.
CPU usage is the same.
Then for my needs, I will keep using instances / thin instances and consider it done. The maximum is about 20-30 animated characters / objects simultaneously on screen.