threepipe
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

ZipLoader.ts 750B

123456789101112131415161718
  1. import {FileLoader} from 'three'
  2. import {unzipSync} from 'three/examples/jsm/libs/fflate.module.js'
  3. export class ZipLoader extends FileLoader {
  4. load(url: string, onLoad?: (t: any) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void {
  5. this.setResponseType('arraybuffer')
  6. return super.load(url, (buffer: any)=>{
  7. // const files = blob.arrayBuffer().then(buff => )
  8. const files = unzipSync(new Uint8Array(buffer))
  9. const map = new Map<string, File>(Object.entries(files).map(([path, fileBuffer]) => {
  10. return [path, new File([fileBuffer as any], path)]
  11. }))
  12. onLoad?.(map)
  13. }, onProgress, onError)
  14. }
  15. }