Only last instance of AxesViewer can be disposed

if there are multiple instances of axes viewer, last instance can be removed, but any previous instances will remain visible in the scene no matter what

for example:

const av1 = new AxesViewer(scene, scale);
const av2 = new AxesViewer(scene, scale);
av1.dispose();
av2.dispose();

will remove av2 correctly, but av1 will still be visible in the scene
(although av1.scene gets set to null);

version: babylonjs 5.0.0.beta4

cc @Cedric

Let me take a look.

I can’t repro with latest bgjs @vladmandic

axisViewer | Babylon.js Playground (babylonjs.com)

1 Like

I also cannot reproduce using Playground, but definitely reproducible in my code - will narrow it down more and update the thread.

1 Like

my bad, i had same method invoked twice, so ended up creating two instances of AxesViewer under same variable - of course, only last created instance can be disposed while previously created instance just became a “ghost” that cannot be disposed as it cannot be referenced.

1 Like