LoadingManager: onLoad invoked early by loaders with async parsing
See original GitHub issueGLTFLoader goes through the following steps for .gltf
assets.
- request
.gltf
JSON manifest - parse JSON, request necessary
.bin
and texture resources - 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:
- Created 5 years ago
- Reactions:3
- Comments:19 (7 by maintainers)
Top GitHub Comments
@donmccurdy For now, I think creating a proxy request via
manager.itemStart()
andmanager.itemEnd()
is the best solution forGLTFLoader
.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:Possibly could be reworded as: