Agriculture-front-end/public/Cesium/Workers/createVerticesFromQuantizedTerrainMesh.js
2023-04-16 22:33:44 +08:00

2 lines
10 KiB
JavaScript

define(["./AttributeCompression-90851096","./EllipsoidTangentPlane-edb321d3","./buildModuleUrl-4e1b81e7","./Cartesian2-47311507","./Cartographic-3309dd0d","./when-b60132fc","./TerrainEncoding-c4158481","./IndexDatatype-8a5eead4","./Math-119be1a3","./PrimitiveType-a54dc62f","./OrientedBoundingBox-87d59c2a","./Check-7b2a090c","./GeometryAttribute-3a88ba31","./WebMercatorProjection-01b1b5e7","./createTaskProcessorWorker","./Cartesian4-3ca25aab","./IntersectionTests-7386ffbf","./Plane-7ae8294c","./Event-16a2dfbf","./RuntimeError-4a5c8994","./ComponentDatatype-c140a87d","./WebGLConstants-4ae0db90","./PolygonPipeline-660e1625","./earcut-2.2.1-20c8012f","./EllipsoidRhumbLine-ed1a6bf4","./FeatureDetection-c3b71206"],(function(e,t,r,i,n,o,a,s,d,c,u,h,l,I,m,g,f,v,T,p,E,y,w,N,b,x){"use strict";function M(){h.DeveloperError.throwInstantiationError()}Object.defineProperties(M.prototype,{errorEvent:{get:h.DeveloperError.throwInstantiationError},credit:{get:h.DeveloperError.throwInstantiationError},tilingScheme:{get:h.DeveloperError.throwInstantiationError},ready:{get:h.DeveloperError.throwInstantiationError},readyPromise:{get:h.DeveloperError.throwInstantiationError},hasWaterMask:{get:h.DeveloperError.throwInstantiationError},hasVertexNormals:{get:h.DeveloperError.throwInstantiationError},availability:{get:h.DeveloperError.throwInstantiationError}});var C=[];M.getRegularGridIndices=function(e,t){var r=C[e];o.defined(r)||(C[e]=r=[]);var i=r[t];return o.defined(i)||W(e,t,i=e*t<d.CesiumMath.SIXTY_FOUR_KILOBYTES?r[t]=new Uint16Array((e-1)*(t-1)*6+3*(e+t-2)):r[t]=new Uint32Array((e-1)*(t-1)*6+3*(e+t-2)),0),i},M.getRegularGridIndicesForReproject=function(e,t){var r=C[e];o.defined(r)||(C[e]=r=[]);var i=r[t];return o.defined(i)||W(e,t,i=e*t<d.CesiumMath.SIXTY_FOUR_KILOBYTES?r[t]=new Uint16Array((e-1)*(t-1)*6):r[t]=new Uint32Array((e-1)*(t-1)*6),0),i};var A=[];M.getRegularGridIndicesAndEdgeIndices=function(e,t){var r=A[e];o.defined(r)||(A[e]=r=[]);var i=r[t];if(!o.defined(i)){var n=M.getRegularGridIndices(e,t),a=P(e,t),s=a.westIndicesSouthToNorth,d=a.southIndicesEastToWest,c=a.eastIndicesNorthToSouth,u=a.northIndicesWestToEast;i=r[t]={indices:n,westIndicesSouthToNorth:s,southIndicesEastToWest:d,eastIndicesNorthToSouth:c,northIndicesWestToEast:u}}return i};var S=[];function P(e,t){var r,i=new Array(t),n=new Array(e),o=new Array(t),a=new Array(e);for(r=0;r<e;++r)a[r]=r,n[r]=e*t-1-r;for(r=0;r<t;++r)o[r]=(r+1)*e-1,i[r]=(t-r-1)*e;return{westIndicesSouthToNorth:i,southIndicesEastToWest:n,eastIndicesNorthToSouth:o,northIndicesWestToEast:a}}function W(e,t,r,i){for(var n=0,o=0;o<t-1;++o){for(var a=0;a<e-1;++a){var s=n,d=s+e,c=d+1,u=s+1;r[i++]=s,r[i++]=d,r[i++]=u,r[i++]=u,r[i++]=d,r[i++]=c,++n}++n}var h=(t-1)/2,l=(e-1)/2;n=0;for(a=0;a<l;a++)r[i++]=n,r[i++]=n+1,r[i++]=n+2,n+=2;n=e*(t-1);for(a=0;a<l;a++)r[i++]=n+1,r[i++]=n,r[i++]=n+2,n+=2;n=0;for(a=0;a<h;a++)r[i++]=n+e,r[i++]=n,r[i++]=n+2*e,n+=2*e;n=e-1;for(a=0;a<h;a++)r[i++]=n,r[i++]=n+e,r[i++]=n+2*e,n+=2*e}function B(e,t,r,i,n){for(var a=o.defined(n),s=e[0],d=e.length,c=1;c<d;++c){var u=e[c];!a||n[s+"_"+u]?(r[i++]=s,r[i++]=u,r[i++]=t,r[i++]=t,r[i++]=u,r[i++]=t+1,s=u,++t):(s=u,++t)}return i}M.getRegularGridAndSkirtIndicesAndEdgeIndices=function(e,t){var r=S[e];o.defined(r)||(S[e]=r=[]);var i=r[t];if(!o.defined(i)){var n=e*t,a=(e-1)*(t-1)*6,d=2*e+2*t,c=n+d,u=3*(e+t-2),h=a+6*Math.max(0,d-4)+u,l=P(e,t),I=l.westIndicesSouthToNorth,m=l.southIndicesEastToWest,g=l.eastIndicesNorthToSouth,f=l.northIndicesWestToEast,v=s.IndexDatatype.createTypedArray(c,h);W(e,t,v,0),M.addSkirtIndices(I,m,g,f,n,v,a+u),i=r[t]={indices:v,westIndicesSouthToNorth:I,southIndicesEastToWest:m,eastIndicesNorthToSouth:g,northIndicesWestToEast:f,indexCountWithoutSkirts:a}}return i},M.addSkirtIndices=function(e,t,r,i,n,o,a,s){var d=n;a=B(e,d,o,a,s),a=B(t,d+=e.length,o,a,s),a=B(r,d+=t.length,o,a,s),B(i,d+=r.length,o,a,s)},M.heightmapTerrainQuality=.25,M.getEstimatedLevelZeroGeometricErrorForAHeightmap=function(e,t,r){return 2*e.maximumRadius*Math.PI*M.heightmapTerrainQuality/(t*r)},M.prototype.requestTileGeometry=h.DeveloperError.throwInstantiationError,M.prototype.getLevelMaximumGeometricError=h.DeveloperError.throwInstantiationError,M.prototype.getTileDataAvailable=h.DeveloperError.throwInstantiationError,M.prototype.loadTileDataAvailability=h.DeveloperError.throwInstantiationError;var _=32767,F=new n.Cartesian3,D=new n.Cartesian3,k=new n.Cartesian3,H=new n.Cartographic,O=new i.Cartesian2,V=new n.Cartesian3,G=new c.Matrix4,Y=new c.Matrix4;function R(e,t,r,i,o,a,s,u,h){var l=Number.POSITIVE_INFINITY,I=o.north,m=o.south,g=o.east,f=o.west;g<f&&(g+=d.CesiumMath.TWO_PI);for(var v=e.length,T=0;T<v;++T){var p=e[T],E=r[p],y=i[p];H.longitude=d.CesiumMath.lerp(f,g,y.x),H.latitude=d.CesiumMath.lerp(m,I,y.y),H.height=E-t;var w=a.cartographicToCartesian(H,F);c.Matrix4.multiplyByPoint(s,w,w),n.Cartesian3.minimumByComponent(w,u,u),n.Cartesian3.maximumByComponent(w,h,h),l=Math.min(l,H.height)}return l}function U(t,r,i,a,s,u,h,m,g,f,v,T,p,E,y){var w=o.defined(h),N=g.north,b=g.south,x=g.east,M=g.west;x<M&&(x+=d.CesiumMath.TWO_PI);for(var C=i.length,A=0;A<C;++A){var S=i[A],P=s[S],W=u[S];H.longitude=d.CesiumMath.lerp(M,x,W.x)+E,H.latitude=d.CesiumMath.lerp(b,N,W.y)+y,H.height=P-f;var B,_=m.cartographicToCartesian(H,F);if(w){var D=2*S;if(O.x=h[D],O.y=h[D+1],1!==v){var k=e.AttributeCompression.octDecode(O.x,O.y,V),R=l.Transforms.eastNorthUpToFixedFrame(F,m,Y),U=c.Matrix4.inverseTransformation(R,G);c.Matrix4.multiplyByPointAsVector(U,k,k),k.z*=v,n.Cartesian3.normalize(k,k),c.Matrix4.multiplyByPointAsVector(R,k,k),n.Cartesian3.normalize(k,k),e.AttributeCompression.octEncode(k,O)}}a.hasWebMercatorT&&(B=(I.WebMercatorProjection.geodeticLatitudeToMercatorAngle(H.latitude)-T)*p),r=a.encode(t,r,_,W,H.height,O,B)}}function z(e,t){var r;return"function"==typeof e.slice&&"function"!=typeof(r=e.slice()).sort&&(r=void 0),o.defined(r)||(r=Array.prototype.slice.call(e)),r.sort(t),r}return m((function(h,m){var g,f,v=h.quantizedVertices,T=v.length/3,p=h.octEncodedNormals,E=h.westIndices.length+h.eastIndices.length+h.southIndices.length+h.northIndices.length,y=h.includeWebMercatorT,w=i.Rectangle.clone(h.rectangle),N=w.west,b=w.south,x=w.east,C=w.north,A=i.Ellipsoid.clone(h.ellipsoid),S=h.exaggeration,P=h.minimumHeight*S,W=h.maximumHeight*S,B=o.defined(h.validMinimumHeight)?h.validMinimumHeight*S:P*S,L=o.defined(h.validMaximumHeight)?h.validMaximumHeight*S:W*S,j=h.relativeToCenter,q=l.Transforms.eastNorthUpToFixedFrame(j,A),K=c.Matrix4.inverseTransformation(q,new c.Matrix4);y&&(g=I.WebMercatorProjection.geodeticLatitudeToMercatorAngle(b),f=1/(I.WebMercatorProjection.geodeticLatitudeToMercatorAngle(C)-g));var Q=v.subarray(0,T),X=v.subarray(T,2*T),Z=v.subarray(2*T,3*T),J=o.defined(p),$=new Array(T),ee=new Array(T),te=new Array(T),re=y?new Array(T):[],ie=D;ie.x=Number.POSITIVE_INFINITY,ie.y=Number.POSITIVE_INFINITY,ie.z=Number.POSITIVE_INFINITY;var ne=k;ne.x=Number.NEGATIVE_INFINITY,ne.y=Number.NEGATIVE_INFINITY,ne.z=Number.NEGATIVE_INFINITY;for(var oe=Number.POSITIVE_INFINITY,ae=Number.NEGATIVE_INFINITY,se=Number.POSITIVE_INFINITY,de=Number.NEGATIVE_INFINITY,ce=0;ce<T;++ce){var ue=Q[ce],he=X[ce],le=ue/_,Ie=he/_,me=d.CesiumMath.lerp(P,W,Z[ce]/_);H.longitude=d.CesiumMath.lerp(N,x,le),H.latitude=d.CesiumMath.lerp(b,C,Ie),H.height=me,oe=Math.min(H.longitude,oe),ae=Math.max(H.longitude,ae),se=Math.min(H.latitude,se),de=Math.max(H.latitude,de);var ge=A.cartographicToCartesian(H);$[ce]=new i.Cartesian2(le,Ie),ee[ce]=me,te[ce]=ge,y&&(re[ce]=(I.WebMercatorProjection.geodeticLatitudeToMercatorAngle(H.latitude)-g)*f),c.Matrix4.multiplyByPoint(K,ge,F),n.Cartesian3.minimumByComponent(F,ie,ie),n.Cartesian3.maximumByComponent(F,ne,ne)}var fe,ve,Te=z(h.westIndices,(function(e,t){return $[e].y-$[t].y})),pe=z(h.eastIndices,(function(e,t){return $[t].y-$[e].y})),Ee=z(h.southIndices,(function(e,t){return $[t].x-$[e].x})),ye=z(h.northIndices,(function(e,t){return $[e].x-$[t].x}));ve=r.BoundingSphere.fromPoints(te),fe=u.OrientedBoundingBox.fromRectangle(w,P,W,A);var we,Ne=u.OrientedBoundingBox.fromRectangle(w,B,L,A);(1!==S||P<0)&&(we=new a.EllipsoidalOccluder(A).computeHorizonCullingPointPossiblyUnderEllipsoid(j,te,P));var be=P;be=Math.min(be,R(h.westIndices,h.westSkirtHeight,ee,$,w,A,K,ie,ne)),be=Math.min(be,R(h.southIndices,h.southSkirtHeight,ee,$,w,A,K,ie,ne)),be=Math.min(be,R(h.eastIndices,h.eastSkirtHeight,ee,$,w,A,K,ie,ne)),be=Math.min(be,R(h.northIndices,h.northSkirtHeight,ee,$,w,A,K,ie,ne));for(var xe=new t.AxisAlignedBoundingBox(ie,ne,j),Me=new a.TerrainEncoding(xe,be,W,q,J,y),Ce=Me.getStride(),Ae=new Float32Array(T*Ce+E*Ce),Se=0,Pe=0;Pe<T;++Pe){if(J){var We=2*Pe;if(O.x=p[We],O.y=p[We+1],1!==S){var Be=e.AttributeCompression.octDecode(O.x,O.y,V),_e=l.Transforms.eastNorthUpToFixedFrame(te[Pe],A,Y),Fe=c.Matrix4.inverseTransformation(_e,G);c.Matrix4.multiplyByPointAsVector(Fe,Be,Be),Be.z*=S,n.Cartesian3.normalize(Be,Be),c.Matrix4.multiplyByPointAsVector(_e,Be,Be),n.Cartesian3.normalize(Be,Be),e.AttributeCompression.octEncode(Be,O)}}Se=Me.encode(Ae,Se,te[Pe],$[Pe],ee[Pe],O,re[Pe])}var De=Math.max(0,2*(E-4)),ke=h.indices.length+3*De,He=s.IndexDatatype.createTypedArray(T+E,ke);He.set(h.indices,0);var Oe=1e-4,Ve=(ae-oe)*Oe,Ge=(de-se)*Oe,Ye=-Ve,Re=Ve,Ue=Ge,ze=-Ge,Le=T*Ce;U(Ae,Le,Te,Me,ee,$,p,A,w,h.westSkirtHeight,S,g,f,Ye,0),U(Ae,Le+=h.westIndices.length*Ce,Ee,Me,ee,$,p,A,w,h.southSkirtHeight,S,g,f,0,ze),U(Ae,Le+=h.southIndices.length*Ce,pe,Me,ee,$,p,A,w,h.eastSkirtHeight,S,g,f,Re,0),U(Ae,Le+=h.eastIndices.length*Ce,ye,Me,ee,$,p,A,w,h.northSkirtHeight,S,g,f,0,Ue);var je=function(e,t,r,i){if(i<12)return;for(var n={},o=e.length,a=0;a<o;a+=3){var s=e[a],d=e[a+1],c=e[a+2];(t[s]===_&&t[d]===_||0===t[s]&&0===t[d]||r[s]===_&&r[d]===_||0===r[s]&&0===r[d])&&(n[s+"_"+d]=1,n[d+"_"+s]=1),(t[d]===_&&t[c]===_||0===t[d]&&0===t[c]||r[d]===_&&r[c]===_||0===r[d]&&0===r[c])&&(n[d+"_"+c]=1,n[c+"_"+d]=1),(t[c]===_&&t[s]===_||0===t[c]&&0===t[s]||r[c]===_&&r[s]===_||0===r[c]&&0===r[s])&&(n[c+"_"+s]=1,n[s+"_"+c]=1)}return n}(h.indices,Q,X,h.level);return M.addSkirtIndices(Te,Ee,pe,ye,T,He,h.indices.length,je),m.push(Ae.buffer,He.buffer),{vertices:Ae.buffer,indices:He.buffer,westIndicesSouthToNorth:Te,southIndicesEastToWest:Ee,eastIndicesNorthToSouth:pe,northIndicesWestToEast:ye,vertexStride:Ce,center:j,minimumHeight:P,maximumHeight:W,boundingSphere:ve,orientedBoundingBox:fe,validOrientedBoundingBox:Ne,occludeePointInScaledSpace:we,encoding:Me,indexCountWithoutSkirts:h.indices.length}}))}));