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

2 lines
10 KiB
JavaScript

define(["./createTaskProcessorWorker","./ComponentDatatype-c140a87d","./Color-5008547b","./S3MCompressType-4145c64c","./pako_inflate-f73548c4","./when-b60132fc","./Check-7b2a090c","./WebGLConstants-4ae0db90","./FeatureDetection-c3b71206","./Math-119be1a3","./RuntimeError-4a5c8994","./BoundingSphere-561b54d0","./Cartographic-3309dd0d","./Cartesian2-47311507","./Cartesian4-3ca25aab","./BoundingRectangle-01b3e970","./PrimitiveType-39acab88","./IndexDatatype-8a5eead4"],(function(t,e,n,r,a,i,E,o,s,y,T,p,A,_,u,v,c,B){"use strict";function f(t,e,n,r,a,i){this.left=t,this.bottom=e,this.right=n,this.top=r,this.minHeight=a,this.maxHeight=i,this.width=n-t,this.length=r-e,this.height=i-a}function m(t,n,r,a,i){var E=r.getUint32(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT;var o=0,s={},y=s.vertexAttributes=[],T=s.attrLocation={};s.instanceCount=0,s.instanceMode=0;var p=0;r.getUint32(a,!0),a+=Uint32Array.BYTES_PER_ELEMENT;var A=r.getUint16(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT;var _=A;A>4&&(_=A>>8,A&=15);var u=r.getUint32(a,!0);if(a+=Uint32Array.BYTES_PER_ELEMENT,u>0){var v=r.getUint16(a,!0);v=A*Float32Array.BYTES_PER_ELEMENT,a+=Uint32Array.BYTES_PER_ELEMENT,o=u*v,T.aPosition=p,y.push({index:T.aPosition,typedArray:n.subarray(a,a+o),componentsPerAttribute:A,componentDatatype:e.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:v,normalize:!1}),p++,a+=o}var c=r.getUint32(a,!0);if(a+=Uint32Array.BYTES_PER_ELEMENT,c>0){var B=r.getUint16(a,!0);B=_*Float32Array.BYTES_PER_ELEMENT,a+=Uint32Array.BYTES_PER_ELEMENT,o=c*B,t.ignoreNormal||(T.aNormal=p,y.push({index:T.aNormal,typedArray:n.subarray(a,a+o),componentsPerAttribute:_,componentDatatype:e.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:B,normalize:!1}),p++),a+=o}var f=r.getUint32(a,!0);if(a+=Uint32Array.BYTES_PER_ELEMENT,f>0){var m=new Uint8Array(4*f);i.push(m.buffer);var l=r.getUint32(a,!0);l=4*Float32Array.BYTES_PER_ELEMENT,a+=Uint32Array.BYTES_PER_ELEMENT,o=f*l;for(var U=new Float32Array(n.buffer,a,4*u),P=0;P<u;P++)m[4*P]=255*U[4*P],m[4*P+1]=255*U[4*P+1],m[4*P+2]=255*U[4*P+2],m[4*P+3]=255*U[4*P+3];a+=o,T.aColor=p,y.push({index:T.aColor,typedArray:m,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.UNSIGNED_BYTE,offsetInBytes:0,strideInBytes:4,normalize:!0}),p++}var d=r.getUint32(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT,d>0&&(a+=o=16*d);var g=r.getUint32(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT;for(var L,N,M=-1,S=0;S<g;S++){L=r.getUint32(a,!0),a+=Uint32Array.BYTES_PER_ELEMENT,N=r.getUint16(a,!0),a+=Uint16Array.BYTES_PER_ELEMENT,r.getUint16(a,!0),a+=Uint16Array.BYTES_PER_ELEMENT,o=L*N*Float32Array.BYTES_PER_ELEMENT;var h,R=n.subarray(a,a+o);if(-1!=M||20!=N&&35!=N)if(-1!==M)s.instanceBounds=new Float32Array(n.buffer,a,L*N);else{var Y="aTexCoord"+S;T[Y]=p++,y.push({index:T[Y],typedArray:R,componentsPerAttribute:N,componentDatatype:e.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:N*Float32Array.BYTES_PER_ELEMENT,normalize:!1})}else M=S,s.instanceCount=L,s.instanceMode=N,s.instanceBuffer=R,20===N?(h=20*Float32Array.BYTES_PER_ELEMENT,T.uv2=p++,y.push({index:T.uv2,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:0,strideInBytes:h,instanceDivisor:1}),T.uv3=p++,y.push({index:T.uv3,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:4*Float32Array.BYTES_PER_ELEMENT,strideInBytes:h,instanceDivisor:1}),T.uv4=p++,y.push({index:T.uv4,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:8*Float32Array.BYTES_PER_ELEMENT,strideInBytes:h,instanceDivisor:1}),T.secondary_colour=p++,y.push({index:T.secondary_colour,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:12*Float32Array.BYTES_PER_ELEMENT,strideInBytes:h,instanceDivisor:1}),T.uv6=p++,y.push({index:T.uv6,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:16*Float32Array.BYTES_PER_ELEMENT,strideInBytes:h,instanceDivisor:1})):35===N&&(h=35*Float32Array.BYTES_PER_ELEMENT,T.uv1=p++,y.push({index:T.uv1,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:0,strideInBytes:h,instanceDivisor:1,byteLength:o}),T.uv2=p++,y.push({index:T.uv2,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:4*Float32Array.BYTES_PER_ELEMENT,strideInBytes:h,instanceDivisor:1}),T.uv3=p++,y.push({index:T.uv3,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:8*Float32Array.BYTES_PER_ELEMENT,strideInBytes:h,instanceDivisor:1}),T.uv4=p++,y.push({index:T.uv4,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:12*Float32Array.BYTES_PER_ELEMENT,strideInBytes:h,instanceDivisor:1}),T.uv5=p++,y.push({index:T.uv5,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:16*Float32Array.BYTES_PER_ELEMENT,strideInBytes:h,instanceDivisor:1}),T.uv6=p++,y.push({index:T.uv6,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:20*Float32Array.BYTES_PER_ELEMENT,strideInBytes:h,instanceDivisor:1}),T.uv7=p++,y.push({index:T.uv7,componentsPerAttribute:3,componentDatatype:e.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:24*Float32Array.BYTES_PER_ELEMENT,strideInBytes:h,instanceDivisor:1}),T.secondary_colour=p++,y.push({index:T.secondary_colour,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:27*Float32Array.BYTES_PER_ELEMENT,strideInBytes:h,instanceDivisor:1}),T.uv9=p++,y.push({index:T.uv9,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:31*Float32Array.BYTES_PER_ELEMENT,strideInBytes:h,instanceDivisor:1}));a+=o}s.verticesCount=u,s.instanceIndex=M;var D=r.getUint32(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT;var b=[];for(S=0;S<D;S++){var I={},C=r.getUint32(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT;var F=r.getUint8(a,!0);a+=Uint8Array.BYTES_PER_ELEMENT,r.getUint8(a,!0),a+=Uint8Array.BYTES_PER_ELEMENT;var x=r.getUint8(a,!0);a+=Uint8Array.BYTES_PER_ELEMENT,a+=1,I.indicesCount=C,I.indexType=F,I.primitiveType=x;var w=a;C>0&&(0==F?(a+=o=C*Uint16Array.BYTES_PER_ELEMENT,C%2==1&&(a+=2)):a+=o=4*C),I.indicesTypedArray=n.subarray(w,w+o);var k=r.getUint32(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT;var O=r.getUint32(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT*k,I.materialCode=O,b.push(I)}return t[E]={vertexPackage:s,arrIndexPackage:b},a}function l(t,n,r){var a=t.vertexAttributes,i=t.attrLocation,E=a.length;i[1===r?"instanceId":"batchId"]=E,a.push({index:E,typedArray:n,componentsPerAttribute:1,componentDatatype:e.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:0,instanceDivisor:r})}return new n.Color,t((function(t,e){var n=t.buffer,i=t.supportCompressType,E=t.bVolume,o=null,s=null,y=null;if(E&&t.volbuffer.byteLength<8&&(E=!1),E){var T=t.volbuffer,p=new Uint8Array(T,8),A=a.pako.inflate(p).buffer,_=new Float64Array(A,0,1),u=new Uint32Array(A,48,1);if(0===_[0]||3200===u[0]||3201===u[0]){var v=0;0===_[0]&&(v=8),e.push(A);var c=new Float64Array(A,v,6),B=c[0],U=c[1],P=c[2],d=c[3],g=c[4]<c[5]?c[4]:c[5],L=c[4]>c[5]?c[4]:c[5];s={left:B,top:U,right:P,bottom:d,minHeight:g,maxHeight:L,width:(o=new f(B,d,P,U,g,L)).width,length:o.length,height:o.height};var N=new Uint32Array(A,48+v,7),M=N[0],S=N[1],h=N[2],R=N[3];y={nFormat:M,nSideBlockCount:S,nBlockLength:h,nLength:R,nWidth:N[4],nHeight:N[5],nDepth:N[6],imageArray:new Uint8Array(A,76+v,R*R*4)}}}var Y=0,D=new Uint8Array(n,0,4);if(115!==D[0]||51!==D[1]||109!==D[2])return{result:!1};var b=D[3],I=(p=new Uint8Array(n,4),a.pako.inflate(p).buffer),C=new Uint8Array(I);e.push(C.buffer);var F=new DataView(I),x=F.getUint32(Y,!0);Y+=Uint32Array.BYTES_PER_ELEMENT;var w=new Uint8Array(I,Y,x),k=x%4;k&&(k=4-k),Y+=x+k;var O=r.getStringFromTypedArray(w,void 0,void 0,"gbk");O=(O=O.replace(new RegExp("\r\n","gm"),"")).replace(new RegExp(":","gm"),""),F.getUint32(Y,!0),Y+=Uint32Array.BYTES_PER_ELEMENT;var z=F.getUint32(Y,!0);Y+=Uint32Array.BYTES_PER_ELEMENT;var H={};H.ignoreNormal=t.ignoreNormal;for(var G=0;G<z;G++)Y=m(H,C,F,Y,e);F.getUint32(Y,!0),Y+=Uint32Array.BYTES_PER_ELEMENT;var W=F.getUint32(Y,!0);for(Y+=Uint32Array.BYTES_PER_ELEMENT,G=0;G<W;G++){var V=F.getUint32(Y,!0);Y+=Uint32Array.BYTES_PER_ELEMENT;var X=F.getUint32(Y,!0);Y+=Uint32Array.BYTES_PER_ELEMENT;var j={};if(-1==H[V].vertexPackage.instanceIndex){for(var q=new Float32Array(H[V].vertexPackage.verticesCount),J=0;J<X;J++){var K=F.getUint32(Y,!0);Y+=Uint32Array.BYTES_PER_ELEMENT;var Q=F.getUint32(Y,!0);Y+=Uint32Array.BYTES_PER_ELEMENT;var Z=0,$=0;j[K]={batchId:J};for(var tt=0;tt<Q;tt++)if($=F.getUint32(Y,!0),Y+=Uint32Array.BYTES_PER_ELEMENT,Z=F.getUint32(Y,!0),Y+=Uint32Array.BYTES_PER_ELEMENT,q.fill)q.fill(J,$,$+Z);else for(var et=$+$,nt=$;nt<et;nt++)q[nt]=J;j[K].vertexColorOffset=$,j[K].vertexColorCount=Z}l(H[V].vertexPackage,q,void 0)}else{var rt=H[V].vertexPackage.instanceCount;H[V].vertexPackage.instanceBuffer,H[V].vertexPackage.instanceMode;var at=new Float32Array(rt),it=0;for(J=0;J<X;J++){K=F.getUint32(Y,!0);Y+=Uint32Array.BYTES_PER_ELEMENT;Q=F.getUint32(Y,!0);Y+=Uint32Array.BYTES_PER_ELEMENT;for(tt=0;tt<Q;tt++){var Et=F.getUint32(Y,!0);Y+=Uint32Array.BYTES_PER_ELEMENT,at[it]=it,void 0===j[K]&&(j[K]={vertexColorCount:1,instanceIds:[],vertexColorOffset:it}),j[K].instanceIds.push(Et),it++}}l(H[V].vertexPackage,at,1)}H[V].pickInfo=j}F.getUint32(Y,!0),Y+=Uint32Array.BYTES_PER_ELEMENT;var ot=F.getUint32(Y,!0);Y+=Uint32Array.BYTES_PER_ELEMENT;var st={};for(G=0;G<ot;G++){var yt=F.getUint32(Y,!0);Y+=Uint32Array.BYTES_PER_ELEMENT;var Tt=F.getUint32(Y,!0);Y+=Uint32Array.BYTES_PER_ELEMENT;var pt=F.getUint32(Y,!0);Y+=Uint32Array.BYTES_PER_ELEMENT;var At=F.getUint32(Y,!0);Y+=Uint32Array.BYTES_PER_ELEMENT;Q=F.getUint32(Y,!0);Y+=Uint32Array.BYTES_PER_ELEMENT;var _t=F.getUint32(Y,!0);Y+=Uint32Array.BYTES_PER_ELEMENT;var ut=null;if(At===r.S3MCompressType.enrS3TCDXTN&&1!==i){var vt=null;_t>r.S3MPixelFormat.BGR||_t===r.S3MPixelFormat.LUMINANCE_ALPHA?(vt=new Uint8Array(I,Y,Tt*pt),ut=new Uint8Array(Tt*pt*4)):(vt=new Uint16Array(I,Y,Q/2),ut=new Uint16Array(Tt*pt)),r.DXTTextureDecode.decode(ut,Tt,pt,vt,_t),e.push(ut.buffer),At=0}else ut=new Uint8Array(I,Y,Q);st[yt]={id:yt,width:Tt,height:pt,compressType:At,nFormat:_t,imageBuffer:ut},Y+=Q}return{result:!0,version:b,xmlDoc:O,geoPackage:H,texturePackage:st,volImageBuffer:y,volBounds:s}}))}));