# A class to keep track of loaded assets

**URL:** <https://forum.babylonjs.com/t/a-class-to-keep-track-of-loaded-assets/45135>\
**Category:** Questions\
**Tags:** loaders\
**Created:** [October 23, 2023, 11:41pm UTC](https://forum.babylonjs.com/t/a-class-to-keep-track-of-loaded-assets/45135 "2023-10-23T23:41:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavidP](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/davidp/32/45669_2.png) [@DavidP](https://forum.babylonjs.com/u/DavidP)\
**Post date:** [October 23, 2023, 11:41pm UTC](https://forum.babylonjs.com/t/a-class-to-keep-track-of-loaded-assets/45135/1 "2023-10-23T23:41:40Z")

</div>

Hello,  
I am looking for a simple way to keep track of loaded assets (their names). To this end, I introduced cLoader manager class that records asset names on successful load -  
cLoader has loadedMeshNames array data member and, on successful load, the new mesh name is appended to this array.  
Thus if I want to keep track of a particular mesh, for example, I can load the mesh through this class. Here is my playground

> **[Babylon.js Playground](https://playground.babylonjs.com/#00BDB0%232)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

Unfortunately, that does not work because I am getting an error in the callback for onSuccess load.  
In console, you can see following error  
_logger.ts:103 BJS - [16:17:25]: Unable to load from [https://assets.babylonjs.com/meshes/Yeti/MayaExport/glTF/Yeti.gltf:](https://assets.babylonjs.com/meshes/Yeti/MayaExport/glTF/Yeti.gltf:) Error in onSuccess callback: TypeError: Cannot read properties of undefined (reading ‘loadedMeshNames’)_

For some reason, I cannot access the data member in my class’ method.  
Any suggestion, what would be the optimum way for me to keep track of loaded assets, so I can destroy, hide, unhide them as needed?  
Thank you

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [October 24, 2023, 1:30am UTC](https://forum.babylonjs.com/t/a-class-to-keep-track-of-loaded-assets/45135/2 "2023-10-24T01:30:48Z")

</div>

> [@DavidP](#):
>
> I am getting an error in the callback for onSuccess load.

This is because you don’t pass a variable to the callback function.  
Here it works (see console) - [https://playground.babylonjs.com/#00BDB0#5](https://playground.babylonjs.com/#00BDB0#5)  
Please note that in this configuration there will be only the first meshes from each model in your `loadedMeshNames` array, and all of them will have identical names `' __root__'`.  
To avoid this use either mesh IDs, or save all meshes names in your array (Yeti model has 7 meshes).

---

<div class="post-metadata">

**Author:** ![DavidP](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/davidp/32/45669_2.png) [@DavidP](https://forum.babylonjs.com/u/DavidP)\
**Post date:** [October 24, 2023, 2:22am UTC](https://forum.babylonjs.com/t/a-class-to-keep-track-of-loaded-assets/45135/3 "2023-10-24T02:22:44Z")

</div>

@labris Thank you for both solving the problem and pointing out a potential issue with mesh name!
