define(["require","./createTaskProcessorWorker","./Check-7b2a090c","./FeatureDetection-c3b71206","./when-b60132fc","./PrimitiveType-a54dc62f","./Cartesian2-47311507","./Cartographic-3309dd0d","./Cartesian4-3ca25aab","./Color-5008547b","./ComponentDatatype-c140a87d","./getStringFromTypedArray-c37342c0","./buildModuleUrl-4e1b81e7","./S3MCompressType-4a5b4c24","./IndexDatatype-8a5eead4","./RuntimeError-4a5c8994","./BoundingRectangle-3ed8ca6d","./S3MPixelFormat-4f2b7689","./pako_inflate-f73548c4","./arrayFill-4513d7ad","./CompressedTextureBuffer-290a1ff4","./PixelFormat-fd637eac","./Math-119be1a3","./WebGLConstants-4ae0db90","./Event-16a2dfbf"],(function(t,e,r,a,n,A,o,i,B,E,C,s,y,d,l,f,u,P,c,p,T,L,D,g,F){"use strict";function M(t,e,r){if("function"==typeof t.slice)return t.slice(e,r);for(var n=Array.prototype.slice.call(t,e,r),A=a.FeatureDetection.typedArrayTypes,o=A.length,i=0;i=0){n.defined(l)||(r.nCompressOptions|=d.VertexCompressOption.SVC_Vertex);var L=e.GetAttribute(t,a.posUniqueID),D=v(t,e,L),g=D.data.componentsPerAttribute;r.verticesCount=D.array.length/g,r.vertCompressConstant=D.data.quantization.range/(1<3&&(r.minVerticesValue.w=F[3]);var M=r.verticesCount;if(s&&(f=new i.Cartographic,u=new i.Cartographic,P=new Float32Array(2*M),c=new Float64Array(2*M)),n.defined(l)){var m=D.array,I=3===g?i.Cartesian3.unpackArray(m):B.Cartesian4.unpackArray(m);for(let t=0,e=I.length;t=0){r.nCompressOptions|=d.VertexCompressOption.SVC_Normal;var w=e.GetAttribute(t,a.normalUniqueID),Y=v(t,e,w),J=Y.data.quantization;r.normalRangeConstant=(1<=0){r.nCompressOptions|=d.VertexCompressOption.SVC_VertexColor;var k=e.GetAttribute(t,a.colorUniqueID),W=v(t,e,k);T.aColor=p.length,p.push({index:T.aColor,typedArray:W.array,componentsPerAttribute:W.data.componentsPerAttribute,componentDatatype:W.data.componentDatatype,offsetInBytes:W.data.byteOffset,strideInBytes:W.data.byteStride,normalize:W.data.normalized})}for(V=0;V-1?H(e):n.defined(e.clampRegionEdge)?Y(e):t>=U.ClampGroundPolygon&&t<=U.ClampObjectLine?w(e):t==U.ClampGroundAndObjectLineCache?Y(e):V(e)},K.calcBoundingSphere=function(t,e,r){var a,A=t._fileType;return a=e.instanceIndex>-1?H(e):n.defined(e.clampRegionEdge)?Y(e):A>=U.ClampGroundPolygon&&A<=U.ClampObjectLine?w(e):A==U.ClampGroundAndObjectLineCache?Y(e):V(e),y.BoundingSphere.transform(a,r,a),a},K.calcBoundingRectangle=function(t,e){var r;return t._fileType===U.ClampGroundPolygon&&(r=function(t){var e,r,a=n.defined(t.nCompressOptions)&&(t.nCompressOptions&d.VertexCompressOption.SVC_Vertex)===d.VertexCompressOption.SVC_Vertex,A=new u.BoundingRectangle,B=t.vertexAttributes[0],E=B.componentsPerAttribute,C=1;a?(C=t.vertCompressConstant,r=new i.Cartesian3(t.minVerticesValue.x,t.minVerticesValue.y,t.minVerticesValue.z),e=new Uint16Array(B.typedArray.buffer,B.typedArray.byteOffset,B.typedArray.byteLength/2)):e=new Float32Array(B.typedArray.buffer,B.typedArray.byteOffset,B.typedArray.byteLength/4);for(var s=[],y=0;y=1&&(_=f[D][F-1]),0!=F&&(c[m-6]=_.x,c[m-5]=_.y,c[m-4]=_.z,c[m-3]=_.x,c[m-2]=_.y,c[m-1]=_.z),F!=g-1&&(c[m]=_.x,c[m+1]=_.y,c[m+2]=_.z,c[m+3]=_.x,c[m+4]=_.y,c[m+5]=_.z),m=2*M+8*F,0!=F&&(T[m-4]=-1,T[m-3]=-1,T[m-2]=1,T[m-1]=-1),F!=g-1&&(T[m]=-1,T[m+1]=1,T[m+2]=1,T[m+3]=1)}L+=f[D].length}var S={vertexAttributes:[],attrLocation:{}},O=S.vertexAttributes,N=S.attrLocation;S.instanceCount=0,S.instanceMode=0,N.aPosition=0,O.push({index:N.aPosition,typedArray:P,componentsPerAttribute:3,componentDatatype:C.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:3*Float32Array.BYTES_PER_ELEMENT,normalize:!1}),N.aNormal=1,O.push({index:N.aNormal,typedArray:c,componentsPerAttribute:3,componentDatatype:C.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:3*Float32Array.BYTES_PER_ELEMENT,normalize:!1}),N.aTexCoord0=2,O.push({index:N.aTexCoord0,typedArray:p,componentsPerAttribute:3,componentDatatype:C.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:3*Float32Array.BYTES_PER_ELEMENT,normalize:!1}),N.aTexCoord1=3,O.push({index:N.aTexCoord1,typedArray:T,componentsPerAttribute:2,componentDatatype:C.ComponentDatatype.BYTE,offsetInBytes:0,strideInBytes:2*Int8Array.BYTES_PER_ELEMENT,normalize:!1});for(var h=[],R=0;R65535?1:0,o.primitiveType=A.PrimitiveType.TRIANGLES,n=0===o.indexType?new Uint16Array(o.indicesCount):new Uint32Array(o.indicesCount);for(var i=0,B=0;B96?n-71:n>64?n-65:n>47?n+4:n>46?63:62}var A=0;for(a=0;a>E,y>>E);if(tt0){e.getUint16(o+r,!0),o+=Uint16Array.BYTES_PER_ELEMENT,o+=2*Uint8Array.BYTES_PER_ELEMENT;var B=i*Uint8Array.BYTES_PER_ELEMENT*4;A=M(t,o,o+B),o+=B;var E=n.vertexAttributes,s=n.attrLocation;s.aColor=E.length,E.push({index:s.aColor,typedArray:A,componentsPerAttribute:4,componentDatatype:C.ComponentDatatype.UNSIGNED_BYTE,offsetInBytes:0,strideInBytes:4,normalize:!0})}return{bytesOffset:o}}function Nt(t,e,r,a,n){var A=a,o=e.getUint32(A+r,!0);return A+=Uint32Array.BYTES_PER_ELEMENT,o<=0?{bytesOffset:A}:(e.getUint16(A+r,!0),A+=Uint16Array.BYTES_PER_ELEMENT,A+=2*Uint8Array.BYTES_PER_ELEMENT,{bytesOffset:A+=o*Uint8Array.BYTES_PER_ELEMENT*4})}function ht(t,e,r,a,n){var A=n,o=[],i=r.getUint32(A+a,!0);A+=Uint32Array.BYTES_PER_ELEMENT;for(var B=0;B0){var d=0,l=null;1===s||3===s?(d=C*Uint32Array.BYTES_PER_ELEMENT,l=e.subarray(A,A+d)):(d=C*Uint16Array.BYTES_PER_ELEMENT,l=e.subarray(A,A+d),C%2!=0&&(d+=2)),E.indicesTypedArray=l,A+=d}E.indicesCount=C,E.indexType=s,E.primitiveType=y;var f=[],u=r.getUint32(A+a,!0);A+=Uint32Array.BYTES_PER_ELEMENT;for(var P=0;P=2&&(e.getInt32(L+r,!0),L+=Int32Array.BYTES_PER_ELEMENT);var O,N={};N.posUniqueID=e.getInt32(L+r,!0),L+=Int32Array.BYTES_PER_ELEMENT,N.normalUniqueID=e.getInt32(L+r,!0),L+=Int32Array.BYTES_PER_ELEMENT,N.colorUniqueID=e.getInt32(L+r,!0),L+=Int32Array.BYTES_PER_ELEMENT,N.secondColorUniqueID=e.getInt32(L+r,!0),L+=Int32Array.BYTES_PER_ELEMENT,3===l?(O=e.getUint32(L+r,!0),L+=Int32Array.BYTES_PER_ELEMENT):(O=e.getUint16(L+r,!0),L+=Int16Array.BYTES_PER_ELEMENT);for(var h=[],R=0;R0){var Y=(J=Pt(e,r,T,L)).string;L=J.bytesOffset,w.materialCode=Y,V.push(w)}3===l&&((zt=(L+r)%4)&&(zt=4-zt),L+=zt);var J,k=new Object,W=e.getUint32(L+r,!0),Z=M(T,L+=Int32Array.BYTES_PER_ELEMENT,L+W);if(H>0?m.dracoDecodeMesh(at,Z,W,fe,w,N,g,P,k,p):m.dracoDecodePointCloud(at,Z,W,fe,N),n.defined(k.min)&&n.defined(k.max)||(k=void 0),L+=W,3===l)(zt=(L+r)%4)&&(zt=4-zt),(zt=((L=(J=Pt(e,r,T,L+=zt)).bytesOffset)+r)%4)&&(zt=4-zt),L+=zt;a[I]={vertexPackage:fe,arrIndexPackage:V,cartographicBounds:k}}else if(S==it&&3==l){var X=e.getUint32(L+r,!0);L+=Uint32Array.BYTES_PER_ELEMENT;var z=e.getUint32(L+r,!0);L+=Uint32Array.BYTES_PER_ELEMENT,fe.minVerticesValue=new B.Cartesian4,fe.minTexCoordValue=[new o.Cartesian2,new o.Cartesian2],fe.texCoordCompressConstant=[new i.Cartesian3,new i.Cartesian3];V=[];for(var j=0;j0){var Ot=e.getInt8(L+r,!0);L+=Int8Array.BYTES_PER_ELEMENT,e.getInt8(L+r,!0),L+=Int8Array.BYTES_PER_ELEMENT;var Nt=e.getInt8(L+r,!0);L+=Int8Array.BYTES_PER_ELEMENT,e.getInt8(L+r,!0),L+=Int8Array.BYTES_PER_ELEMENT;var bt,Ut,Kt=e.getInt32(L+r,!0);L+=Int32Array.BYTES_PER_ELEMENT,13!==Nt?(bt=new Uint8Array(e.buffer,L+r,Kt),L+=Uint8Array.BYTES_PER_ELEMENT*Kt):(bt=new Uint32Array(e.buffer,L+r,Kt),L+=Uint32Array.BYTES_PER_ELEMENT*Kt),(zt=(L+r)%4)&&(zt=4-zt),L+=zt,13!==Nt?(Ut=C.ComponentDatatype.createTypedArray(C.ComponentDatatype.UNSIGNED_BYTE,St*Uint32Array.BYTES_PER_ELEMENT),Q.decodeIndexBuffer(Ut,St,Uint32Array.BYTES_PER_ELEMENT,bt)):Ut=bt;var Ht,Vt=e.getInt32(L+r,!0);L+=Int32Array.BYTES_PER_ELEMENT,w.indexType=Ot,0===Ot?Ht=new Uint16Array(St):1===Ot&&(Ht=new Uint32Array(St)),w.indicesCount=St;var wt=new Uint32Array(Ut.buffer,Ut.byteOffset,Ut.byteLength/4);Ht.set(wt,0),w.indicesTypedArray=Ht,w.primitiveType=Nt;for(ut=0;ut0&&13!==Nt){var Wt=fe.preVertexCount;w.indicesTypedArray=wt.map((function(t){return t+Wt})),w.indexType=1}V.push(w),(zt=(L+r)%4)&&(zt=4-zt),L+=zt}}}fe.nCompressOptions=X,2===V.length&&13===V[1].primitiveType&&V[1].indicesCount>=3&&(Xt=d.S3MEdgeProcessor.createEdgeDataByIndices(fe,V[1],s)),n.defined(k.min)&&n.defined(k.max)||(k=void 0),a[I]={vertexPackage:fe,arrIndexPackage:V,edgeGeometry:Xt,cartographicBounds:k}}else{var Xt;if(S===ot||S===At)L=(kt=Gt(l,T,e,r,L,fe,E,g,P,p)).bytesOffset,k=kt.cartographicBounds;else if(S===it&&(L=(kt=Rt(T,e,r,L,fe,E,g,P,p)).bytesOffset,k=kt.cartographicBounds,3==l)){var Qt;L=(Qt=Pt(e,r,T,L)).bytesOffset,fe.customVertexAttribute=JSON.parse(Qt.string);var zt;gt="aCustom"+fe.customVertexAttribute.TextureCoordMatrix,Ft="aCustom"+fe.customVertexAttribute.VertexWeight,Mt="aCustom"+fe.customVertexAttribute.VertexWeight_1;n.defined(fe.attrLocation[gt])&&(fe.attrLocation.aTextureCoordMatrix=fe.attrLocation[gt],delete fe.attrLocation[gt]),n.defined(fe.attrLocation[Ft])&&(fe.attrLocation.aVertexWeight=fe.attrLocation[Ft],delete fe.attrLocation[Ft]),n.defined(fe.attrLocation[Mt])&&(fe.attrLocation.aVertexWeight_1=fe.attrLocation[Mt],delete fe.attrLocation[Mt]);var jt;for(mt=(jt=Object.keys(fe.attrLocation)).length,It=0;It=3&&(Xt=d.S3MEdgeProcessor.createEdgeDataByIndices(fe,V[1],s)),L=kt.bytesOffset,n.defined(k)&&n.defined(k.min)&&n.defined(k.max)||(k=void 0),a[I]={vertexPackage:fe,arrIndexPackage:V,edgeGeometry:Xt,cartographicBounds:k}}if(3!==l&&n.defined(y)&&y){var $t=e.getUint16(L+r,!0);if(L+=Uint16Array.BYTES_PER_ELEMENT,1===$t){var te=e.getUint32(L+r,!0);L+=Uint32Array.BYTES_PER_ELEMENT;var ee,re=e.getUint32(L+r,!0);L+=Uint32Array.BYTES_PER_ELEMENT,e.getFloat32(L+r,!0),L+=Float32Array.BYTES_PER_ELEMENT;var ae=new Array(te),ne=new Array(te),Ae=new Array(te),oe=new Array(te);for(ee=0;ee-1e-10}function ae(t,e,r,a,A,o,i,B){var E=new DataView(t),C=new Uint8Array(t),y=E.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;var d=s.getStringFromTypedArray(C,r,y);d=d.replace(/(\.s3mblock)|(\.s3mbz)|(\.s3mb)/gi,""),r+=y;var l=E.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(var f=0;f=3&&(E.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT),E.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;var m=E.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;var I=new Uint8Array(t,r,m),v=r+m,_=c.pako.inflate(I).buffer;B.push(_),E=new DataView(_);C=new Uint8Array(_);r=0;var S=E.getUint32(r,!0),O=ut(E,_,r+=Uint32Array.BYTES_PER_ELEMENT),N=O.buffer;r=O.byteOffset;var h=jt(M,N,E,O.dataViewByteOffset),R=r%4;0!==R&&(r+=4-R),kt((O=ut(E,_,r)).buffer,E,O.dataViewByteOffset,F,!1,void 0,void 0,M),r=O.byteOffset,3!==M&&((O=ut(E,_,r)).buffer,r=O.byteOffset);var G={};!function(t,e,r,a,A,o,i,B,E,C){var y=B,d=i.getUint32(y,!0);y+=Uint32Array.BYTES_PER_ELEMENT;for(var l={},f=0;fv[5]?v[4]:v[5];T={left:_,top:S,right:O,bottom:N,minHeight:h,maxHeight:R,width:(p=new ft(_,N,O,S,h,R)).width,length:p.length,height:p.height};var G=new Uint32Array(F,48+I,7),x=G[0],b=G[1],U=G[2],H=G[3];L={nFormat:x,nSideBlockCount:b,nBlockLength:U,nLength:H,nWidth:G[4],nHeight:G[5],nDepth:G[6],imageArray:new Uint8Array(F,76+I,H*H*4)}}}var V=0,w={};w.ignoreNormal=e.ignoreNormal;var Y=e.rootBatchIdMap||{},J=e.ancestorMap||{},k={},W=new DataView(a),Z=W.getFloat32(V,!0);if(V+=Float32Array.BYTES_PER_ELEMENT,C)return W.getUint32(V,!0),V+=Uint32Array.BYTES_PER_ELEMENT,ae(a,a.byteLength,V,Y,J,e.isRoot,k,r),k;var Q=!1;if(Z>=3&&(W.getUint32(V,!0),V+=Uint32Array.BYTES_PER_ELEMENT),Z>=2&&(W.getUint32(V,!0),V+=Uint32Array.BYTES_PER_ELEMENT),re(Z-1)||re(Z-2)||re(Z-3)||Z>2.09&&Z<2.11){var z=W.getUint32(V,!0);V+=Uint32Array.BYTES_PER_ELEMENT;var j=new Uint8Array(a,V,z);a=c.pako.inflate(j).buffer,r.push(a),W=new DataView(a),V=0}else if(Z>1.199&&Z<1.201){z=W.getUint32(V,!0);V+=Uint32Array.BYTES_PER_ELEMENT,r.push(a)}else{Q=!0,V=0;z=W.getInt32(V,!0);if(V+=Int32Array.BYTES_PER_ELEMENT,V+=Uint8Array.BYTES_PER_ELEMENT*z,o){W.getUint32(V,!0),V+=Uint32Array.BYTES_PER_ELEMENT;g=new Uint8Array(a,V);a=c.pako.inflate(g).buffer,r.push(a),W=new DataView(a),V=0}}var q=W.getUint32(V,!0),$=ut(W,a,V+=Uint32Array.BYTES_PER_ELEMENT),tt=$.buffer;V=$.byteOffset;var et={},rt=jt(Z,tt,W,$.dataViewByteOffset,et,u),at=V%4;0!==at&&(V+=4-at);var At=Z>2.09&&3!==Z;if(kt(($=ut(W,a,V)).buffer,W,$.dataViewByteOffset,w,Q,r,At,Z,y,et,f,e.fileType,u),V=$.byteOffset,At)for(var ot=0;otP.S3MPixelFormat.BGR||p===P.S3MPixelFormat.LUMINANCE_ALPHA?new Uint8Array(l*f*4):new Uint16Array(l*f),d.DXTTextureDecode.decode(L,l,f,T,p),A.push(L.buffer),u=0):L=T,n[C]={id:C,width:l,height:f,compressType:u,oriCompressType:D,nFormat:p,imageBuffer:L,mipmapLevel:y}}}(B,($=ut(W,a,V)).buffer,W,$.dataViewByteOffset,pt,r),V=$.byteOffset;var Tt=W.getUint32(V,!0);V+=Uint32Array.BYTES_PER_ELEMENT;var Lt=new Uint8Array(a).subarray(V,V+Tt),Dt=s.getStringFromTypedArray(Lt);V+=Tt,Dt=Dt.replace(/\n\0/,"");var gt=JSON.parse(Dt);(3===Z&&(q=W.getUint32(V,!0),V+=Uint32Array.BYTES_PER_ELEMENT),(q&nt)==nt)&&ee(($=ut(W,a,V)).buffer,W,$.dataViewByteOffset,w,Z);if(1==Z){var Ft=rt.pageLods,Mt=!0;for(ot=0;ot65535?new Uint32Array(s/2):new Uint16Array(s/2),u=0;for(E=0,C=o.length;E