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

2 lines
43 KiB
JavaScript

define(["./createTaskProcessorWorker","./Check-7b2a090c","./FeatureDetection-c3b71206","./when-b60132fc","./BoundingSphere-561b54d0","./Cartographic-3309dd0d","./Cartesian4-3ca25aab","./Color-5008547b","./ComponentDatatype-c140a87d","./S3MCompressType-4145c64c","./Cartesian2-47311507","./IndexDatatype-8a5eead4","./PrimitiveType-39acab88","./RuntimeError-4a5c8994","./pako_inflate-f73548c4","./unzip-7fd7fbf8","./buildModuleUrl-3addfe33","./arrayFill-4513d7ad","./CompressedTextureBuffer-290a1ff4","./PixelFormat-d55645da","./Math-119be1a3","./WebGLConstants-4ae0db90","./BoundingRectangle-01b3e970"],(function(t,e,r,a,n,i,o,E,s,y,f,u,d,l,T,p,_,c,A,m,g,v,B){"use strict";function P(t,e,a){if("function"==typeof t.slice)return t.slice(e,a);for(var n=Array.prototype.slice.call(t,e,a),i=r.FeatureDetection.typedArrayTypes,o=i.length,E=0;E<o;++E)if(t instanceof i[E]){n=new i[E](n);break}return n}function U(){}var L;function M(t,e,r){var n,i=t.num_points(),o=r.num_components(),E=new L.AttributeQuantizationTransform;if(E.InitFromAttribute(r)){for(var y=new Array(o),f=0;f<o;++f)y[f]=E.min_value(f);n={quantizationBits:E.quantization_bits(),minValues:y,range:E.range(),octEncoded:!1}}L.destroy(E),(E=new L.AttributeOctahedronTransform).InitFromAttribute(r)&&(n={quantizationBits:E.quantization_bits(),octEncoded:!0}),L.destroy(E);var u,d=i*o;u=a.defined(n)?function(t,e,r,a,n){var i,o;a.quantizationBits<=8?(o=new L.DracoUInt8Array,i=new Uint8Array(n),e.GetAttributeUInt8ForAllPoints(t,r,o)):(o=new L.DracoUInt16Array,i=new Uint16Array(n),e.GetAttributeUInt16ForAllPoints(t,r,o));for(var E=0;E<n;++E)i[E]=o.GetValue(E);return L.destroy(o),i}(t,e,r,n,d):function(t,e,r,a){var n,i;switch(r.data_type()){case 1:case 11:i=new L.DracoInt8Array,n=new Int8Array(a),e.GetAttributeInt8ForAllPoints(t,r,i);break;case 2:i=new L.DracoUInt8Array,n=new Uint8Array(a),e.GetAttributeUInt8ForAllPoints(t,r,i);break;case 3:i=new L.DracoInt16Array,n=new Int16Array(a),e.GetAttributeInt16ForAllPoints(t,r,i);break;case 4:i=new L.DracoUInt16Array,n=new Uint16Array(a),e.GetAttributeUInt16ForAllPoints(t,r,i);break;case 5:case 7:i=new L.DracoInt32Array,n=new Int32Array(a),e.GetAttributeInt32ForAllPoints(t,r,i);break;case 6:case 8:i=new L.DracoUInt32Array,n=new Uint32Array(a),e.GetAttributeUInt32ForAllPoints(t,r,i);break;case 9:case 10:i=new L.DracoFloat32Array,n=new Float32Array(a),e.GetAttributeFloatForAllPoints(t,r,i)}for(var o=0;o<a;++o)n[o]=i.GetValue(o);return L.destroy(i),n}(t,e,r,d);var l=s.ComponentDatatype.fromTypedArray(u);return{array:u,data:{componentsPerAttribute:o,componentDatatype:l,byteOffset:r.byte_offset(),byteStride:s.ComponentDatatype.getSizeInBytes(l)*o,normalized:r.normalized(),quantization:n}}}function b(t,e,r,E,u,d,l){var T=void 0,p=void 0,_=r.vertexAttributes,c=r.attrLocation;if(r.nCompressOptions=0,a.defined(E.posUniqueID)&&E.posUniqueID>=0){r.nCompressOptions|=y.VertexCompressOption.SVC_Vertex;var A=e.GetAttribute(t,E.posUniqueID),m=M(t,e,A),g=m.data.componentsPerAttribute;r.verticesCount=m.array.length/g,r.vertCompressConstant=m.data.quantization.range/(1<<m.data.quantization.quantizationBits);var v=m.data.quantization.minValues;if(r.minVerticesValue=new o.Cartesian4(v[0],v[1],v[2],1),g>3&&(r.minVerticesValue.w=v[3]),c.aPosition=_.length,_.push({index:c.aPosition,typedArray:m.array,componentsPerAttribute:g,componentDatatype:m.data.componentDatatype,offsetInBytes:m.data.byteOffset,strideInBytes:m.data.byteStride,normalize:m.data.normalized}),d){var B=r.verticesCount,P=new i.Cartesian3,U=new i.Cartesian3,L=new i.Cartographic;T=new i.Cartographic,p=new i.Cartographic;for(var b=new Float32Array(2*B),S=new Float64Array(2*B),h=0;h<B;h++)n.Matrix4.multiplyByPoint(u,i.Cartesian3.fromElements(m.array[3*h]*r.vertCompressConstant+v[0],m.array[3*h+1]*r.vertCompressConstant+v[1],m.array[3*h+2]*r.vertCompressConstant+v[2],P),U),L=i.Cartographic.fromCartesian(U),S[2*h]=L.longitude,S[2*h+1]=L.latitude,0===h?(T.longitude=L.longitude,T.latitude=L.latitude,p.longitude=L.longitude,p.latitude=L.latitude):(T.longitude=Math.max(L.longitude,T.longitude),T.latitude=Math.max(L.latitude,T.latitude),p.longitude=Math.min(L.longitude,p.longitude),p.latitude=Math.min(L.latitude,p.latitude));for(h=0;h<B;h++)b[2*h]=S[2*h]-p.longitude,b[2*h+1]=S[2*h+1]-p.latitude;c.img=_.length,_.push({index:c.img,typedArray:b,componentsPerAttribute:2,componentDatatype:s.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:2*Float32Array.BYTES_PER_ELEMENT,normalize:!1}),l.max=T,l.min=p}}if(a.defined(E.normalUniqueID)&&E.normalUniqueID>=0){r.nCompressOptions|=y.VertexCompressOption.SVC_Normal;var N=e.GetAttribute(t,E.normalUniqueID),R=M(t,e,N),x=R.data.quantization;r.normalRangeConstant=(1<<x.quantizationBits)-1,c.aNormal=_.length,_.push({index:c.aNormal,typedArray:R.array,componentsPerAttribute:R.data.componentsPerAttribute,componentDatatype:R.data.componentDatatype,offsetInBytes:R.data.byteOffset,strideInBytes:R.data.byteStride,normalize:R.data.normalized})}if(a.defined(E.colorUniqueID)&&E.colorUniqueID>=0){r.nCompressOptions|=y.VertexCompressOption.SVC_VertexColor;var Y=e.GetAttribute(t,E.colorUniqueID),C=M(t,e,Y);c.aColor=_.length,_.push({index:c.aColor,typedArray:new Uint8Array(C.array),componentsPerAttribute:C.data.componentsPerAttribute,componentDatatype:s.ComponentDatatype.UNSIGNED_BYTE,offsetInBytes:C.data.byteOffset,strideInBytes:4,normalize:C.data.normalized})}for(h=0;h<E.texCoordUniqueIDs.length;h++){r.texCoordCompressConstant=[],r.minTexCoordValue=[];var I=E.texCoordUniqueIDs[h];if(!(I<0)){var F=e.GetAttribute(t,I),D=M(t,e,F);if(a.defined(D.data.quantization)){r.nCompressOptions|=y.VertexCompressOption.SVC_TexutreCoord,r.texCoordCompressConstant.push(D.data.quantization.range/(1<<D.data.quantization.quantizationBits));v=D.data.quantization.minValues;r.minTexCoordValue.push(new f.Cartesian2(v[0],v[1]))}var w="aTexCoord"+h;c[w]=_.length,_.push({index:c[w],typedArray:D.array,componentsPerAttribute:D.data.componentsPerAttribute,componentDatatype:D.data.componentDatatype,offsetInBytes:D.data.byteOffset,strideInBytes:D.data.byteStride,normalize:D.data.normalized})}}}U.dracoDecodePointCloud=function(t,e,r,a,n){for(var i=new(L=t).Decoder,o=["POSITION","NORMAL","COLOR"],E=0;E<o.length;++E)i.SkipAttributeTransform(L[o[E]]);var s=new L.DecoderBuffer;if(s.Init(e,r),i.GetEncodedGeometryType(s)!==L.POINT_CLOUD)throw new l.RuntimeError("Draco geometry type must be POINT_CLOUD.");var y=new L.PointCloud,f=i.DecodeBufferToPointCloud(s,y);if(!f.ok()||0===y.ptr)throw new l.RuntimeError("Error decoding draco point cloud: "+f.error_msg());L.destroy(s),b(y,i,a,n),L.destroy(y),L.destroy(i)},U.dracoDecodeMesh=function(t,e,r,a,n,i,o,E,s){for(var y=new(L=t).Decoder,f=["POSITION","NORMAL","COLOR","TEX_COORD"],T=0;T<f.length;++T)y.SkipAttributeTransform(L[f[T]]);var p=new L.DecoderBuffer;if(p.Init(e,r),y.GetEncodedGeometryType(p)!==L.TRIANGULAR_MESH)throw new l.RuntimeError("Unsupported draco mesh geometry type.");var _=new L.Mesh,c=y.DecodeBufferToMesh(p,_);if(!c.ok()||0===_.ptr)throw new l.RuntimeError("Error decoding draco mesh geometry: "+c.error_msg());L.destroy(p),b(_,y,a,i,o,E,s);var A=function(t,e){for(var r=t.num_points(),a=t.num_faces(),n=new L.DracoInt32Array,i=3*a,o=u.IndexDatatype.createTypedArray(r,i),E=0,s=0;s<a;++s)e.GetFaceFromMesh(t,s,n),o[E+0]=n.GetValue(0),o[E+1]=n.GetValue(1),o[E+2]=n.GetValue(2),E+=3;var y=u.IndexDatatype.UNSIGNED_SHORT;return o instanceof Uint32Array&&(y=u.IndexDatatype.UNSIGNED_INT),L.destroy(n),{typedArray:o,numberOfIndices:i,indexDataType:y}}(_,y);n.indicesTypedArray=A.typedArray,n.indicesCount=A.numberOfIndices,n.indexType=A.indexDataType,n.primitiveType=d.PrimitiveType.TRIANGLES,L.destroy(_),L.destroy(y)};var S,h,N=Object.freeze({S3M:49,S3M4:1}),R=1,x=2,Y={};Y[0]=m.PixelFormat.RGB_DXT1,Y[R]=m.PixelFormat.RGBA_DXT3,Y[x]=m.PixelFormat.RGBA_DXT5;var C,I=0,F=!1;function D(t,e){var r=t.data,n=r.byteLength,i=new Uint8Array(r),o=C._malloc(n);!function(t,e,r,a){var n,i=r/4,o=a%4,E=new Uint32Array(t.buffer,0,(a-o)/4),s=new Uint32Array(e.buffer);for(n=0;n<E.length;n++)s[i+n]=E[n];for(n=a-o;n<a;n++)e[r+n]=t[n]}(i,C.HEAPU8,o,n);var E=C._crn_get_dxt_format(o,n),s=Y[E];if(!a.defined(s))throw new l.RuntimeError("Unsupported compressed format.");var y,f=C._crn_get_levels(o,n),u=C._crn_get_width(o,n),d=C._crn_get_height(o,n),T=0;for(y=0;y<f;++y)T+=m.PixelFormat.compressedTextureSizeInBytes(s,u>>y,d>>y);if(I<T&&(a.defined(S)&&C._free(S),S=C._malloc(T),h=new Uint8Array(C.HEAPU8.buffer,S,T),I=T),C._crn_decompress(o,n,S,T,0,f),C._free(o),a.defaultValue(t.bMipMap,!1)){var p=h.slice(0,T);return e.push(p.buffer),new A.CompressedTextureBuffer(s,u,d,p)}var _=m.PixelFormat.compressedTextureSizeInBytes(s,u,d),c=h.subarray(0,_),g=new Uint8Array(_);return g.set(c,0),e.push(g.buffer),new A.CompressedTextureBuffer(s,u,d,g)}var w,O=1,z=1,V=2,k=3,G=new E.Color,q=!1;if(a.defined(p.unzip)){p.unzip.onRuntimeInitialized=function(){q=!0};var H=p.unzip.cwrap("unzip","number",["number","number","number","number"]),W=p.unzip.cwrap("freePointer",null,["number"])}function X(t,e,r,a,n,i){this.left=t,this.bottom=e,this.right=r,this.top=a,this.minHeight=n,this.maxHeight=i,this.width=r-t,this.length=a-e,this.height=i-n}function j(t,e,r){var a=r,n=t.getUint32(a,!0),i=a+=Uint32Array.BYTES_PER_ELEMENT,o=new Uint8Array(e,a,n);return{dataViewByteOffset:i,byteOffset:a+=n*Uint8Array.BYTES_PER_ELEMENT,buffer:o}}function J(t,e,r,a){var n=t.getUint32(a+e,!0);a+=Uint32Array.BYTES_PER_ELEMENT;var i=r.subarray(a,a+n);return{string:y.getStringFromTypedArray(i),bytesOffset:a+=n}}function Z(t,e,r,a,n,i){var o=r,E=t.getUint16(r+a,!0);o+=Uint16Array.BYTES_PER_ELEMENT,i||(o+=Uint16Array.BYTES_PER_ELEMENT);for(var y=0;y<E;y++){var f=t.getUint32(o+a,!0);o+=Uint32Array.BYTES_PER_ELEMENT;var u=t.getUint16(o+a,!0);if(o+=Uint16Array.BYTES_PER_ELEMENT,t.getUint16(o+a,!0),o+=Uint16Array.BYTES_PER_ELEMENT,20==u||35==u);else{var d=f*u*Float32Array.BYTES_PER_ELEMENT,l=e.subarray(o,o+d);o+=d;var T="aTexCoord"+y,p=n.vertexAttributes,_=n.attrLocation;_[T]=p.length,p.push({index:_[T],typedArray:l,componentsPerAttribute:u,componentDatatype:s.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:u*Float32Array.BYTES_PER_ELEMENT,normalize:!1})}}return{bytesOffset:o}}function Q(t,e,r,a,n){var i=r,o=t.getUint16(i+a,!0);i+=Uint16Array.BYTES_PER_ELEMENT,i+=Uint16Array.BYTES_PER_ELEMENT;for(var E=n.vertexAttributes,y=n.attrLocation,f=0;f<o;f++){var u=t.getUint32(i+a,!0);i+=Uint32Array.BYTES_PER_ELEMENT;var d=t.getUint16(i+a,!0);if(i+=Uint16Array.BYTES_PER_ELEMENT,16===d){i-=Uint16Array.BYTES_PER_ELEMENT;var l=u*(d*Float32Array.BYTES_PER_ELEMENT+Uint16Array.BYTES_PER_ELEMENT),T=e.subarray(i,i+l);i+=l;var p=new Uint8Array(Float32Array.BYTES_PER_ELEMENT*d*u);n.instanceCount=u,n.instanceMode=d,n.instanceBuffer=p,n.instanceIndex=1;for(var _=Float32Array.BYTES_PER_ELEMENT*d+Uint16Array.BYTES_PER_ELEMENT,c=0;c<u;c++){var A=c*_+Uint16Array.BYTES_PER_ELEMENT,m=T.subarray(A,A+_);p.set(m,c*(_-Uint16Array.BYTES_PER_ELEMENT))}g=16*Float32Array.BYTES_PER_ELEMENT,y.uv2=E.length,E.push({index:y.uv2,componentsPerAttribute:4,componentDatatype:s.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:0,strideInBytes:g,instanceDivisor:1}),y.uv3=E.length,E.push({index:y.uv3,componentsPerAttribute:4,componentDatatype:s.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:4*Float32Array.BYTES_PER_ELEMENT,strideInBytes:g,instanceDivisor:1}),y.uv4=E.length,E.push({index:y.uv4,componentsPerAttribute:4,componentDatatype:s.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:8*Float32Array.BYTES_PER_ELEMENT,strideInBytes:g,instanceDivisor:1}),y.secondary_colour=E.length,E.push({index:y.secondary_colour,componentsPerAttribute:4,componentDatatype:s.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:12*Float32Array.BYTES_PER_ELEMENT,strideInBytes:g,instanceDivisor:1})}else{t.getUint16(i+a,!0),i+=Uint16Array.BYTES_PER_ELEMENT;l=u*d*Float32Array.BYTES_PER_ELEMENT;if(17===d||29===d){var g;p=e.subarray(i,i+l);n.instanceCount=u,n.instanceMode=d,n.instanceBuffer=p,n.instanceIndex=1,17===d?(g=17*Float32Array.BYTES_PER_ELEMENT,y.uv2=E.length,E.push({index:y.uv2,componentsPerAttribute:4,componentDatatype:s.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:0,strideInBytes:g,instanceDivisor:1}),y.uv3=E.length,E.push({index:y.uv3,componentsPerAttribute:4,componentDatatype:s.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:4*Float32Array.BYTES_PER_ELEMENT,strideInBytes:g,instanceDivisor:1}),y.uv4=E.length,E.push({index:y.uv4,componentsPerAttribute:4,componentDatatype:s.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:8*Float32Array.BYTES_PER_ELEMENT,strideInBytes:g,instanceDivisor:1}),y.secondary_colour=E.length,E.push({index:y.secondary_colour,componentsPerAttribute:4,componentDatatype:s.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:12*Float32Array.BYTES_PER_ELEMENT,strideInBytes:g,instanceDivisor:1}),y.uv6=E.length,E.push({index:y.uv6,componentsPerAttribute:4,componentDatatype:s.ComponentDatatype.UNSIGNED_BYTE,normalize:!0,offsetInBytes:16*Float32Array.BYTES_PER_ELEMENT,strideInBytes:g,instanceDivisor:1})):29===d&&(g=29*Float32Array.BYTES_PER_ELEMENT,y.uv1=E.length,E.push({index:y.uv1,componentsPerAttribute:4,componentDatatype:s.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:0,strideInBytes:g,instanceDivisor:1,byteLength:l}),y.uv2=E.length,E.push({index:y.uv2,componentsPerAttribute:4,componentDatatype:s.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:4*Float32Array.BYTES_PER_ELEMENT,strideInBytes:g,instanceDivisor:1}),y.uv3=E.length,E.push({index:y.uv3,componentsPerAttribute:4,componentDatatype:s.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:8*Float32Array.BYTES_PER_ELEMENT,strideInBytes:g,instanceDivisor:1}),y.uv4=E.length,E.push({index:y.uv4,componentsPerAttribute:4,componentDatatype:s.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:12*Float32Array.BYTES_PER_ELEMENT,strideInBytes:g,instanceDivisor:1}),y.uv5=E.length,E.push({index:y.uv5,componentsPerAttribute:4,componentDatatype:s.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:16*Float32Array.BYTES_PER_ELEMENT,strideInBytes:g,instanceDivisor:1}),y.uv6=E.length,E.push({index:y.uv6,componentsPerAttribute:4,componentDatatype:s.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:20*Float32Array.BYTES_PER_ELEMENT,strideInBytes:g,instanceDivisor:1}),y.uv7=E.length,E.push({index:y.uv7,componentsPerAttribute:3,componentDatatype:s.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:24*Float32Array.BYTES_PER_ELEMENT,strideInBytes:g,instanceDivisor:1}),y.secondary_colour=E.length,E.push({index:y.secondary_colour,componentsPerAttribute:4,componentDatatype:s.ComponentDatatype.UNSIGNED_BYTE,normalize:!0,offsetInBytes:27*Float32Array.BYTES_PER_ELEMENT,strideInBytes:g,instanceDivisor:1}),y.uv9=E.length,E.push({index:y.uv9,componentsPerAttribute:4,componentDatatype:s.ComponentDatatype.UNSIGNED_BYTE,normalize:!0,offsetInBytes:28*Float32Array.BYTES_PER_ELEMENT,strideInBytes:g,instanceDivisor:1}))}else{var v=u*d;n.instanceBounds=new Float32Array(v);for(var B=0;B<v;B++)n.instanceBounds[B]=t.getFloat32(i+a+B*Float32Array.BYTES_PER_ELEMENT,!0)}i+=l}}return{bytesOffset:i}}function K(t,e,r,o,E,y,f){var u=o,d=e.getUint32(u+r,!0);if(E.verticesCount=d,u+=Uint32Array.BYTES_PER_ELEMENT,d<=0)return{bytesOffset:u};var l=e.getUint16(u+r,!0);u+=Uint16Array.BYTES_PER_ELEMENT;var T=e.getUint16(u+r,!0);T=l*Float32Array.BYTES_PER_ELEMENT,u+=Uint16Array.BYTES_PER_ELEMENT;var p=d*l*Float32Array.BYTES_PER_ELEMENT,_=t.subarray(u,u+p);u+=p;var c=E.vertexAttributes,A=E.attrLocation,m=void 0,g=void 0;if(f){var v=new i.Cartesian3,B=new i.Cartesian3,P=new Float32Array(_.buffer,_.byteOffset,_.byteLength/4),U=new i.Cartographic;m=new i.Cartographic,g=new i.Cartographic;for(var L=new Float32Array(2*d),M=new Float64Array(2*d),b=0;b<d;b++)n.Matrix4.multiplyByPoint(y,i.Cartesian3.fromElements(P[3*b],P[3*b+1],P[3*b+2],v),B),U=i.Cartographic.fromCartesian(B),M[2*b]=U.longitude,M[2*b+1]=U.latitude,0===b?(m.longitude=U.longitude,m.latitude=U.latitude,g.longitude=U.longitude,g.latitude=U.latitude):(m.longitude=Math.max(U.longitude,m.longitude),m.latitude=Math.max(U.latitude,m.latitude),g.longitude=Math.min(U.longitude,g.longitude),g.latitude=Math.min(U.latitude,g.latitude));for(b=0;b<d;b++)L[2*b]=M[2*b]-g.longitude,L[2*b+1]=M[2*b+1]-g.latitude;A.img=c.length,c.push({index:A.img,typedArray:L,componentsPerAttribute:2,componentDatatype:s.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:2*Float32Array.BYTES_PER_ELEMENT,normalize:!1})}else if(3===l&&a.defined(y)){v=new i.Cartesian3,B=new i.Cartesian3,P=new Float32Array(_.buffer,_.byteOffset,_.byteLength/4);for(var S=new Float32Array(_.byteLength/4+d),h=P.length,N=(b=0,0);b<h;b+=3,N+=4)S[N]=P[b],S[N+1]=P[b+1],S[N+2]=P[b+2],n.Matrix4.multiplyByPoint(y,i.Cartesian3.fromElements(S[N],S[N+1],S[N+2],v),B),S[N+3]=i.Cartographic.fromCartesian(B).height;_=S,T=(l=4)*Float32Array.BYTES_PER_ELEMENT}return A.aPosition=c.length,c.push({index:A.aPosition,typedArray:_,componentsPerAttribute:l,componentDatatype:s.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:T,normalize:!1}),{bytesOffset:u,cartographicBounds:{max:m,min:g}}}function $(t,e,r,a,n){var i=a,o=e.getUint32(i+r,!0);if(i+=Uint32Array.BYTES_PER_ELEMENT,o<=0)return{bytesOffset:i};var E=e.getUint16(i+r,!0);i+=Uint16Array.BYTES_PER_ELEMENT;var y=e.getUint16(i+r,!0);i+=Uint16Array.BYTES_PER_ELEMENT;var f=o*E*Float32Array.BYTES_PER_ELEMENT,u=t.subarray(i,i+f);if(i+=f,!n.ignoreNormal){var d=n.vertexAttributes,l=n.attrLocation;l.aNormal=d.length,d.push({index:l.aNormal,typedArray:u,componentsPerAttribute:E,componentDatatype:s.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:y,normalize:!1})}return{bytesOffset:i}}function tt(t,e,r,a,n){var i,o=a,E=e.getUint32(o+r,!0);if(o+=Uint32Array.BYTES_PER_ELEMENT,n.verticesCount,E>0){e.getUint16(o+r,!0),o+=Uint16Array.BYTES_PER_ELEMENT,o+=2*Uint8Array.BYTES_PER_ELEMENT;var y=E*Uint8Array.BYTES_PER_ELEMENT*4;i=P(t,o,o+y),o+=y;var f=n.vertexAttributes,u=n.attrLocation;u.aColor=f.length,f.push({index:u.aColor,typedArray:i,componentsPerAttribute:4,componentDatatype:s.ComponentDatatype.UNSIGNED_BYTE,offsetInBytes:0,strideInBytes:4,normalize:!0})}return{bytesOffset:o}}function et(t,e,r,a,n){var i=a,o=e.getUint32(i+r,!0);return i+=Uint32Array.BYTES_PER_ELEMENT,o<=0?{bytesOffset:i}:(e.getUint16(i+r,!0),i+=Uint16Array.BYTES_PER_ELEMENT,i+=2*Uint8Array.BYTES_PER_ELEMENT,{bytesOffset:i+=o*Uint8Array.BYTES_PER_ELEMENT*4})}function rt(t,e,r,a){var n=a,i=[],o=e.getUint32(n+r,!0);n+=Uint32Array.BYTES_PER_ELEMENT;for(var E=0;E<o;E++){var s={},y=e.getUint32(n+r,!0);n+=Uint32Array.BYTES_PER_ELEMENT;var f=e.getUint8(n+r,!0);n+=Uint8Array.BYTES_PER_ELEMENT,e.getUint8(n+r,!0),n+=Uint8Array.BYTES_PER_ELEMENT;var u=e.getUint8(n+r,!0);if(n+=Uint8Array.BYTES_PER_ELEMENT,n+=Uint8Array.BYTES_PER_ELEMENT,y>0){var d=0,l=null;1===f||3===f?(d=y*Uint32Array.BYTES_PER_ELEMENT,l=t.subarray(n,n+d)):(d=y*Uint16Array.BYTES_PER_ELEMENT,l=t.subarray(n,n+d),y%2!=0&&(d+=2)),s.indicesTypedArray=l,n+=d}s.indicesCount=y,s.indexType=f,s.primitiveType=u;var T=[],p=e.getUint32(n+r,!0);n+=Uint32Array.BYTES_PER_ELEMENT;for(var _=0;_<p;_++){var c=J(e,r,t,n),A=c.string;n=c.bytesOffset,T.push(A),s.materialCode=A}if(i.push(s),0!==n%4)n+=4-n%4}return{bytesOffset:n,arrIndexPackage:i}}function at(t,e,r,a,n,i,E){var f,u=a,d=e.getUint32(u+r,!0);return n.nCompressOptions=d,u+=Uint32Array.BYTES_PER_ELEMENT,(d&y.VertexCompressOption.SVC_Vertex)==y.VertexCompressOption.SVC_Vertex?(f=function(t,e,r,a,n){var i=a,E=e.getUint32(i+r,!0);if(n.verticesCount=E,i+=Uint32Array.BYTES_PER_ELEMENT,E<=0)return{bytesOffset:i};var y=e.getUint16(i+r,!0);i+=Uint16Array.BYTES_PER_ELEMENT;var f=e.getUint16(i+r,!0);f=y*Int16Array.BYTES_PER_ELEMENT,i+=Uint16Array.BYTES_PER_ELEMENT;var u=e.getFloat32(i+r,!0);i+=Float32Array.BYTES_PER_ELEMENT;var d=new o.Cartesian4;d.x=e.getFloat32(i+r,!0),i+=Float32Array.BYTES_PER_ELEMENT,d.y=e.getFloat32(i+r,!0),i+=Float32Array.BYTES_PER_ELEMENT,d.z=e.getFloat32(i+r,!0),i+=Float32Array.BYTES_PER_ELEMENT,d.w=e.getFloat32(i+r,!0),i+=Float32Array.BYTES_PER_ELEMENT,n.vertCompressConstant=u,n.minVerticesValue=d;var l=E*y*Int16Array.BYTES_PER_ELEMENT,T=t.subarray(i,i+l);i+=l;var p=n.vertexAttributes,_=n.attrLocation;return _.aPosition=p.length,p.push({index:_.aPosition,typedArray:T,componentsPerAttribute:y,componentDatatype:s.ComponentDatatype.SHORT,offsetInBytes:0,strideInBytes:f,normalize:!1}),{bytesOffset:i}}(t,e,r,u,n),u=f.bytesOffset):u=(f=K(t,e,r,u,n,E)).bytesOffset,(d&y.VertexCompressOption.SVC_Normal)==y.VertexCompressOption.SVC_Normal?(f=function(t,e,r,a,n){var i=a,o=e.getUint32(i+r,!0);if(i+=Uint32Array.BYTES_PER_ELEMENT,o<=0)return{bytesOffset:i};e.getUint16(i+r,!0),i+=Uint16Array.BYTES_PER_ELEMENT;var E=e.getUint16(i+r,!0);i+=Uint16Array.BYTES_PER_ELEMENT;var y=2*o*Int16Array.BYTES_PER_ELEMENT,f=t.subarray(i,i+y);if(i+=y,!n.ignoreNormal){var u=n.vertexAttributes,d=n.attrLocation;d.aNormal=u.length,u.push({index:d.aNormal,typedArray:f,componentsPerAttribute:2,componentDatatype:s.ComponentDatatype.SHORT,offsetInBytes:0,strideInBytes:E,normalize:!1})}return{bytesOffset:i}}(t,e,r,u,n),u=f.bytesOffset):u=(f=$(t,e,r,u,n)).bytesOffset,u=(f=et(0,e,r,u=(f=tt(t,e,r,u,n)).bytesOffset)).bytesOffset,(d&y.VertexCompressOption.SVC_TexutreCoord)==y.VertexCompressOption.SVC_TexutreCoord?(f=function(t,e,r,a,n){n.texCoordCompressConstant=[],n.minTexCoordValue=[];var i=r,E=t.getUint16(r+a,!0);i+=Uint16Array.BYTES_PER_ELEMENT,i+=Uint16Array.BYTES_PER_ELEMENT;for(var y=0,f=0;f<E;f++){var u=t.getUint8(i+a,!0);i+=Uint8Array.BYTES_PER_ELEMENT,i+=3*Uint8Array.BYTES_PER_ELEMENT;var d=t.getUint32(i+a,!0);i+=Uint32Array.BYTES_PER_ELEMENT;var l=t.getUint16(i+a,!0);i+=Uint16Array.BYTES_PER_ELEMENT,t.getUint16(i+a,!0),i+=Uint16Array.BYTES_PER_ELEMENT;var T=t.getFloat32(i+a,!0);i+=Float32Array.BYTES_PER_ELEMENT,n.texCoordCompressConstant.push(T);var p=new o.Cartesian4;p.x=t.getFloat32(i+a,!0),i+=Float32Array.BYTES_PER_ELEMENT,p.y=t.getFloat32(i+a,!0),i+=Float32Array.BYTES_PER_ELEMENT,p.z=t.getFloat32(i+a,!0),i+=Float32Array.BYTES_PER_ELEMENT,p.w=t.getFloat32(i+a,!0),i+=Float32Array.BYTES_PER_ELEMENT,n.minTexCoordValue.push(p);var _=d*l*Int16Array.BYTES_PER_ELEMENT,c=e.subarray(i,i+_),A=(i+=_)%4;0!==A&&(i+=4-A);var m="aTexCoord"+y,g=n.vertexAttributes,v=n.attrLocation;if(v[m]=g.length,g.push({index:v[m],typedArray:c,componentsPerAttribute:l,componentDatatype:s.ComponentDatatype.SHORT,offsetInBytes:0,strideInBytes:l*Int16Array.BYTES_PER_ELEMENT,normalize:!1}),u){_=d*Float32Array.BYTES_PER_ELEMENT;var B=e.subarray(i,i+_);i+=_,n.texCoordZMatrix=!0,v[m="aTexCoordZ"+y]=g.length,g.push({index:v[m],typedArray:B,componentsPerAttribute:1,componentDatatype:s.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:Float32Array.BYTES_PER_ELEMENT,normalize:!1})}y++}return{bytesOffset:i}}(e,t,u,r,n),u=f.bytesOffset):u=(f=Z(e,t,u,r,n,i)).bytesOffset,(d&y.VertexCompressOption.SVC_TexutreCoordIsW)==y.VertexCompressOption.SVC_TexutreCoordIsW&&(n.textureCoordIsW=!0),{bytesOffset:u=(f=Q(e,t,u,r,n)).bytesOffset}}function nt(t,e,r,a,n,i,o,E){var s,y=a;y=(s=K(t,e,r,y,n,o,E)).bytesOffset;var f=s.cartographicBounds;return{bytesOffset:y=(s=Q(e,t,y=(s=Z(e,t,y=(s=et(0,e,r,y=(s=tt(t,e,r,y=(s=$(t,e,r,y,n)).bytesOffset,n)).bytesOffset)).bytesOffset,r,n,i)).bytesOffset,r,n)).bytesOffset,cartographicBounds:f}}function it(t){return 0!==t.length&&"ClampGroundAndObjectLinePass"===t[0].materialCode}function ot(t,e,r,o,E,s,f,u,d,l,T){var p=t,_=0,c=e.getUint32(_+r,!0);_+=Uint32Array.BYTES_PER_ELEMENT,l=a.defaultValue(l,a.defaultValue.EMPTY_OBJECT);for(var A=void 0,m=0;m<c;m++){var g=J(e,r,p,_),v=g.string;if(a.defined(d)){var B=a.defaultValue(l[v],n.Matrix4.IDENTITY);A=new n.Matrix4,n.Matrix4.multiply(d,B,A)}var L=(_=g.bytesOffset)%4;0!==L&&(_+=4-L);var M;if(M=e.getUint32(_+r,!0),_+=Int32Array.BYTES_PER_ELEMENT,(lt={vertexAttributes:[],attrLocation:{},instanceCount:0,instanceMode:0,instanceIndex:-1}).ignoreNormal=o.ignoreNormal,M==k){u>=2&&(e.getInt32(_+r,!0),_+=Int32Array.BYTES_PER_ELEMENT);var b={};b.posUniqueID=e.getInt32(_+r,!0),_+=Int32Array.BYTES_PER_ELEMENT,b.normalUniqueID=e.getInt32(_+r,!0),_+=Int32Array.BYTES_PER_ELEMENT,b.colorUniqueID=e.getInt32(_+r,!0),_+=Int32Array.BYTES_PER_ELEMENT,b.secondColorUniqueID=e.getInt32(_+r,!0),_+=Int32Array.BYTES_PER_ELEMENT;var S=e.getUint16(_+r,!0);_+=Int16Array.BYTES_PER_ELEMENT;for(var h=[],N=0;N<S;N++){var R=e.getInt32(_+r,!0);h.push(R),_+=Int32Array.BYTES_PER_ELEMENT}b.texCoordUniqueIDs=h;var x=e.getInt32(_+r,!0);_+=Int32Array.BYTES_PER_ELEMENT;var Y=[],C={};if(x>0){var I=J(e,r,p,_),F=I.string;_=I.bytesOffset,C.materialCode=F,Y.push(C)}var D=new Object,O=e.getUint32(_+r,!0),G=P(p,_+=Int32Array.BYTES_PER_ELEMENT,_+O);x>0?U.dracoDecodeMesh(w,G,O,lt,C,b,A,T,D):U.dracoDecodePointCloud(w,G,O,lt,b),a.defined(D.min)&&a.defined(D.max)||(D=void 0),_+=O,o[v]={vertexPackage:lt,arrIndexPackage:Y,cartographicBounds:D}}else{var q;M==z?(_=(g=nt(p,e,r,_,lt,E,A,T)).bytesOffset,D=g.cartographicBounds):M==V&&(_=(g=at(p,e,r,_,lt,E,A)).bytesOffset),it(Y=(g=rt(p,e,r,_)).arrIndexPackage)&&(lt.clampRegionEdge=!0),2===Y.length&&13===Y[1].primitiveType&&Y[1].indicesCount>=3&&(q=y.S3MEdgeProcessor.createEdgeDataByIndices(lt,Y[1],s)),_=g.bytesOffset,o[v]={vertexPackage:lt,arrIndexPackage:Y,edgeGeometry:q,cartographicBounds:D}}if(a.defined(f)&&f){var H=e.getUint16(_+r,!0);if(_+=Uint16Array.BYTES_PER_ELEMENT,1===H){var W=e.getUint32(_+r,!0);_+=Uint32Array.BYTES_PER_ELEMENT;var X,j=e.getUint32(_+r,!0);_+=Uint32Array.BYTES_PER_ELEMENT,e.getFloat32(_+r,!0),_+=Float32Array.BYTES_PER_ELEMENT;var Z=new Array(W),Q=new Array(W),K=new Array(W),$=new Array(W);for(X=0;X<W;X++){var tt=e.getFloat32(_+r,!0);_+=Float32Array.BYTES_PER_ELEMENT,Z[X]=tt;var et=e.getUint16(_+r,!0);_+=Uint16Array.BYTES_PER_ELEMENT,Q[X]=et;var ot=e.getUint16(_+r,!0);_+=Uint16Array.BYTES_PER_ELEMENT,K[X]=ot;for(var Et=ot*j,st=new Array(Et),yt=0;yt<Et;yt++){var ft=e.getFloat32(_+r,!0);_+=Float32Array.BYTES_PER_ELEMENT,st[yt]=ft}$[X]=st}}var ut=new i.Cartesian3,dt=new i.Cartesian3;ut.x=e.getFloat64(_+r,!0),_+=Float64Array.BYTES_PER_ELEMENT,ut.y=e.getFloat64(_+r,!0),_+=Float64Array.BYTES_PER_ELEMENT,ut.z=e.getFloat64(_+r,!0),_+=Float64Array.BYTES_PER_ELEMENT,dt.x=e.getFloat64(_+r,!0),_+=Float64Array.BYTES_PER_ELEMENT,dt.y=e.getFloat64(_+r,!0),_+=Float64Array.BYTES_PER_ELEMENT,dt.z=e.getFloat64(_+r,!0),_+=Float64Array.BYTES_PER_ELEMENT,o[v].min=ut,o[v].max=dt;var lt=o[v].vertexPackage;a.defined(lt.instanceBuffer)&&2===u&&(lt.instanceBounds=new Float32Array(6),i.Cartesian3.pack(ut,lt.instanceBounds,0),i.Cartesian3.pack(dt,lt.instanceBounds,3))}}}function Et(t,e,r,i,o){var E={},s=[],y=new n.Matrix4,f=t;o=a.defaultValue(o,{});for(var u=0;u<16;u++)y[u]=e.getFloat64(r+i,!0),r+=Float64Array.BYTES_PER_ELEMENT;E.matrix=y,E.skeletonNames=s;var d=e.getUint32(r+i,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(var l=0;l<d;l++){var T=J(e,i,f,r),p=T.string;r=T.bytesOffset,s.push(p),o[p]=y}return{byteOffset:r,geode:E}}function st(t){var e=t.indexOf("Geometry");if(-1===e)return t;var r=t.substring(e,t.length);return t.replace(r,"")}function yt(t,e,r,a,o){var E={},s=e.getFloat32(r+a,!0);r+=Float32Array.BYTES_PER_ELEMENT;var y=e.getUint16(r+a,!0);r+=Uint16Array.BYTES_PER_ELEMENT,E.rangeMode=y,E.rangeList=s;var f=new i.Cartesian3;f.x=e.getFloat64(r+a,!0),r+=Float64Array.BYTES_PER_ELEMENT,f.y=e.getFloat64(r+a,!0),r+=Float64Array.BYTES_PER_ELEMENT,f.z=e.getFloat64(r+a,!0),r+=Float64Array.BYTES_PER_ELEMENT;var u=e.getFloat64(r+a,!0);r+=Float64Array.BYTES_PER_ELEMENT,E.boundingSphere=new n.BoundingSphere(f,u);var d=(p=J(e,a,t,r)).string;r=p.bytesOffset,d=st(d=(d=d.replace(/(\.s3mblock)|(\.s3mbz)|(\.s3mb)/gi,"")).replace(/\\/gi,"/")),E.childTile=d,E.geodes=[];var l=e.getUint32(r+a,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(var T=0;T<l;T++){var p;r=(p=Et(t,e,r,a,o)).byteOffset,E.geodes.push(p.geode)}return{pageLOD:E,bytesOffset:r}}function ft(t,e,r,a){var n=0,i={},o=[],E=e.getUint32(n+r,!0);n+=Uint32Array.BYTES_PER_ELEMENT;for(var s=0;s<E;s++){var y=yt(t,e,n,r,a);n=y.bytesOffset,o.push(y.pageLOD)}return i.pageLods=o,i}function ut(t,e,r){var a=t.vertexAttributes,n=t.attrLocation,i=a.length;n["aTextureBatchId"+r]=i,a.push({index:i,typedArray:e,componentsPerAttribute:1,componentDatatype:s.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:0})}function dt(t,e,r,n){for(var i=r.length,o=0;o<i;o++)for(var E=r[o],s=E.subName.split("_")[0],y=E.subVertexOffsetArr,f=0;f<y.length;f++){var u=y[f],d=u.geoName,l=u.offset,T=u.count,p=u.texUnitIndex,_=e[d].vertexPackage.verticesCount,A=n[d];a.defined(A)||(A=n[d]={});var m=A[p];a.defined(m)||(m=A[p]=new Float32Array(_),c.arrayFill(m,-1));var g=a.defined(t)?t[s]:o;c.arrayFill(m,g,l,l+T)}}function lt(t,e,r){var a=t.vertexAttributes,n=t.attrLocation,i=a.length;n[1===r?"instanceId":"batchId"]=i,a.push({index:i,typedArray:e,componentsPerAttribute:1,componentDatatype:s.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:0,instanceDivisor:r})}function Tt(t,e,r,a,n){var i=0,o=t,s=e.getUint32(i+r,!0);i+=Uint32Array.BYTES_PER_ELEMENT;for(var y=0;y<s;y++){var f=J(e,r,o,i),u=f.string;i=f.bytesOffset;var d=e.getUint32(i+r,!0);i+=Uint32Array.BYTES_PER_ELEMENT;var l={};if(a[u].pickInfo=l,-1==a[u].vertexPackage.instanceIndex){for(var T=new Float32Array(a[u].vertexPackage.verticesCount),p=0;p<d;p++){var _=e.getUint32(i+r,!0);i+=Uint32Array.BYTES_PER_ELEMENT;var A=e.getUint32(i+r,!0);i+=Uint32Array.BYTES_PER_ELEMENT;var m=0,g=0;l[_]={batchId:p};for(var v=0;v<A;v++)g=e.getUint32(i+r,!0),i+=Uint32Array.BYTES_PER_ELEMENT,m=e.getUint32(i+r,!0),i+=Uint32Array.BYTES_PER_ELEMENT,c.arrayFill(T,p,g,g+m);l[_].vertexColorOffset=g,l[_].vertexCount=m}lt(a[u].vertexPackage,T,void 0)}else{var B=a[u].vertexPackage.instanceCount,P=a[u].vertexPackage.instanceBuffer,U=a[u].vertexPackage.instanceMode,L=new Float32Array(B),M=17===U?16:28;M*=Float32Array.BYTES_PER_ELEMENT;var b=0;for(p=0;p<d;p++){var S=e.getUint32(i+r,!0);if(i+=Uint32Array.BYTES_PER_ELEMENT,2!==n){var h=b*U*Float32Array.BYTES_PER_ELEMENT+M;E.Color.unpack(P,h,G),S=G.red+256*G.green+65536*G.blue}A=e.getUint32(i+r,!0);i+=Uint32Array.BYTES_PER_ELEMENT;for(v=0;v<A;v++){var N=e.getUint32(i+r,!0);if(i+=Uint32Array.BYTES_PER_ELEMENT,L[b]=b,void 0===l[S]&&(l[S]={vertexColorCount:1,instanceIds:[],vertexColorOffset:b}),l[S].instanceIds.push(N),b++,3===n){m=e.getUint32(i+r,!0);i+=Uint32Array.BYTES_PER_ELEMENT}}}lt(a[u].vertexPackage,L,1)}}}function pt(t){return t<1e-10&&t>-1e-10}function _t(t,e,r,n,i,o,E,s){var f=new DataView(t),u=new Uint8Array(t),d=f.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;var l=y.getStringFromTypedArray(u,r,d);l=l.replace(/(\.s3mblock)|(\.s3mbz)|(\.s3mb)/gi,""),r+=d;var p=f.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(var _=0;_<p;_++){var c={},A=f.getFloat32(r,!0);r+=Float32Array.BYTES_PER_ELEMENT;var m=f.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,c.rangeMode=m,c.rangeList=A;var g={};g.x=f.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,g.y=f.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,g.z=f.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT;var v=f.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT,c.boundingSphere={center:g,radius:v},d=f.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;var B=y.getStringFromTypedArray(u,r,d);r+=d,B=st(B=B.replace(/(\.s3mblock)|(\.s3mbz)|(\.s3mb)/gi,"")),c.childTile=B}var P={},U=f.getFloat32(r,!0);r+=Float32Array.BYTES_PER_ELEMENT;f.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;var L=f.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;var M=new Uint8Array(t,r,L),b=r+L,S=T.pako.inflate(M).buffer;s.push(S),f=new DataView(S);u=new Uint8Array(S);r=0;var h=f.getUint32(r,!0),R=j(f,S,r+=Uint32Array.BYTES_PER_ELEMENT),x=R.buffer;r=R.byteOffset;var Y=ft(x,f,R.dataViewByteOffset),C=r%4;0!==C&&(r+=4-C),ot((R=j(f,S,r)).buffer,f,R.dataViewByteOffset,P,!1),(R=j(f,S,r=R.byteOffset)).buffer;var I={};!function(t,e,r,n,i,o,E,s,f,u){var d=s,l=E.getUint32(d,!0);d+=Uint32Array.BYTES_PER_ELEMENT;for(var T={},p=0;p<l;p++){var _=E.getUint32(d,!0);d+=Uint32Array.BYTES_PER_ELEMENT;var c=y.getStringFromTypedArray(o,d-s,_),A=(d+=_)%4;0!==A&&(d+=4-A),E.getUint32(d,!0),d+=Uint32Array.BYTES_PER_ELEMENT,E.getUint8(d,!0),d+=Uint8Array.BYTES_PER_ELEMENT;var m=E.getUint32(d,!0);d+=Uint32Array.BYTES_PER_ELEMENT;var g=E.getUint32(d,!0);d+=Uint32Array.BYTES_PER_ELEMENT;var v=E.getUint32(d,!0);d+=Uint32Array.BYTES_PER_ELEMENT;var B=E.getUint32(d,!0);d+=Uint32Array.BYTES_PER_ELEMENT;var P,U=E.getUint32(d,!0);if(d+=Uint32Array.BYTES_PER_ELEMENT,n){var L=d-s;P=o.subarray(L,L+B),d+=B}var M=E.getUint32(d,!0);d+=Uint32Array.BYTES_PER_ELEMENT;for(var b=[],S=0;S<M;S++){_=E.getUint32(d,!0),d+=Uint32Array.BYTES_PER_ELEMENT;var h=y.getStringFromTypedArray(o,d-s,_);d+=_,b.push(h),r[h]=c}var N=E.getUint32(d,!0);d+=Uint32Array.BYTES_PER_ELEMENT;var R=[];for(S=0;S<N;S++){_=E.getUint32(d,!0),d+=Uint32Array.BYTES_PER_ELEMENT;var x=y.getStringFromTypedArray(o,d-s,_);d+=_,R.push(x)}var Y=E.getUint32(d,!0);d+=Uint32Array.BYTES_PER_ELEMENT;var C=[],I=void 0,w=c;if(n)I=e[c]={};else{var O=r[c];for(w=O;a.defined(O);)w=O,O=r[O];a.defined(w)&&(I=e[w])}var z=0;for(S=0;S<Y;S++){_=E.getUint32(d,!0),d+=Uint32Array.BYTES_PER_ELEMENT;var V=y.getStringFromTypedArray(o,d-s,_);if(d+=_,n){var k=V.split("_")[0];a.defined(I[k])?z++:I[k]=S-z}var G=E.getUint32(d,!0);d+=Uint32Array.BYTES_PER_ELEMENT;var q=E.getUint32(d,!0);d+=Uint32Array.BYTES_PER_ELEMENT;var H=E.getUint32(d,!0);d+=Uint32Array.BYTES_PER_ELEMENT;var W=E.getUint32(d,!0);d+=Uint32Array.BYTES_PER_ELEMENT;var X=E.getUint32(d,!0);d+=Uint32Array.BYTES_PER_ELEMENT;for(var j=[],J=0;J<X;J++){_=E.getUint32(d,!0),d+=Uint32Array.BYTES_PER_ELEMENT;var Z=y.getStringFromTypedArray(o,d-s,_);d+=_;var Q=E.getUint32(d,!0);d+=Uint32Array.BYTES_PER_ELEMENT;var K=E.getUint32(d,!0);d+=Uint32Array.BYTES_PER_ELEMENT;var $=E.getUint32(d,!0);d+=Uint32Array.BYTES_PER_ELEMENT,j.push({geoName:Z,offset:Q,count:K,texUnitIndex:$})}C.push({subName:V,offsetX:G,offsetY:q,width:H,height:W,subVertexOffsetArr:j})}dt(I,t,C,T),a.defined(P)&&v===y.S3MPixelFormat.CRN_DXT5&&F&&(P=D({data:P},u).bufferView),f[c]={id:c,rootTextureName:w,width:m,height:g,compressType:v,size:B,format:U,textureData:P,subTexInfos:C,requestNames:R}}for(var Z in T)if(T.hasOwnProperty(Z)){var tt=t[Z].vertexPackage,et=T[Z];for(var $ in et)et.hasOwnProperty($)&&ut(tt,et[$],$)}}(P,n,i,o,0,(R=j(f,S,r=R.byteOffset)).buffer,f,R.dataViewByteOffset,I,s),r=R.byteOffset;var w=f.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;var z=u.subarray(r,r+w),V=y.getStringFromTypedArray(z);r+=w;var k=JSON.parse(V);(h&O)==O&&(Tt((R=j(f,S,r)).buffer,f,R.dataViewByteOffset,P,U),r=R.byteOffset);var G=Y.pageLods,q=!0;for(_=0;_<G.length;_++){var H=G[_];q=""===H.childTile;for(var W=H.geodes,X=0;X<W.length;X++)for(var J=W[X].skeletonNames,Z=0;Z<J.length;Z++){var Q=J[Z];if(q){var K=P[Q].vertexPackage;K.boundingSphere=y.S3MVertexPackage.calcBoundingSphereInWorker(1,K)}}}E[l]={result:!0,groupNode:Y,geoPackage:P,matrials:k,texturePackage:I,version:N.S3M4,rootBatchIdMap:n,ancestorMap:i},b<e&&_t(t,e,b,n,i,!1,E,s)}function ct(t,e){var r=t.buffer,n=t.isS3MZ,i=t.fileType,o=t.supportCompressType,E=t.bVolume,s=t.isS3MBlock,f=t.modelMatrix,u=t.materialType,d=t.isCoverImageryLayer,l=null,_=null,c=null;if(E&&t.volbuffer.byteLength<8&&(E=!1),E){var A=t.volbuffer,m=new Uint8Array(A,8),g=T.pako.inflate(m).buffer,v=new Float64Array(g,0,1),B=new Uint32Array(g,48,1);if(0===v[0]||3200===B[0]||3201===B[0]){var P=0;0==v[0]&&(P=8),e.push(g);var U=new Float64Array(g,P,6),L=U[0],M=U[1],b=U[2],S=U[3],h=U[4]<U[5]?U[4]:U[5],R=U[4]>U[5]?U[4]:U[5];_={left:L,top:M,right:b,bottom:S,minHeight:h,maxHeight:R,width:(l=new X(L,S,b,M,h,R)).width,length:l.length,height:l.height};var x=new Uint32Array(g,48+P,7),Y=x[0],C=x[1],I=x[2],F=x[3];c={nFormat:Y,nSideBlockCount:C,nBlockLength:I,nLength:F,nWidth:x[4],nHeight:x[5],nDepth:x[6],imageArray:new Uint8Array(g,76+P,F*F*4)}}}var D=0,w={};w.ignoreNormal=t.ignoreNormal;var z=t.rootBatchIdMap||{},V=t.ancestorMap||{},k={},G=new DataView(r),Z=G.getFloat32(D,!0);if(D+=Float32Array.BYTES_PER_ELEMENT,Z>2.2)return{result:!1};if(s)return G.getUint32(D,!0),D+=Uint32Array.BYTES_PER_ELEMENT,_t(r,r.byteLength,D,z,V,t.isRoot,k,e),k;var Q,K=!1;if(Z>=2&&(Q=G.getUint32(D,!0),D+=Uint32Array.BYTES_PER_ELEMENT),pt(Z-1)||pt(Z-2)||Z>2.09&&Z<2.11){var $=G.getUint32(D,!0);D+=Uint32Array.BYTES_PER_ELEMENT;var tt=new Uint8Array(r,D,$);r=!0===q?function(t,e){var r=e||4*t.length,a=p.unzip._malloc(Uint8Array.BYTES_PER_ELEMENT*r),n=new Uint8Array(r);p.unzip.HEAPU8.set(n,a/Uint8Array.BYTES_PER_ELEMENT);var i,o=p.unzip._malloc(Uint8Array.BYTES_PER_ELEMENT*t.length);for(p.unzip.HEAPU8.set(t,o/Uint8Array.BYTES_PER_ELEMENT);0==(i=H(a,r,o,t.length));)W(a),r*=4,a=p.unzip._malloc(Uint8Array.BYTES_PER_ELEMENT*r),n=new Uint8Array(r),p.unzip.HEAPU8.set(n,a/Uint8Array.BYTES_PER_ELEMENT);var E=new Uint8Array(p.unzip.HEAPU8.buffer,a,i);t=null,n=null;var s=new Uint8Array(E).buffer;return W(a),W(o),s}(tt,Q):T.pako.inflate(tt).buffer,e.push(r),G=new DataView(r),D=0}else if(Z>1.199&&Z<1.201){$=G.getUint32(D,!0);D+=Uint32Array.BYTES_PER_ELEMENT,e.push(r)}else{K=!0,D=0;$=G.getInt32(D,!0);if(D+=Int32Array.BYTES_PER_ELEMENT,D+=Uint8Array.BYTES_PER_ELEMENT*$,n){G.getUint32(D,!0),D+=Uint32Array.BYTES_PER_ELEMENT;m=new Uint8Array(r,D);r=T.pako.inflate(m).buffer,e.push(r),G=new DataView(r),D=0}}var et=G.getUint32(D,!0),rt=j(G,r,D+=Uint32Array.BYTES_PER_ELEMENT),at=rt.buffer;D=rt.byteOffset;var nt={},it=ft(at,G,rt.dataViewByteOffset,nt),Et=D%4;0!==Et&&(D+=4-Et);var st=Z>2.09;if(ot((rt=j(G,r,D)).buffer,G,rt.dataViewByteOffset,w,K,e,st,Z,f,nt,d),D=rt.byteOffset,st)for(var yt=0;yt<it.pageLods.length;yt++)for(var ut=it.pageLods[yt],dt=ut.geodes,lt=0;lt<dt.length;lt++)for(var ct=dt[lt].skeletonNames,At=0;At<ct.length;At++){var mt=ct[At];a.defined(w[mt].max)&&(a.defined(ut.max)?(ut.max.x=Math.max(w[mt].max.x,ut.max.x),ut.max.y=Math.max(w[mt].max.y,ut.max.y),ut.max.z=Math.max(w[mt].max.z,ut.max.z),ut.min.x=Math.min(w[mt].min.x,ut.min.x),ut.min.y=Math.min(w[mt].min.y,ut.min.y),ut.min.z=Math.min(w[mt].min.z,ut.min.z)):(ut.max=w[mt].max,ut.min=w[mt].min))}(rt=j(G,r,D)).buffer;var gt={};!function(t,e,r,a,n,i){var o=0,E=r.getUint32(o+a,!0);o+=Uint32Array.BYTES_PER_ELEMENT;for(var s=0;s<E;s++){var f=J(r,a,e,o),u=f.string,d=(o=f.bytesOffset)%4;0!==d&&(o+=4-d);var l=r.getUint32(o+a,!0);o+=Uint32Array.BYTES_PER_ELEMENT;var T=r.getUint32(o+a,!0);o+=Uint32Array.BYTES_PER_ELEMENT;var p=r.getUint32(o+a,!0);o+=Uint32Array.BYTES_PER_ELEMENT;var _=r.getUint32(o+a,!0);o+=Uint32Array.BYTES_PER_ELEMENT;var c=r.getUint32(o+a,!0);o+=Uint32Array.BYTES_PER_ELEMENT;var A=r.getUint32(o+a,!0);o+=Uint32Array.BYTES_PER_ELEMENT;var m=e.subarray(o,o+c);o+=c;var g=null;_===y.S3MCompressType.enrS3TCDXTN&&1!=t?(y.DXTTextureDecode.decode(g,T,p,m,A),g=A>y.S3MPixelFormat.BGR||A===y.S3MPixelFormat.LUMINANCE_ALPHA?new Uint8Array(T*p*4):new Uint16Array(T*p),y.DXTTextureDecode.decode(g,T,p,m,A),i.push(g.buffer),_=0):g=m,n[u]={id:u,width:T,height:p,compressType:_,nFormat:A,imageBuffer:g,mipmapLevel:l}}}(o,(rt=j(G,r,D=rt.byteOffset)).buffer,G,rt.dataViewByteOffset,gt,e),D=rt.byteOffset;var vt=G.getUint32(D,!0);D+=Uint32Array.BYTES_PER_ELEMENT;var Bt=new Uint8Array(r).subarray(D,D+vt),Pt=y.getStringFromTypedArray(Bt);D+=vt,Pt=Pt.replace(/\n\0/,"");var Ut=JSON.parse(Pt);(et&O)==O&&Tt((rt=j(G,r,D)).buffer,G,rt.dataViewByteOffset,w,Z);var Lt=it.pageLods,Mt=!0;for(yt=0;yt<Lt.length;yt++){var bt=Lt[yt];Mt=""===bt.childTile;for(var St=bt.geodes,ht=0;ht<St.length;ht++){ct=St[ht].skeletonNames;for(var Nt=0;Nt<ct.length;Nt++){var Rt=ct[Nt];if(Mt){var xt=w[Rt].vertexPackage;xt.boundingSphere=y.S3MVertexPackage.calcBoundingSphereInWorker(i,xt)}}}}return"BatchPBR"===u&&function(t,e,r){for(var n in delete t.ignoreNormal,t)if(t.hasOwnProperty(n)){var i=t[n],o=i.arrIndexPackage;if(o.length<1)continue;if(1===o.length||2===o.length&&13===o[1].primitiveType){var E=i.vertexPackage.attrLocation.aTexCoord0;if(void 0!==E){var s=i.vertexPackage.vertexAttributes[E],f=new Float32Array(s.typedArray.buffer,s.typedArray.byteOffset,s.typedArray.byteLength/4);if(3===s.componentsPerAttribute&&f[2]<0)continue}}var u,d,l=0,T={},p=void 0;for(u=0,d=o.length;u<d;u++)13!==o[u].primitiveType?l+=o[u].indicesTypedArray.byteLength:p=o[u],0===u&&(T.indicesCount=0,T.indexType=o[u].indexType,T.primitiveType=o[u].primitiveType,T.materialCode=o[u].materialCode);T.indicesCount=l/2;var _=new Uint8Array(l),c=0;for(u=0,d=o.length;u<d;u++)13!==(h=o[u]).primitiveType&&(_.set(h.indicesTypedArray,c,c+h.indicesTypedArray.byteLength),c+=h.indicesTypedArray.byteLength);T.indicesTypedArray=_,i.arrIndexPackage=[T],a.defined(p)&&(i.arrIndexPackage.push(p),i.edgeGeometry=y.S3MEdgeProcessor.createEdgeDataByIndices(i.vertexPackage,p));var A=2*o.length*4,m=new Float32Array(A),g={};for(u=0,d=r.material.length;u<d;u++)g[(N=r.material[u].material).id]=N;for(u=0,d=o.length;u<d;u++)if(N=g[(h=o[u]).materialCode]){var v=N.pbrMetallicRoughness;if(v){m[8*u]=v.metallicFactor,m[8*u+1]=v.roughnessFactor,m[8*u+2]=N.alphaCutoff;var B=""===N.alphaMode?0:1,P="none"===N.cullMode?0:1;m[8*u+3]=P|B<<16,m[8*u+4]=v.emissiveFactor.x,m[8*u+5]=v.emissiveFactor.y,m[8*u+6]=v.emissiveFactor.z,m[8*u+7]=0,N.pbrIndex=u}}var U="PBRMaterialParam_"+n;for(u=0,d=r.material.length;u<d;u++)if((N=r.material[u].material).id===T.materialCode){N.textureunitstates.push({textureunitstate:{addressmode:{u:0,v:0,w:0},filteringoption:0,filtermax:2,filtermin:2,id:U,texmodmatrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],url:""}});break}var L,M,b=i.vertexPackage,S=b.attrLocation.aTexCoord1;if(void 0!==S){s=b.vertexAttributes[S];L=new Float32Array(2*b.verticesCount),s.typedArray=L}else L=new Float32Array(2*b.verticesCount),S=b.vertexAttributes.length,b.attrLocation.aTexCoord1=S,b.vertexAttributes.push({index:S,typedArray:L,componentsPerAttribute:2,componentDatatype:5126,offsetInBytes:0,strideInBytes:8,normalize:!1});for(void 0!==(S=b.attrLocation.aColor)&&(M=(s=b.vertexAttributes[S]).typedArray),u=0,d=o.length;u<d;u++){var h,N;if((N=g[(h=o[u]).materialCode])&&N.pbrMetallicRoughness)for(var R=N.pbrMetallicRoughness.baseColor,x=void 0!==M,Y=N.pbrIndex,C=(_=h.indicesTypedArray,0),I=(_=0===h.indexType?new Uint16Array(_.buffer,_.byteOffset,_.byteLength/2):new Uint32Array(_.buffer,_.byteOffset,_.byteLength/4)).length;C<I;C++){var F=_[C];L[2*F]=Y,x&&(M[4*F]=255*R.x,M[4*F+1]=255*R.y,M[4*F+2]=255*R.z,M[4*F+3]=255*R.w)}}e[U]={id:U,width:2*o.length,height:1,compressType:0,nFormat:25,imageBuffer:m,mipmapLevel:0}}}(w,gt,Ut),{result:!0,groupNode:it,geoPackage:w,matrials:Ut,texturePackage:gt,version:N.S3M4,volImageBuffer:c,volBounds:_}}function At(){a.defined(C)&&a.defined(w)&&(C.onRuntimeInitialized=function(){F=!0},self.onmessage=t(ct),self.postMessage(!0))}return function(e){if("undefined"==typeof WebAssembly)return self.onmessage=t(ct),void self.postMessage(!0);var n=e.data.webAssemblyConfig;return a.defined(n)?r.FeatureDetection.isInternetExplorer()?require([_.buildModuleUrl("ThirdParty/Workers/ie-webworker-promise-polyfill.js")],(function(t){return self.Promise=t,-1!==n.modulePath.indexOf("crunch")?require([n.modulePath],(function(t){a.defined(n.wasmBinaryFile)?(a.defined(t)||(t=self.Module),C=t,At()):(C=t,At())})):require([n.modulePath],(function(t){a.defined(n.wasmBinaryFile)?(a.defined(t)||(t=self.DracoDecoderModule),t(n).then((function(t){w=t,At()}))):(w=t(),At())}))})):-1!==n.modulePath.indexOf("crunch")?require([n.modulePath],(function(t){a.defined(n.wasmBinaryFile)?(a.defined(t)||(t=self.Module),C=t,At()):(C=t,At())})):require([n.modulePath],(function(t){a.defined(n.wasmBinaryFile)?(a.defined(t)||(t=self.DracoDecoderModule),t(n).then((function(t){w=t,At()}))):(w=t(),At())})):void 0}}));