The vertexData.json tells the width is 264.
I don’t understand why my baked texture only has a width of 264, when my mesh has 15k vertices.
it has a height of 32, which is correct because the anim has a length of 32 frames.
I reused the code in the example.
let baker = null,
mesh = null;
const ranges = [{ from: 0, to: 32, name: "My animation" }];
SceneLoader.ImportMeshAsync("", "/path/", "untitled.glb", scene, undefined)
.then((importResult) => {
mesh = importResult.meshes[1]; //<- offset 1 because 0 has no skeleton
// create the baker helper, so we can generate the texture
baker = new VertexAnimationBaker(scene, mesh);
// you can slice the animation here with several animation ranges.
return baker.bakeVertexData(ranges);
})
.then((vertexData) => {
// we got the vertex data. let's serialize it:
const vertexDataJSON = baker.serializeBakedVertexDataToJSON(vertexData);
// and save it to a local JSON file
let a = document.createElement("a");
a.setAttribute("href", "data:text/plain;charset=utf-8," + encodeURIComponent(vertexDataJSON));
a.setAttribute("download", "vertexData.json");
a.click();
});
So, I thought I should have a texture width of about 15k.
total size of the texture 15k * 3 (<=>3 points in vertex) * sizeof(float) * 32 lines
Hmm
Reading this post it is not per vertex but a matrix per bone.
Quick question before I deal with it tomorrow: is each matrix local to the bone? So the value has to be considered relative to the root of the mesh and then, one can apply the translation as needed?
3x3 or 4x4 matrices?
The base of those matrices is the gltf’s bind pose of each bone?
Yes, it is the final transformation of the local bone matrix, as bone.getLocalMatrix().multiplyToRef(parentBone.getFinalMatrix(), bone.getFinalMatrix()); shows.
Note that because it is skinning, we also remove the bind pose by multiplying by the inverse bind matrix (bone.getAbsoluteInverseBindMatrix().multiplyToArray(bone.getFinalMatrix(), targetMatrix, mappedIndex * 16);).