UnZipData.js 2.5 KB

1
  1. define(["./createTaskProcessorWorker","./pako_inflate-f73548c4","./CompressedTextureBuffer-290a1ff4","./when-b60132fc","./PixelFormat-bcb666b6","./WebGLConstants-aba9fc67"],(function(e,r,t,n,a,i){"use strict";var f,E,u=1,s=2,o={};o[0]=a.PixelFormat.RGB_DXT1,o[u]=a.PixelFormat.RGBA_DXT3,o[s]=a.PixelFormat.RGBA_DXT5;var _,c=0;function d(e){var r=e.data,u=r.byteLength,s=new Uint8Array(r,e.offset),d=_._malloc(u);!function(e,r,t,n){var a,i=t/4,f=n%4,E=new Uint32Array(e.buffer,0,(n-f)/4),u=new Uint32Array(r.buffer);for(a=0;a<E.length;a++)u[i+a]=E[a];for(a=n-f;a<n;a++)r[t+a]=e[a]}(s,_.HEAPU8,d,u);var T=_._crn_get_dxt_format(d,u),y=o[T];if(!n.defined(y))throw new i.RuntimeError("Unsupported compressed format.");var l,m=_._crn_get_levels(d,u),U=_._crn_get_width(d,u),p=_._crn_get_height(d,u),A=0;for(l=0;l<m;++l)A+=a.PixelFormat.compressedTextureSizeInBytes(y,U>>l,p>>l);if(c<A&&(n.defined(f)&&_._free(f),f=_._malloc(A),E=new Uint8Array(_.HEAPU8.buffer,f,A),c=A),_._crn_decompress(d,u,f,A,0,m),_._free(d),n.defaultValue(e.bMipMap,!1)){var B=E.slice(0,A);return new t.CompressedTextureBuffer(y,U,p,B)}var g=a.PixelFormat.compressedTextureSizeInBytes(y,U,p),w=E.subarray(0,g),P=new Uint8Array(g);return P.set(w,0),new t.CompressedTextureBuffer(y,U,p,P)}function T(e){var r=new DataView(e),t=0,n=r.getUint32(t,!0);t+=Uint32Array.BYTES_PER_ELEMENT;var a=r.getUint32(t,!0);t+=Uint32Array.BYTES_PER_ELEMENT;var i=r.getUint32(t,!0);t+=Uint32Array.BYTES_PER_ELEMENT;var f=r.getUint32(t,!0);t+=Uint32Array.BYTES_PER_ELEMENT;var E=r.getUint32(t,!0);t+=Uint32Array.BYTES_PER_ELEMENT;var u=d({data:e.slice(t,t+E)}).bufferView,s=new ArrayBuffer(t+u.byteLength),o=new Uint8Array(s),_=new Uint32Array(s);return t=0,_[0]=n,t+=Uint32Array.BYTES_PER_ELEMENT,_[1]=a,t+=Uint32Array.BYTES_PER_ELEMENT,_[2]=i,t+=Uint32Array.BYTES_PER_ELEMENT,_[3]=f,t+=Uint32Array.BYTES_PER_ELEMENT,_[4]=u.byteLength,t+=Uint32Array.BYTES_PER_ELEMENT,o.set(u,t),s}function y(e,t){for(var n=e.data,a=[],i=0;i<n.length;i++){var f,E=n[i];try{var u=new Uint8Array(E.zipBuffer);f=r.pako.inflate(u).buffer,e.isCRN&&(f=T(f)),t.push(f),a.push({unzipBuffer:f,name:E.name})}catch(r){E.unzipLength===E.zippedLength&&(f=E.zipBuffer.buffer,e.isCRN&&(f=T(f)),t.push(f),a.push({unzipBuffer:f,name:E.name}));continue}}return{data:a}}function l(){self.onmessage=e(y),self.postMessage(!0)}return function(e){var r=e.data.webAssemblyConfig;if(n.defined(r))return require([r.modulePath],(function(e){n.defined(r.wasmBinaryFile)?(n.defined(e)||(e=self.Module),_=e,l()):(_=e,l())}))}}));