I’m encountering an issue with BABYLON.SpriteManager
when dynamically recreating sprites and their managers upon user interaction. Specifically, when I click on a mesh twice in a row, the sprite does not appear as expected.
Expected Behavior
- Each time the mesh is clicked, the existing sprite and
SpriteManager
should be disposed of, and a new sprite with a newSpriteManager
should appear.
Actual Behavior
- After the first click, the sprite appears as expected.
- On subsequent clicks, the sprite does not appear, even though the code for creating a new
SpriteManager
and sprite executes without errors.
Observations
- The issue seems to occur only when the sprite and
SpriteManager
are recreated on consecutive clicks. - The console log (
scene.spriteManagers[0].sprites[0]
) correctly shows the new sprite on subsequent clicks, but the sprite does not appear in the scene.
Are there any best practices or workarounds for dynamically recreating sprites and SpriteManager
instances?
Thanks in advance for your help!