question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LoadingManager: onLoad invoked early by loaders with async parsing

See original GitHub issue

GLTFLoader goes through the following steps for .gltf assets.

  1. request .gltf JSON manifest
  2. parse JSON, request necessary .bin and texture resources
  3. assemble scene graph and call loader’s onLoad callback

All three of those steps are asynchronous, but LoadingManager invokes its on onLoad after any file request finishes if there are no outstanding requests. So the manager calls onLoad after steps (1) and (2), both. The issue is still there for .glb, because assembly is still asynchronous.

COLLADALoader gets around this because its parsing step is synchronous. As soon as the .dae file is obtained, it synchronously parses, calls the loader onLoad, and then the manager’s onLoad is invoked. Texture requests will finish some time after that.

That approach isn’t an option for glTF — we could hack a solution:

const fakeRequestURL = '[[my-fake-request-232932929]]';
manager.itemStart( fakeRequestURL );

// ... do async requests and assembly ...

manager.itemEnd( fakeRequestURL );

This makes itemsLoaded / itemsTotal incorrect, but isn’t the worst outcome. Otherwise I think we’d need to change the LoadingManager API a bit.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:19 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Mugen87commented, Jun 12, 2018

@donmccurdy For now, I think creating a proxy request via manager.itemStart() and manager.itemEnd() is the best solution for GLTFLoader.

1reaction
pailheadcommented, Jun 9, 2018

Please consider that the tone of one’s posts may be misinterpreted based on a language barrier. I believe that there is some frustration among the users who don’t have stakes in other libraries, products and companies.

GLTFLoader definitely comes off as a first class citizen, and seems to be influencing many three.js core changes. This is a very valid concern:

Please pay attention and don’t mess up the THREE LoadingManager just to make the GLTF loader run “better”. That’s all I ask here.

Possibly could be reworded as:

Please proceed with care when refactoring THREE.LoadingManager and consider the fact that GLTFLoader is not the only loader present in /examples. Thank you.

Please consult other loaders for possible alternate patterns that might remove the requirement to modify THREE.LoadingManager. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GLTFLoader + DefaultLoadingManager - Questions
It looks like DefaultLoadingManager fires the onLoad callback before GLTFLoader finished parsing the scene. Is it a correct behaviour?
Read more >
Loaders
Loaders make it easy to asynchronously load data in an activity or fragment. Loaders have these characteristics: There are multiple classes ...
Read more >
How do i load gltf files using three js
LoadingManager (); const loader = new THREE. ... glTF resource **line90** loader.load( // resource URL 'static/ElmTree.gltf', // called when ...
Read more >
Making loading data lifecycle aware | by Ian Lake
Let's say you are converting a regular AsyncTask to the loader equivalent, ... basically as soon as you know you'll need to load...
Read more >
Connect to the Internet with AsyncTask and AsyncTaskLoader
In this practical you will use an AsyncTask to start a background task which ... which results in a load every time the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found