SpriteManager multiple dispose on same SpriteManager

Hello,
I’m found a little bug.
When i dispose several times the same SpriteManager, for the second and following dispose an other SpriteManager is disposed.

It comes from the SpriteManger.ts line 761, indexOf return “-1” and splice(-1,1) delete the last element in array.

I sink that we should check if indexOf not return “-1” and why not create method “isDisposed” for users know this spriteManager is already dispose

I can do PR if you want !

Playground when the bug is present: https://playground.babylonjs.com/#SVILZC#1 (Open inspector for see all SpriteManagers)

Victor

I guess a PR is ok, even if I don’t think the dispose methods on other types of objects in Babylon are all foolproof if called multiple times: it seems to me to be a bug from the user standpoint to call dispose multiple times on the same object.

Yes, I agree, the user must not destroy several times same SpriteManger (or another instance), but we (BABYLON) must not destroy another instance.

In PR, i does a method isDisposed ?

No, you can simply check that the index is not -1 before removing the entry from this._scene.spriteManagers.