Hey there i’m quite new to babylonjs so maybe thats a simple thing tho.
I’m loading a gltf file from our customer into babylon. This file comes with an animation group that we’re animating.
The application we’re building lets the user change materials. Those materials are loaded as JSON file from s3.
The moment i apply a material to an mesh which was covered by the animationgroup before, the mesh does not animate anymore.
After my research it seems that since the material comes with blocks those blocks are not covered by the animation group.
Now my question is how can i make the old animations to work on the mesh with the new material applied on.
Unfortunatly it would be hard to create a playground. If that would be needed i will ask my customer for the permission to share.
Thats the process to apply the net material
/**
* This function loads the **new Material and adds it to the given mesh**
*/
export async function replaceMaterial(
material: Material,
mesh: AbstractMesh,
scene: Scene,
) {
const createUrlCreator = (base_path: string) => (path: string) =>
`${BASE_RENDER_PATH}/materials${base_path}/${path}`
const urlCreator = createUrlCreator(material.path)
const newMaterial = await NodeMaterial.ParseFromFileAsync(
material.jsonFile,
urlCreator(material.jsonFile),
scene,
)
if (!mesh.metadata?.oldMaterial) {
mesh.metadata = { ...mesh.metadata, oldMaterial: mesh.material }
}
mesh.material = newMaterial
}