TL;DR:
Does it make sense to have onProgress reporting during a Loader's .parse() method?
Keep reading...
Recently I switched from using ObjectLoader.load() to ObjectLoader.parse(). The reasons for switching are that I really had no need for actually loading a file, I can just parse the information just the same. I gain one less dependency on XHR, on the other hand however, I loose onProgress information while things are being parsed.
Loaders work well to report onProgress information in the load()method. I'd be interested to hear if anyone would find it useful to also include a similar onProgress on the .parse() method. I understand the mechanism to report the progress is different, .load() uses XHR total vs loaded bytes, whereas in .parse(), there is no mechanism in place to understand the bytes parsed vs total. There could be, however, an understanding of total _things_ to parse. I'm mainly thinking of the ObjectLoader where there is parseGeometries, parseTextures, etc.
Loading Manager works to a certain extent to describe if 'files' are being loaded, and in my case, I do have base64 encoded images in the JSON data which it does report loading during the progress. But if I have a rather large set of geometries with say, only one texture, I don't get any meaningful information regarding where we are in the geometry loading. My files tend to have a lot of geometry pieces.
I do not want to add unnecessary overhead, and it would be great if there was an abstract way to handle all loading situations, as well as allow people to opt in or out of such progress reporting.
I'd be interested to hear if anyone would find it useful to also include a similar onProgress on the .parse() method.
Why do you need something like that?
Huge parse time = bad design
How do you avoid huge parse time with 10-100mb models?
Parsing is usually done in the main thread and a sequential process. While parsing, everything else in your application is blocked. Even UI updates are not possible. One approach to avoid this problem is to encapsulate your parsing logic into a separate thread (Web Worker) and report the results via messaging into your main thread.
See: https://www.html5rocks.com/en/tutorials/workers/basics/
@Mugen87 I guess I should read though #9756
Looks good 馃槈
How do you avoid huge parse time with 10-100mb models?
Stay away from JSON, OBJ, DAE and other text formats.
For best results use binary (and compressed) formats.
Example: http://necromanthus.com/Test/html5/SMC.html
what would you need progress event for if you cant actually display the progress? unless you use the worker, as suggested above, your UI is locked until parse method is done
@makc the point is to be able to track the progress. Thanks to @Mugen87, it is clear this will probably need to happen with a Worker.
ObjectLoader basically relies on JSON.parse() which doesn't provide a progress event.
@mrdoob you could use replacer argument, I guess
Every time we try to put hacks in the hack bites us in the butt...
Most helpful comment
Every time we try to put hacks in the hack bites us in the butt...