Does disposing a skeleton also dispose it's bones

Hi,
I am trying to figure out if disposing a skeleton will also dispose it’s child bones.
The reason for this is that I have a number of transforms attached as children to the skeleton’s bones and am trying to work out what should happen to them when the skeleton is disposed.

Note that the skeletons I am using are not Gltf skeletons, but rather the standard babylon skeleton.

According to this post calling skeleton.dispose() should call each bone.dispose() method.

However, after adding a log function for each bone of the skeleton using it’s onDisposeObservable, this is not what I’m seeing.
Can someone please give clarity on if each bone is is expected to be disposed when a skeleton is disposed?

I do not think it is the case as bones do not hold into any native memory I am pretty sure we do not call dispose on them.

Why are you trying to rely on this function ?

2 Likes

Thanks for the confirmation.
If I have an object attached to a bone of a skeleton, I need to know if the bone is removed so I can handle that scenario. I was using the bone.onDisposeObservable to attempt to do this, but it was never called.
I got around it by manually calling each bone.dispose() when scene.onSkeletonRemovedObservable is triggered, so my original observer now works.

I just wanted to ensure I wasn’t doing anything stupid, especially as the post I linked to said:

calling skeleton.dispose() will dispose the bones

Thanks again :smiley:

1 Like