Agriculture-front-end/dist/Cesium/Workers/UnZipData.js
2023-09-11 21:56:39 +08:00

2 lines
2.5 KiB
JavaScript

define(["./createTaskProcessorWorker","./pako_inflate-f73548c4","./CompressedTextureBuffer-290a1ff4","./when-b60132fc","./PixelFormat-d55645da","./RuntimeError-4a5c8994","./WebGLConstants-4ae0db90"],(function(e,r,t,n,a,i,f){"use strict";var E,u,s=1,o=2,_={};_[0]=a.PixelFormat.RGB_DXT1,_[s]=a.PixelFormat.RGBA_DXT3,_[o]=a.PixelFormat.RGBA_DXT5;var d,c=0;function T(e){var r=e.data,f=r.byteLength,s=new Uint8Array(r,e.offset),o=d._malloc(f);!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,d.HEAPU8,o,f);var T=d._crn_get_dxt_format(o,f),y=_[T];if(!n.defined(y))throw new i.RuntimeError("Unsupported compressed format.");var l,m=d._crn_get_levels(o,f),U=d._crn_get_width(o,f),p=d._crn_get_height(o,f),A=0;for(l=0;l<m;++l)A+=a.PixelFormat.compressedTextureSizeInBytes(y,U>>l,p>>l);if(c<A&&(n.defined(E)&&d._free(E),E=d._malloc(A),u=new Uint8Array(d.HEAPU8.buffer,E,A),c=A),d._crn_decompress(o,f,E,A,0,m),d._free(o),n.defaultValue(e.bMipMap,!1)){var B=u.slice(0,A);return new t.CompressedTextureBuffer(y,U,p,B)}var g=a.PixelFormat.compressedTextureSizeInBytes(y,U,p),w=u.subarray(0,g),P=new Uint8Array(g);return P.set(w,0),new t.CompressedTextureBuffer(y,U,p,P)}function y(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=T({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 l(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=y(f)),t.push(f),a.push({unzipBuffer:f,name:E.name})}catch(r){E.unzipLength===E.zippedLength&&(f=E.zipBuffer.buffer,e.isCRN&&(f=y(f)),t.push(f),a.push({unzipBuffer:f,name:E.name}));continue}}return{data:a}}function m(){self.onmessage=e(l),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),d=e,m()):(d=e,m())}))}}));