Cloning mesh with skeleton that has `needInitialSkinMatrix` true after some delay fails


I face an issue when cloning a mesh in the following case:

  1. source mesh has a skeleton
  2. source mesh skeleton has needInitialSkinMatrix set to true
  3. cloning happens with some delay (I mimicked it with a setTimeout).

Cloning then fails with a “Cannot read properties of null” error which happens because the root matrix isn’t properly retrieved, because the skeleton’s _currentRenderId equals currentRenderId of the scene.

Here’s a Playground (note that the skeleton has "needInitialSkinMatrix": true and that cloning happens within a setTimeout)

There was a similar issue resolved some time ago: Meshes with skeletons that have needInitialSkinMatrix=true crash when cloned. But example from that topic also fails, if setTimeout is added: PG.

Thank you.

P.S. Setting needInitialSkinMatrix to false helps solve this particular error, but I don’t know for sure that it doesn’t cause other issues yet.

This PG will fix the problem:

1 Like

Thank you very much!