UNPKG

threepipe

Version:

A 3D viewer framework built on top of three.js in TypeScript with a focus on quality rendering, modularity and extensibility.

16 lines 676 B
import { FileLoader } from 'three'; import { unzipSync } from 'three/examples/jsm/libs/fflate.module.js'; export class ZipLoader extends FileLoader { load(url, onLoad, onProgress, onError) { this.setResponseType('arraybuffer'); return super.load(url, (buffer) => { // const files = blob.arrayBuffer().then(buff => ) const files = unzipSync(new Uint8Array(buffer)); const map = new Map(Object.entries(files).map(([path, fileBuffer]) => { return [path, new File([fileBuffer], path)]; })); onLoad?.(map); }, onProgress, onError); } } //# sourceMappingURL=ZipLoader.js.map