Hi,
I finally got the chance to look into a bug I have seen since upgrading from babylonjs 5 beta 4 to the latest rc versions.
It seems that meshes with a skeleton that has needInitialSkinMatrix = true crash when cloned.
This seems to happen now because the Mesh constructor assigns the cloned mesh’s skeleton to the new clone by default and it didn’t do this previously (I’d actually like this to be optional, but that’s a separate matter).
This means that AbstractMesh.getPositionData is now called whereas it was not previously.
The line var skeletonMatrices = this.skeleton.getTransformMatrices(this); returns undefined as skeleton.prepare() does not calculate skeleton._transformMatrices if skeleton.needInitialSkinMatrix = true.
So AbstractMesh.getPositionData crashes when Matrix.FromFloat32ArrayToRefScaled is called as the passed in skeletonMatrices is undefined.
Hope this makes sense… its very late here.
Playground example of the crash (please open the debugger)
Hi @bghgary,
The mesh in question was exported from maya as a .Babylon file and when it is imported needInitialSkinMatrix is set to true.
Until I hit this bug, I didn’t even know the variable existed.
I was able to work around the bug by setting it to false as soon as the mesh is loaded but I wanted to flag the bug regardless as other people may hit it and not realise what’s happening.
Thanks for working on the fix