月球大数据地理空间分析展示平台-【前端】-月球2期前端
Surpriseplus
2023-07-07 3c23ce2d0214a1246664e61fd51466033e25481e
public/CIMSDK/Workers/createVerticesFromQuantizedTerrainMesh.js
@@ -1 +1 @@
define(["./AxisAlignedBoundingBox-9efb5e58","./Matrix2-9599853a","./Matrix3-2b60b40d","./defaultValue-abec0268","./TerrainEncoding-245bc7b6","./IndexDatatype-5f9fa3ed","./Math-a56d1479","./Transforms-98e4fe15","./WebMercatorProjection-c25ac936","./createTaskProcessorWorker","./RuntimeError-279c39be","./AttributeCompression-8346a48c","./ComponentDatatype-565a8190","./WebGLConstants-292d99ef","./combine-7a07cedd"],(function(e,t,r,n,o,i,a,s,c,h,l,d,u,I,g){"use strict";function m(){s.DeveloperError.throwInstantiationError()}Object.defineProperties(m.prototype,{errorEvent:{get:s.DeveloperError.throwInstantiationError},credit:{get:s.DeveloperError.throwInstantiationError},tilingScheme:{get:s.DeveloperError.throwInstantiationError},ready:{get:s.DeveloperError.throwInstantiationError},readyPromise:{get:s.DeveloperError.throwInstantiationError},hasWaterMask:{get:s.DeveloperError.throwInstantiationError},hasVertexNormals:{get:s.DeveloperError.throwInstantiationError},availability:{get:s.DeveloperError.throwInstantiationError}});const f=[];m.getRegularGridIndices=function(e,t){let r=f[e];n.defined(r)||(f[e]=r=[]);let o=r[t];return n.defined(o)||(o=e*t<a.CesiumMath.SIXTY_FOUR_KILOBYTES?r[t]=new Uint16Array((e-1)*(t-1)*6):r[t]=new Uint32Array((e-1)*(t-1)*6),E(e,t,o,0)),o};const y=[];m.getRegularGridIndicesAndEdgeIndices=function(e,t){let r=y[e];n.defined(r)||(y[e]=r=[]);let o=r[t];if(!n.defined(o)){const n=m.getRegularGridIndices(e,t),i=p(e,t),a=i.westIndicesSouthToNorth,s=i.southIndicesEastToWest,c=i.eastIndicesNorthToSouth,h=i.northIndicesWestToEast;o=r[t]={indices:n,westIndicesSouthToNorth:a,southIndicesEastToWest:s,eastIndicesNorthToSouth:c,northIndicesWestToEast:h}}return o};const T=[];function p(e,t){const r=new Array(t),n=new Array(e),o=new Array(t),i=new Array(e);let a;for(a=0;a<e;++a)i[a]=a,n[a]=e*t-1-a;for(a=0;a<t;++a)o[a]=(a+1)*e-1,r[a]=(t-a-1)*e;return{westIndicesSouthToNorth:r,southIndicesEastToWest:n,eastIndicesNorthToSouth:o,northIndicesWestToEast:i}}function E(e,t,r,n){let o=0;for(let i=0;i<t-1;++i){for(let t=0;t<e-1;++t){const t=o,i=t+e,a=i+1,s=t+1;r[n++]=t,r[n++]=i,r[n++]=s,r[n++]=s,r[n++]=i,r[n++]=a,++o}++o}}function x(e,t,r,n){let o=e[0];const i=e.length;for(let a=1;a<i;++a){const i=e[a];r[n++]=o,r[n++]=i,r[n++]=t,r[n++]=t,r[n++]=i,r[n++]=t+1,o=i,++t}return n}m.getRegularGridAndSkirtIndicesAndEdgeIndices=function(e,t){let r=T[e];n.defined(r)||(T[e]=r=[]);let o=r[t];if(!n.defined(o)){const n=e*t,a=(e-1)*(t-1)*6,s=2*e+2*t,c=n+s,h=a+6*Math.max(0,s-4),l=p(e,t),d=l.westIndicesSouthToNorth,u=l.southIndicesEastToWest,I=l.eastIndicesNorthToSouth,g=l.northIndicesWestToEast,f=i.IndexDatatype.createTypedArray(c,h);E(e,t,f,0),m.addSkirtIndices(d,u,I,g,n,f,a),o=r[t]={indices:f,westIndicesSouthToNorth:d,southIndicesEastToWest:u,eastIndicesNorthToSouth:I,northIndicesWestToEast:g,indexCountWithoutSkirts:a}}return o},m.addSkirtIndices=function(e,t,r,n,o,i,a){let s=o;a=x(e,s,i,a),s+=e.length,a=x(t,s,i,a),s+=t.length,a=x(r,s,i,a),s+=r.length,x(n,s,i,a)},m.heightmapTerrainQuality=.25,m.getEstimatedLevelZeroGeometricErrorForAHeightmap=function(e,t,r){return 2*e.maximumRadius*Math.PI*m.heightmapTerrainQuality/(t*r)},m.prototype.requestTileGeometry=s.DeveloperError.throwInstantiationError,m.prototype.getLevelMaximumGeometricError=s.DeveloperError.throwInstantiationError,m.prototype.getTileDataAvailable=s.DeveloperError.throwInstantiationError,m.prototype.loadTileDataAvailability=s.DeveloperError.throwInstantiationError;const N=32767,w=new r.Cartesian3,M=new r.Cartesian3,b=new r.Cartesian3,S=new r.Cartographic,A=new t.Cartesian2,C=new r.Cartographic,W=[],v=[];function P(e,t){let r,n,o,i,a=0;const s=t.length;for(o=t[0],r=1;r<=s;r++)i=t[r%s],e[0]>Math.min(o[0],i[0])&&e[0]<=Math.max(o[0],i[0])&&e[1]<=Math.max(o[1],i[1])&&o[0]!==i[0]&&(n=(e[0]-o[0])*(i[1]-o[1])/(i[0]-o[0])+o[1],(o[1]===i[1]||e[1]<=n)&&a++),o=i;return a%2!=0}function k(e,t,r,n){const o=(e.x-r.x)*(t.y-r.y)-(e.y-r.y)*(t.x-r.x),i=(e.x-n.x)*(t.y-n.y)-(e.y-n.y)*(t.x-n.x);if(o*i>=0)return!1;const a=(r.x-e.x)*(n.y-e.y)-(r.y-e.y)*(n.x-e.x);if(a*(a+o-i)>=0)return!1;const s=a/(i-o),c=s*(t.x-e.x),h=s*(t.y-e.y);return{x:e.x+c,y:e.y+h}}function D(e,n,o,i,s,c,h,l,d){let u=Number.POSITIVE_INFINITY;const I=s.north,g=s.south;let m=s.east;const f=s.west;m<f&&(m+=a.CesiumMath.TWO_PI);const y=e.length;for(let s=0;s<y;++s){const y=e[s],T=o[y],p=i[y];S.longitude=a.CesiumMath.lerp(f,m,p.x),S.latitude=a.CesiumMath.lerp(g,I,p.y),S.height=T-n;const E=c.cartographicToCartesian(S,w);t.Matrix4.multiplyByPoint(h,E,E),r.Cartesian3.minimumByComponent(E,l,l),r.Cartesian3.maximumByComponent(E,d,d),u=Math.min(u,S.height)}return u}function F(e,t,r,o,i,s,h,l,d,u,I,g,m,f){const y=n.defined(h),T=d.north,p=d.south;let E=d.east;const x=d.west;E<x&&(E+=a.CesiumMath.TWO_PI);const N=r.length;for(let n=0;n<N;++n){const d=r[n],N=i[d],M=s[d];S.longitude=a.CesiumMath.lerp(x,E,M.x)+m,S.latitude=a.CesiumMath.lerp(p,T,M.y)+f,S.height=N-u;const b=l.cartographicToCartesian(S,w);if(y){const e=2*d;A.x=h[e],A.y=h[e+1]}let C,W;o.hasWebMercatorT&&(C=(c.WebMercatorProjection.geodeticLatitudeToMercatorAngle(S.latitude)-I)*g),o.hasGeodeticSurfaceNormals&&(W=l.geodeticSurfaceNormal(b)),t=o.encode(e,t,b,M,S.height,A,C,W,1)}}function H(e,t){let r;return"function"==typeof e.slice&&(r=e.slice(),"function"!=typeof r.sort&&(r=void 0)),n.defined(r)||(r=Array.prototype.slice.call(e)),r.sort(t),r}return h((function(h,l){const d=h.flattenPolygonHeight||[1],u=h.flattenPolygon||[];let I=-65565;const g=h.quantizedVertices,f=g.length/3,y=h.octEncodedNormals,T=h.westIndices.length+h.eastIndices.length+h.southIndices.length+h.northIndices.length,p=h.includeWebMercatorT,E=h.exaggeration,x=h.exaggerationRelativeHeight,_=1!==E,G=t.Rectangle.clone(h.rectangle),V=G.west,Y=G.south,O=G.east,B=G.north;W.length=0,v.length=0;let R=!1;const L=[[V,Y],[O,Y],[O,B],[V,B]];for(let e=0;e<d.length;e++)if(1!==d[e]){R=!1;for(let r=0;r<u[e].length;r++){const n=u[e][r];C.longitude=n[0],C.latitude=n[1],C.height=0;if(t.Rectangle.contains(G,C)){W.push(d[e]),v.push(u[e]),R=!0;break}}if(!R)for(let t=0;t<L.length;t++){if(P(L[t],u[e])){W.push(d[e]),v.push(u[e]),R=!0;break}}if(!R)for(let t=0;t<u[e].length-1;t++){for(let r=0;r<L.length-1;r++){if(k({x:L[r][0],y:L[r][1]},{x:L[r+1][0],y:L[r+1][1]},{x:u[e][t][0],y:u[e][t][1]},{x:u[e][t+1][0],y:u[e][t+1][1]})){W.push(d[e]),v.push(u[e]),R=!0;break}}if(R)break}}const j=r.Ellipsoid.clone(h.ellipsoid),U=h.minimumHeight;let z=h.maximumHeight;const q=h.relativeToCenter,Q=s.Transforms.eastNorthUpToFixedFrame(q,j),K=t.Matrix4.inverseTransformation(Q,new t.Matrix4);let X,Z;p&&(X=c.WebMercatorProjection.geodeticLatitudeToMercatorAngle(Y),Z=1/(c.WebMercatorProjection.geodeticLatitudeToMercatorAngle(B)-X));const J=g.subarray(0,f),$=g.subarray(f,2*f),ee=g.subarray(2*f,3*f),te=n.defined(y),re=new Array(f),ne=new Array(f),oe=new Array(f),ie=p?new Array(f):[],ae=_?new Array(f):[],se=M;se.x=Number.POSITIVE_INFINITY,se.y=Number.POSITIVE_INFINITY,se.z=Number.POSITIVE_INFINITY;const ce=b;ce.x=Number.NEGATIVE_INFINITY,ce.y=Number.NEGATIVE_INFINITY,ce.z=Number.NEGATIVE_INFINITY;let he=Number.POSITIVE_INFINITY,le=Number.NEGATIVE_INFINITY,de=Number.POSITIVE_INFINITY,ue=Number.NEGATIVE_INFINITY;for(let e=0;e<f;++e){const n=J[e],o=$[e],i=n/N,s=o/N;let h=a.CesiumMath.lerp(U,z,ee[e]/N);S.longitude=a.CesiumMath.lerp(V,O,i),S.latitude=a.CesiumMath.lerp(Y,B,s),S.height=h;for(let e=0;e<W.length;e++)if(1!==W[e]){P([S.longitude,S.latitude],v[e])&&(S.height=h=d[e],I=Math.max(I,d[e]))}he=Math.min(S.longitude,he),le=Math.max(S.longitude,le),de=Math.min(S.latitude,de),ue=Math.max(S.latitude,ue);const l=j.cartographicToCartesian(S);re[e]=new t.Cartesian2(i,s),ne[e]=h,oe[e]=l,p&&(ie[e]=(c.WebMercatorProjection.geodeticLatitudeToMercatorAngle(S.latitude)-X)*Z),_&&(ae[e]=j.geodeticSurfaceNormal(l)),t.Matrix4.multiplyByPoint(K,l,w),r.Cartesian3.minimumByComponent(w,se,se),r.Cartesian3.maximumByComponent(w,ce,ce)}-65565!==I&&(z=1.2*I);const Ie=H(h.westIndices,(function(e,t){return re[e].y-re[t].y})),ge=H(h.eastIndices,(function(e,t){return re[t].y-re[e].y})),me=H(h.southIndices,(function(e,t){return re[t].x-re[e].x})),fe=H(h.northIndices,(function(e,t){return re[e].x-re[t].x}));let ye;if(U<0){ye=new o.EllipsoidalOccluder(j).computeHorizonCullingPointPossiblyUnderEllipsoid(q,oe,U)}let Te=U;Te=Math.min(Te,D(h.westIndices,h.westSkirtHeight,ne,re,G,j,K,se,ce)),Te=Math.min(Te,D(h.southIndices,h.southSkirtHeight,ne,re,G,j,K,se,ce)),Te=Math.min(Te,D(h.eastIndices,h.eastSkirtHeight,ne,re,G,j,K,se,ce)),Te=Math.min(Te,D(h.northIndices,h.northSkirtHeight,ne,re,G,j,K,se,ce));const pe=new e.AxisAlignedBoundingBox(se,ce,q),Ee=new o.TerrainEncoding(q,pe,Te,z,Q,te,p,_,E,x),xe=Ee.stride,Ne=new Float32Array(f*xe+T*xe);let we=0;for(let e=0;e<f;++e){if(te){const t=2*e;A.x=y[t],A.y=y[t+1]}we=Ee.encode(Ne,we,oe[e],re[e],ne[e],A,ie[e],ae[e],0)}const Me=Math.max(0,2*(T-4)),be=h.indices.length+3*Me,Se=i.IndexDatatype.createTypedArray(f+T,be);Se.set(h.indices,0);const Ae=1e-4,Ce=(le-he)*Ae,We=(ue-de)*Ae,ve=-Ce,Pe=Ce,ke=We,De=-We;let Fe=f*xe;return F(Ne,Fe,Ie,Ee,ne,re,y,j,G,h.westSkirtHeight,X,Z,ve,0),Fe+=h.westIndices.length*xe,F(Ne,Fe,me,Ee,ne,re,y,j,G,h.southSkirtHeight,X,Z,0,De),Fe+=h.southIndices.length*xe,F(Ne,Fe,ge,Ee,ne,re,y,j,G,h.eastSkirtHeight,X,Z,Pe,0),Fe+=h.eastIndices.length*xe,F(Ne,Fe,fe,Ee,ne,re,y,j,G,h.northSkirtHeight,X,Z,0,ke),m.addSkirtIndices(Ie,me,ge,fe,f,Se,h.indices.length),l.push(Ne.buffer,Se.buffer),{vertices:Ne.buffer,indices:Se.buffer,westIndicesSouthToNorth:Ie,southIndicesEastToWest:me,eastIndicesNorthToSouth:ge,northIndicesWestToEast:fe,vertexStride:xe,center:q,minimumHeight:U,maximumHeight:z,occludeePointInScaledSpace:ye,encoding:Ee,indexCountWithoutSkirts:h.indices.length}}))}));
define(["./AxisAlignedBoundingBox-d1a0c6e6","./Matrix2-23dd5853","./Matrix3-6e56fbc7","./defaultValue-865ac579","./TerrainEncoding-1a72b96a","./IndexDatatype-16f6b4a1","./Math-76ce6367","./Transforms-f3654378","./WebMercatorProjection-ab4c1f3a","./createTaskProcessorWorker","./RuntimeError-9e0724f9","./AttributeCompression-b9d605fe","./ComponentDatatype-985dcc38","./WebGLConstants-258cf3a0","./combine-5e110d09"],(function(t,e,r,n,o,i,a,s,c,h,l,d,u,I,g){"use strict";function m(){s.DeveloperError.throwInstantiationError()}Object.defineProperties(m.prototype,{errorEvent:{get:s.DeveloperError.throwInstantiationError},credit:{get:s.DeveloperError.throwInstantiationError},tilingScheme:{get:s.DeveloperError.throwInstantiationError},ready:{get:s.DeveloperError.throwInstantiationError},readyPromise:{get:s.DeveloperError.throwInstantiationError},hasWaterMask:{get:s.DeveloperError.throwInstantiationError},hasVertexNormals:{get:s.DeveloperError.throwInstantiationError},availability:{get:s.DeveloperError.throwInstantiationError}});const f=[];m.getRegularGridIndices=function(t,e){let r=f[t];n.defined(r)||(f[t]=r=[]);let o=r[e];return n.defined(o)||(o=t*e<a.CesiumMath.SIXTY_FOUR_KILOBYTES?r[e]=new Uint16Array((t-1)*(e-1)*6):r[e]=new Uint32Array((t-1)*(e-1)*6),E(t,e,o,0)),o};const y=[];m.getRegularGridIndicesAndEdgeIndices=function(t,e){let r=y[t];n.defined(r)||(y[t]=r=[]);let o=r[e];if(!n.defined(o)){const n=m.getRegularGridIndices(t,e),i=p(t,e),a=i.westIndicesSouthToNorth,s=i.southIndicesEastToWest,c=i.eastIndicesNorthToSouth,h=i.northIndicesWestToEast;o=r[e]={indices:n,westIndicesSouthToNorth:a,southIndicesEastToWest:s,eastIndicesNorthToSouth:c,northIndicesWestToEast:h}}return o};const T=[];function p(t,e){const r=new Array(e),n=new Array(t),o=new Array(e),i=new Array(t);let a;for(a=0;a<t;++a)i[a]=a,n[a]=t*e-1-a;for(a=0;a<e;++a)o[a]=(a+1)*t-1,r[a]=(e-a-1)*t;return{westIndicesSouthToNorth:r,southIndicesEastToWest:n,eastIndicesNorthToSouth:o,northIndicesWestToEast:i}}function E(t,e,r,n){let o=0;for(let i=0;i<e-1;++i){for(let e=0;e<t-1;++e){const e=o,i=e+t,a=i+1,s=e+1;r[n++]=e,r[n++]=i,r[n++]=s,r[n++]=s,r[n++]=i,r[n++]=a,++o}++o}}function x(t,e,r,n){let o=t[0];const i=t.length;for(let a=1;a<i;++a){const i=t[a];r[n++]=o,r[n++]=i,r[n++]=e,r[n++]=e,r[n++]=i,r[n++]=e+1,o=i,++e}return n}m.getRegularGridAndSkirtIndicesAndEdgeIndices=function(t,e){let r=T[t];n.defined(r)||(T[t]=r=[]);let o=r[e];if(!n.defined(o)){const n=t*e,a=(t-1)*(e-1)*6,s=2*t+2*e,c=n+s,h=a+6*Math.max(0,s-4),l=p(t,e),d=l.westIndicesSouthToNorth,u=l.southIndicesEastToWest,I=l.eastIndicesNorthToSouth,g=l.northIndicesWestToEast,f=i.IndexDatatype.createTypedArray(c,h);E(t,e,f,0),m.addSkirtIndices(d,u,I,g,n,f,a),o=r[e]={indices:f,westIndicesSouthToNorth:d,southIndicesEastToWest:u,eastIndicesNorthToSouth:I,northIndicesWestToEast:g,indexCountWithoutSkirts:a}}return o},m.addSkirtIndices=function(t,e,r,n,o,i,a){let s=o;a=x(t,s,i,a),s+=t.length,a=x(e,s,i,a),s+=e.length,a=x(r,s,i,a),s+=r.length,x(n,s,i,a)},m.heightmapTerrainQuality=.25,m.getEstimatedLevelZeroGeometricErrorForAHeightmap=function(t,e,r){return 2*t.maximumRadius*Math.PI*m.heightmapTerrainQuality/(e*r)},m.prototype.requestTileGeometry=s.DeveloperError.throwInstantiationError,m.prototype.getLevelMaximumGeometricError=s.DeveloperError.throwInstantiationError,m.prototype.getTileDataAvailable=s.DeveloperError.throwInstantiationError,m.prototype.loadTileDataAvailability=s.DeveloperError.throwInstantiationError;const N=32767,w=new r.Cartesian3,M=new r.Cartesian3,b=new r.Cartesian3,S=new r.Cartographic,A=new e.Cartesian2,C=new r.Cartographic,W=[],v=[];function P(t,e){let r,n,o,i,a=0;const s=e.length;for(o=e[0],r=1;r<=s;r++)i=e[r%s],t[0]>Math.min(o[0],i[0])&&t[0]<=Math.max(o[0],i[0])&&t[1]<=Math.max(o[1],i[1])&&o[0]!==i[0]&&(n=(t[0]-o[0])*(i[1]-o[1])/(i[0]-o[0])+o[1],(o[1]===i[1]||t[1]<=n)&&a++),o=i;return a%2!=0}function k(t,e,r,n){const o=(t.x-r.x)*(e.y-r.y)-(t.y-r.y)*(e.x-r.x),i=(t.x-n.x)*(e.y-n.y)-(t.y-n.y)*(e.x-n.x);if(o*i>=0)return!1;const a=(r.x-t.x)*(n.y-t.y)-(r.y-t.y)*(n.x-t.x);if(a*(a+o-i)>=0)return!1;const s=a/(i-o),c=s*(e.x-t.x),h=s*(e.y-t.y);return{x:t.x+c,y:t.y+h}}function D(t,n,o,i,s,c,h,l,d){let u=Number.POSITIVE_INFINITY;const I=s.north,g=s.south;let m=s.east;const f=s.west;m<f&&(m+=a.CesiumMath.TWO_PI);const y=t.length;for(let s=0;s<y;++s){const y=t[s],T=o[y],p=i[y];S.longitude=a.CesiumMath.lerp(f,m,p.x),S.latitude=a.CesiumMath.lerp(g,I,p.y),S.height=T-n;const E=c.cartographicToCartesian(S,w);e.Matrix4.multiplyByPoint(h,E,E),r.Cartesian3.minimumByComponent(E,l,l),r.Cartesian3.maximumByComponent(E,d,d),u=Math.min(u,S.height)}return u}function F(t,e,r,o,i,s,h,l,d,u,I,g,m,f){const y=n.defined(h),T=d.north,p=d.south;let E=d.east;const x=d.west;E<x&&(E+=a.CesiumMath.TWO_PI);const N=r.length;for(let n=0;n<N;++n){const d=r[n],N=i[d],M=s[d];S.longitude=a.CesiumMath.lerp(x,E,M.x)+m,S.latitude=a.CesiumMath.lerp(p,T,M.y)+f,S.height=N-u;const b=l.cartographicToCartesian(S,w);if(y){const t=2*d;A.x=h[t],A.y=h[t+1]}let C,W;o.hasWebMercatorT&&(C=(c.WebMercatorProjection.geodeticLatitudeToMercatorAngle(S.latitude)-I)*g),o.hasGeodeticSurfaceNormals&&(W=l.geodeticSurfaceNormal(b)),e=o.encode(t,e,b,M,S.height,A,C,W,1)}}function H(t,e){let r;return"function"==typeof t.slice&&(r=t.slice(),"function"!=typeof r.sort&&(r=void 0)),n.defined(r)||(r=Array.prototype.slice.call(t)),r.sort(e),r}return h((function(h,l){const d=h.flattenPolygonHeight||[1],u=h.flattenPolygon||[];let I=-65565;const g=h.quantizedVertices,f=g.length/3,y=h.octEncodedNormals,T=h.westIndices.length+h.eastIndices.length+h.southIndices.length+h.northIndices.length,p=h.includeWebMercatorT,E=h.exaggeration,x=h.exaggerationRelativeHeight,_=1!==E,G=e.Rectangle.clone(h.rectangle),V=G.west,Y=G.south,O=G.east,B=G.north;W.length=0,v.length=0;let R=!1;const L=[[V,Y],[O,Y],[O,B],[V,B]];for(let t=0;t<d.length;t++)if(1!==d[t]){R=!1;for(let r=0;r<u[t].length;r++){const n=u[t][r];C.longitude=n[0],C.latitude=n[1],C.height=0;if(e.Rectangle.contains(G,C)){W.push(d[t]),v.push(u[t]),R=!0;break}}if(!R)for(let e=0;e<L.length;e++){if(P(L[e],u[t])){W.push(d[t]),v.push(u[t]),R=!0;break}}if(!R)for(let e=0;e<u[t].length-1;e++){for(let r=0;r<L.length-1;r++){if(k({x:L[r][0],y:L[r][1]},{x:L[r+1][0],y:L[r+1][1]},{x:u[t][e][0],y:u[t][e][1]},{x:u[t][e+1][0],y:u[t][e+1][1]})){W.push(d[t]),v.push(u[t]),R=!0;break}}if(R)break}}const j=r.Ellipsoid.clone(h.ellipsoid),U=h.minimumHeight;let z=h.maximumHeight;const q=h.relativeToCenter,Q=s.Transforms.eastNorthUpToFixedFrame(q,j),K=e.Matrix4.inverseTransformation(Q,new e.Matrix4);let X,Z;p&&(X=c.WebMercatorProjection.geodeticLatitudeToMercatorAngle(Y),Z=1/(c.WebMercatorProjection.geodeticLatitudeToMercatorAngle(B)-X));const J=g.subarray(0,f),$=g.subarray(f,2*f),tt=g.subarray(2*f,3*f),et=n.defined(y),rt=new Array(f),nt=new Array(f),ot=new Array(f),it=p?new Array(f):[],at=_?new Array(f):[],st=M;st.x=Number.POSITIVE_INFINITY,st.y=Number.POSITIVE_INFINITY,st.z=Number.POSITIVE_INFINITY;const ct=b;ct.x=Number.NEGATIVE_INFINITY,ct.y=Number.NEGATIVE_INFINITY,ct.z=Number.NEGATIVE_INFINITY;let ht=Number.POSITIVE_INFINITY,lt=Number.NEGATIVE_INFINITY,dt=Number.POSITIVE_INFINITY,ut=Number.NEGATIVE_INFINITY;for(let t=0;t<f;++t){const n=J[t],o=$[t],i=n/N,s=o/N;let h=a.CesiumMath.lerp(U,z,tt[t]/N);S.longitude=a.CesiumMath.lerp(V,O,i),S.latitude=a.CesiumMath.lerp(Y,B,s),S.height=h;for(let t=0;t<W.length;t++)if(1!==W[t]){P([S.longitude,S.latitude],v[t])&&(S.height=h=d[t],I=Math.max(I,d[t]))}ht=Math.min(S.longitude,ht),lt=Math.max(S.longitude,lt),dt=Math.min(S.latitude,dt),ut=Math.max(S.latitude,ut);const l=j.cartographicToCartesian(S);rt[t]=new e.Cartesian2(i,s),nt[t]=h,ot[t]=l,p&&(it[t]=(c.WebMercatorProjection.geodeticLatitudeToMercatorAngle(S.latitude)-X)*Z),_&&(at[t]=j.geodeticSurfaceNormal(l)),e.Matrix4.multiplyByPoint(K,l,w),r.Cartesian3.minimumByComponent(w,st,st),r.Cartesian3.maximumByComponent(w,ct,ct)}-65565!==I&&(z=1.2*I);const It=H(h.westIndices,(function(t,e){return rt[t].y-rt[e].y})),gt=H(h.eastIndices,(function(t,e){return rt[e].y-rt[t].y})),mt=H(h.southIndices,(function(t,e){return rt[e].x-rt[t].x})),ft=H(h.northIndices,(function(t,e){return rt[t].x-rt[e].x}));let yt;if(U<0){yt=new o.EllipsoidalOccluder(j).computeHorizonCullingPointPossiblyUnderEllipsoid(q,ot,U)}let Tt=U;Tt=Math.min(Tt,D(h.westIndices,h.westSkirtHeight,nt,rt,G,j,K,st,ct)),Tt=Math.min(Tt,D(h.southIndices,h.southSkirtHeight,nt,rt,G,j,K,st,ct)),Tt=Math.min(Tt,D(h.eastIndices,h.eastSkirtHeight,nt,rt,G,j,K,st,ct)),Tt=Math.min(Tt,D(h.northIndices,h.northSkirtHeight,nt,rt,G,j,K,st,ct));const pt=new t.AxisAlignedBoundingBox(st,ct,q),Et=new o.TerrainEncoding(q,pt,Tt,z,Q,et,p,_,E,x),xt=Et.stride,Nt=new Float32Array(f*xt+T*xt);let wt=0;for(let t=0;t<f;++t){if(et){const e=2*t;A.x=y[e],A.y=y[e+1]}wt=Et.encode(Nt,wt,ot[t],rt[t],nt[t],A,it[t],at[t],0)}const Mt=Math.max(0,2*(T-4)),bt=h.indices.length+3*Mt,St=i.IndexDatatype.createTypedArray(f+T,bt);St.set(h.indices,0);const At=1e-4,Ct=(lt-ht)*At,Wt=(ut-dt)*At,vt=-Ct,Pt=Ct,kt=Wt,Dt=-Wt;let Ft=f*xt;return F(Nt,Ft,It,Et,nt,rt,y,j,G,h.westSkirtHeight,X,Z,vt,0),Ft+=h.westIndices.length*xt,F(Nt,Ft,mt,Et,nt,rt,y,j,G,h.southSkirtHeight,X,Z,0,Dt),Ft+=h.southIndices.length*xt,F(Nt,Ft,gt,Et,nt,rt,y,j,G,h.eastSkirtHeight,X,Z,Pt,0),Ft+=h.eastIndices.length*xt,F(Nt,Ft,ft,Et,nt,rt,y,j,G,h.northSkirtHeight,X,Z,0,kt),m.addSkirtIndices(It,mt,gt,ft,f,St,h.indices.length),l.push(Nt.buffer,St.buffer),{vertices:Nt.buffer,indices:St.buffer,westIndicesSouthToNorth:It,southIndicesEastToWest:mt,eastIndicesNorthToSouth:gt,northIndicesWestToEast:ft,vertexStride:xt,center:q,minimumHeight:U,maximumHeight:z,occludeePointInScaledSpace:yt,encoding:Et,indexCountWithoutSkirts:h.indices.length}}))}));