# GLTFLoader + DefaultLoadingManager

**URL:** <https://discourse.threejs.org/t/gltfloader-defaultloadingmanager/3062>\
**Category:** Questions\
**Tags:** gltf-loader\
**Created:** [June 8, 2018, 9:48am UTC](https://discourse.threejs.org/t/gltfloader-defaultloadingmanager/3062 "2018-06-08T09:48:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stmaccarelli](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/stmaccarelli/32/3181_2.png) [@stmaccarelli](https://discourse.threejs.org/u/stmaccarelli)\
**Post date:** [June 8, 2018, 9:48am UTC](https://discourse.threejs.org/t/gltfloader-defaultloadingmanager/3062/1 "2018-06-08T09:48:12Z")

</div>

Hello,  
I can’t get how GLTFLoader relates to DefaultLoadingManager

It looks like DefaultLoadingManager fires the onLoad callback before GLTFLoader finished parsing the scene.  
Is it a correct behaviour?

I need the loading manager to fire a custom event when everything is loaded, so my other scripts / functions can use the loaded resources. It used to work ok with OBJloader and PLYLoader, even on large models.

Thanks for te help

---

<div class="post-metadata">

**Author:** ![donmccurdy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/donmccurdy/32/33209_2.png) [@donmccurdy](https://discourse.threejs.org/u/donmccurdy)\
**Post date:** [June 8, 2018, 2:00pm UTC](https://discourse.threejs.org/t/gltfloader-defaultloadingmanager/3062/2 "2018-06-08T14:00:01Z")

</div>

This looks like a bug, either in GLTFLoader or LoadingManager. I’m not sure LoadingManager is set up to properly handle multi-file models, or models that require asynchronous parsing, and glTF needs both. OBJ and PLY were probably fine because they’re just a single file.

The (internal) LoadingManager API is:

- `itemStart` — called when loader begins downloading a file.
- `itemEnd` — called when loader finishes downloading a file. If no other items are pending, calls `onLoad`.

However, `.gltf` files progress as:

1. `.gltf` JSON manifest downloaded.

- `onLoad` is called when it completes

1. `.bin` and texture resources are requested

- `onLoad` is probably called again?

1. GLTFLoader asynchronously constructs the scene graph and calls its own onLoad callback

If you only need to know when a particular model finishes, use the loader’s `onLoad` instead of the LoadingManager’s for now. To have LoadingManager do the right thing, i think we should file a bug.

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [June 8, 2018, 2:18pm UTC](https://discourse.threejs.org/t/gltfloader-defaultloadingmanager/3062/3 "2018-06-08T14:18:05Z")

</div>

A simple example where `LoadingManager` works as intended is:

[https://threejs.org/examples/webgl\_loader\_collada.html](https://threejs.org/examples/webgl_loader_collada.html)

The model consist of the `dae` file and four textures. `LoadingManager.onLoad()` fires as soon as all assets are loaded.

---

<div class="post-metadata">

**Author:** ![stmaccarelli](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/stmaccarelli/32/3181_2.png) [@stmaccarelli](https://discourse.threejs.org/u/stmaccarelli)\
**Post date:** [June 8, 2018, 4:22pm UTC](https://discourse.threejs.org/t/gltfloader-defaultloadingmanager/3062/4 "2018-06-08T16:22:53Z")

</div>

@donmccurdy yes, I was thinking about an async loading problem, because I tried both a .gltf + .bin and a .glb (single binary file) and DefaultLoadingManager counts the file loaded as soon as gltf inits loading.

I didn’t check GLTFLoader’s own loading manager, but it should default to DefaultLoadingManager, as from reference, so maybe it will give back the same error.  
Anyway I have a library of assets (mostly textures and 3d models) and I need to know when the entire library is loaded.

Since using GLTF is not extremely necessary right now, I’ll limit 3D models file format to OBJ and PLY.

Are you going to file an issue on github I can track?

---

<div class="post-metadata">

**Author:** ![donmccurdy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/donmccurdy/32/33209_2.png) [@donmccurdy](https://discourse.threejs.org/u/donmccurdy)\
**Post date:** [June 8, 2018, 11:28pm UTC](https://discourse.threejs.org/t/gltfloader-defaultloadingmanager/3062/5 "2018-06-08T23:28:10Z")

</div>

Opened an issue here: [https://github.com/mrdoob/three.js/issues/14256](https://github.com/mrdoob/three.js/issues/14256)
