Cloning entity with render component and mesh with skin does not clone the skin instance
- it seems in some cases the skin instance never gets cloned and the skinning no longer works
- looking at the code, it seems:
- when rootBone is set, it clones skin instance
- if not set, skin instance should be cloned when the cloned entity is added to the scene / enabled in it.
But it seems in some cases this might not take place.
This may be related to a bug that we just wanted to report. We are creating our own meshes and destroying them a lot and we noticed that the SkinInstanceCache is not freeing the skin instances that were created by it. We looked at the _cloneSkinInstances of the renderComponent and saw that the condition of the if seems to be wrong. The Mesh class doesn't have a property skinInstance, but the condition is looking for one. We think this is a typo and was meant to be !meshInstance.skinInstance.
https://github.com/playcanvas/engine/blob/4500ad0d68c9d867cd756861917574e0533489f9/src/framework/components/render/component.js#L816-L830
If this is not related or doesn't help with this issue, I will open a separate issue and try to add some reproduction steps.
I think you're right on the typo there, and some repro would be awesome, that's always the hardest part.
@MoserAlex - thanks for the investigation, I created a fix you suggested - as that was an obvious typo there. I could not verified if this fixes the original issue as well, so I'll leave the issue opened for now.
Closing, till I can find a repro, or at least a confirmation.