Dispose() function on InstantiatedEntries?

Hey team,
Can we have a dispose function on BABYLON.InstantiatedEntries included in core?

When using AssetContainer.instantiateModelsToScene() to clone a set of character assets, animations, etc, i couldn’t find a built-in function for disposing just 1 specific instance of the container

BABYLON.InstantiatedEntries.prototype.dispose = function(){



All of those elements will be disposed individually when the scene disposes, as they are registered with the scene. There is no problem adding a “disposeEntries()” function (exactly the function you have provided), but when should it be called? Or is it just for you to be able to dispose them? in that case a help function on this class would be more than enough

Yeah, so basicly i instantiate models from an asset container multiple times to clone it correctly with animationGroups retargeted and everything.

Now i want to remove a specific model, say the " b " instance of the container from the PG scene.
Disposing the rootNode wont dispose skeletons or animationGroups, so a overall dispose function would be super helpful.

the dispose functions are called automatically, so I will prefer not to name it “dispose” , but “removeFromScene” or even “disposeFromScene” makes sense to me. Want to offer a PR?

Sure thing :slight_smile:

Tried here: Update assetContainer.ts by aWeirdo · Pull Request #13451 · BabylonJS/Babylon.js · GitHub

But it says formatting/linting fail,
i don’t really use typescript & copy/pasted from the assetContainer dispose function, so i’m not sure what it wants from me :smiley:

Finishing: Formatting
[warn] packages/dev/core/src/assetContainer.ts
[warn] Code style issues found in the above file. Forgot to run Prettier?
##[warning]Couldn’t find a debug log in the cache or working directory
##[error]Error: Npm failed with return code: 1

you should run the formatter :slight_smile:

npm run format:fix