When I tried to load an STL ASCII file with STLLoader the first time I wondered why the parsing took such a veeeeery long time.
The reason is quite obvious:
Because of FileLoader’s response type being set in line 48 of STLLoader.js FileLoader loads the file into an ArrayBuffer, even if it is ASCII, so that it has to be reconverted into text by STLLoader’s ensureString function.
On my machine this reconverting takes about 12 additional seconds on Chrome and about 6 seconds on Firefox for a 40MB file.
If I have such an ASCII file and remove setResponseType('arraybuffer')
on trial, the file is parsed directly and relatively quickly (about 2-3 seconds).
@jostschmithals
Would you please try to add
after
in
STLLoader
three.js/examples/js/loaders/STLLoader.js
Line 247
in
6028312
and see how the performance with your 40MB file will be?
@takahirox
The result is excellent! – Adding
improves the time needed on my system for executing the
ensureString
function(with the previously tested 40MB STL ASCII file, on Windows 10)
– and in spite of this the model looks exactly like before😉
Getting specific, that’s IE 11 and Microsoft Edge[1]. I’d encourage interested persons to upvote the issue here. It is marked as “under consideration” currently.
My preference would be to not add
setResponseType()
if it’s purely an optimization for one vendor. Setting a “text” response type for a binary.glb
will not work, so it seems likely to confuse people in addition to adding code paths we must maintain.TextDecoder API is now in progress on Microsoft Edge, as well: https://wpdev.uservoice.com/forums/257854-microsoft-edge-developer/suggestions/6558040-support-the-encoding-api🙂