[124] TiltLoader breaks in a module env
See original GitHub issueRepro: https://codesandbox.io/s/elegant-villani-9d3hr?file=/src/index.js
import { TiltLoader } from "three/examples/jsm/loaders/TiltLoader"
new TiltLoader().load("/model.tilt", (scene) => console.log(scene))
This is the error message in a local env (Parcel):
TiltLoader.js:42 TypeError: _jszipModuleMin.JSZip is not a constructor
at TiltLoader.parse (TiltLoader.js:59)
at Object.onLoad (TiltLoader.js:32)
at XMLHttpRequest.<anonymous> (three.module.js:36749)
Issue Analytics
- State:
- Created 3 years ago
- Comments:32 (7 by maintainers)
Top Results From Across the Web
Caterpillar Performance Handbook - MacAllister Machinery
Machine performance must ultimately be meas ured in unit cost of material moved, a measure that includes both production and costs.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, author of fflate here! The reason the async version exists in JSZip is beyond me, since it doesn’t actually offload the processing to other threads. On the other hand, if the assets in the ZIP are reasonably large (around 500kB), fflate will use worker threads to compress/decompress them faster.
However, I looked at some of the demos using JSZip and they don’t seem to load that much data, so using the synchronous unzipping algorithm would be no different to the async version. You could even replace
gunzip.js
, which is used by the NRRD loader, withfflate
because gunzip and unzip use the same core algorithm.Since it seems the ThreeJS team wants minified ES6 module scripts, I’ve hand-tuned a minified version of the library and pasted it below. It’s 4.4kB (2.2kB gzipped) and supports synchronous ZIP decompression (through the exported
unzipSync
method) and GZIP decompression (throughgunzipSync
).Usage:
Minified code (to put in
fflate.module.min.js
):This duplication issue will still exist if the examples were to use fflate, but since most users seem to think of 4kB as pocket change, it probably doesn’t matter.
I added the ZIP function into
fflateDeflate
.fflate-deflate.min.js
:fflate-deflate.min.module.js
:Usage:
Side note: in case @sciecode is still working on this,
fflate.unzlibSync(u8Data, new Uint8Array(uncompressedSize))
will work well for you. See the docs.Also, if you’re still looking into the EXR exporter, try
fflateDeflate.zlibSync(u8Data, options)
. Docs