Hey guys,
Could you please explain what is happening here? For me it looks like 100% bug
why freeze on second mesh material breaks animation of first?
uncomment 26 comment 31 → why freeze on first mesh material breaks animation of first AND second animation?
notice that mesh uses shape animations
for me it looks like freeze shouldn’t break animations at all
Thanks!
Both copies share the same material by default, so freezing the material on either copy freezes it for both.
Freezing lets Babylon skip some updates, including the shape-animation weights for meshes sharing that material. That can make one copy use the other copy’s weights. This is a known limitation of frozen materials.
The simplest solution is to leave the material unfrozen for these animated meshes. You can also give each copy its own material by passing true as the second argument to both instantiateModelsToScene() calls.
TL;dr - the documented behavior, not a bug.
https://playground.babylonjs.com/#J4ICEW#2 i tried to copy materials - the same issue
sorry in #2 looks like different issue. mesh2 here is created in state of 1 mesh
https://playground.babylonjs.com/#J4ICEW#3 here is both meshes is blocked but only first material is freezed. why second is freezed then?
why then #1 https://playground.babylonjs.com/#J4ICEW#1 second animation works? freeze should break both animations
Sorry for a late reply. You’re right - my earlier explanation was incomplete. Cloning the materials removes the sharing problem, but there is another limitation here.
You freeze the material before the shape animation starts, while all shape weights are zero. Babylon can prepare a shader without shape-animation support. Once frozen, it skips rebuilding that shader when the shapes become active.
Also, freezing a shared material does not mean both animations will stop. Some updates still happen when the material is bound, so the result depends on which mesh is rendered and when you freeze it.
The simplest solution is to leave these materials unfrozen. For this model, you can also use separate materials and set each mesh’s morphTargetManager.numMaxInfluencers to its numTargets before freezing.
One more detail: in the current Playground, rootNodes[0] has no material, so calling .material.freeze() there throws. You need to access the material on the child mesh instead. After correcting that in version #3, the unfrozen second copy works.