bimland/public/Cesium/Workers/S3MTilesParser.js

2 lines
12 KiB
JavaScript
Raw Permalink Normal View History

2023-07-26 17:04:38 +08:00
define(["./createTaskProcessorWorker","./ComponentDatatype-c140a87d","./Color-5008547b","./getStringFromTypedArray-c37342c0","./S3MCompressType-555475e4","./Cartographic-3309dd0d","./PrimitiveType-a54dc62f","./pako_inflate-f73548c4","./when-b60132fc","./Check-7b2a090c","./WebGLConstants-4ae0db90","./FeatureDetection-c3b71206","./Math-119be1a3","./RuntimeError-4a5c8994","./IndexDatatype-8a5eead4","./Cartesian4-3ca25aab"],(function(t,e,r,n,a,i,o,E,s,y,p,T,u,l,c,A){"use strict";function d(t,e,r,n,a,i){this.left=t,this.bottom=e,this.right=r,this.top=n,this.minHeight=a,this.maxHeight=i,this.width=r-t,this.length=n-e,this.height=i-a}function v(t,r,n,E,s,y,p){var T=s.getUint32(y,!0);y+=Uint32Array.BYTES_PER_ELEMENT;var u=0,l={},c=l.vertexAttributes=[],A=l.attrLocation={};l.instanceCount=0,l.instanceMode=0;var d=0;s.getUint32(y,!0),y+=Uint32Array.BYTES_PER_ELEMENT;var v=s.getUint16(y,!0);y+=Uint32Array.BYTES_PER_ELEMENT;var _=v;v>4&&(_=v>>8,v&=15);var m=s.getUint32(y,!0);y+=Uint32Array.BYTES_PER_ELEMENT;var f=void 0,g=void 0;if(m>0){var B=s.getUint16(y,!0);B=v*Float32Array.BYTES_PER_ELEMENT,y+=Uint32Array.BYTES_PER_ELEMENT,u=m*B;var P=E.subarray(y,y+u);if(n){var U=new i.Cartesian3,L=new i.Cartesian3,h=new Float32Array(P.buffer,P.byteOffset,P.byteLength/4),M=new i.Cartographic;f=new i.Cartographic,g=new i.Cartographic;for(var S=new Float32Array(2*m),N=new Float64Array(2*m),R=0;R<m;R++)o.Matrix4.multiplyByPoint(r,i.Cartesian3.fromElements(h[3*R],h[3*R+1],h[3*R+2],U),L),M=i.Cartographic.fromCartesian(L),N[2*R]=M.longitude,N[2*R+1]=M.latitude,0===R?(f.longitude=M.longitude,f.latitude=M.latitude,g.longitude=M.longitude,g.latitude=M.latitude):(f.longitude=Math.max(M.longitude,f.longitude),f.latitude=Math.max(M.latitude,f.latitude),g.longitude=Math.min(M.longitude,g.longitude),g.latitude=Math.min(M.latitude,g.latitude));for(R=0;R<m;R++)S[2*R]=N[2*R]-g.longitude,S[2*R+1]=N[2*R+1]-g.latitude;A.img=d,c.push({index:A.img,typedArray:S,componentsPerAttribute:2,componentDatatype:e.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:2*Float32Array.BYTES_PER_ELEMENT,normalize:!1}),d++}A.aPosition=d,c.push({index:A.aPosition,typedArray:P,componentsPerAttribute:v,componentDatatype:e.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:B,normalize:!1}),d++,y+=u}var D=s.getUint32(y,!0);if(y+=Uint32Array.BYTES_PER_ELEMENT,D>0){var Y=s.getUint16(y,!0);Y=_*Float32Array.BYTES_PER_ELEMENT,y+=Uint32Array.BYTES_PER_ELEMENT,u=D*Y,t.ignoreNormal||(A.aNormal=d,c.push({index:A.aNormal,typedArray:E.subarray(y,y+u),componentsPerAttribute:_,componentDatatype:e.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:Y,normalize:!1}),d++),y+=u}var C=s.getUint32(y,!0);if(y+=Uint32Array.BYTES_PER_ELEMENT,C>0){var I=new Uint8Array(4*C);p.push(I.buffer);var b=s.getUint32(y,!0);b=4*Float32Array.BYTES_PER_ELEMENT,y+=Uint32Array.BYTES_PER_ELEMENT,u=C*b;for(var F=new Float32Array(E.buffer,y,4*m),x=0;x<m;x++)I[4*x]=255*F[4*x],I[4*x+1]=255*F[4*x+1],I[4*x+2]=255*F[4*x+2],I[4*x+3]=255*F[4*x+3];y+=u,A.aColor=d,c.push({index:A.aColor,typedArray:I,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.UNSIGNED_BYTE,offsetInBytes:0,strideInBytes:4,normalize:!0}),d++}var w=s.getUint32(y,!0);y+=Uint32Array.BYTES_PER_ELEMENT,w>0&&(y+=u=16*w);var O=s.getUint32(y,!0);y+=Uint32Array.BYTES_PER_ELEMENT;for(var k,z,G=-1,H=0;H<O;H++){k=s.getUint32(y,!0),y+=Uint32Array.BYTES_PER_ELEMENT,z=s.getUint16(y,!0),y+=Uint16Array.BYTES_PER_ELEMENT,s.getUint16(y,!0),y+=Uint16Array.BYTES_PER_ELEMENT,u=k*z*Float32Array.BYTES_PER_ELEMENT;var W,V=E.subarray(y,y+u);if(-1!=G||20!=z&&35!=z)if(-1!==G)l.instanceBounds=new Float32Array(E.buffer,y,k*z);else{var X="aTexCoord"+H;A[X]=d++,c.push({index:A[X],typedArray:V,componentsPerAttribute:z,componentDatatype:e.ComponentDatatype.FLOAT,offsetInBytes:0,strideInBytes:z*Float32Array.BYTES_PER_ELEMENT,normalize:!1})}else G=H,l.instanceCount=k,l.instanceMode=z,l.instanceBuffer=V,20===z?(W=20*Float32Array.BYTES_PER_ELEMENT,A.uv2=d++,c.push({index:A.uv2,componentsPerAttribute:4,componentDatatype:e.ComponentDatatype.FLOAT,normalize:!1,offsetInBytes:0,strideInB