qa-regulatory-gwj-vue/static/map/cesium91/CesiumUnminified/Workers/upsampleQuantizedTerrainMes...

2 lines
8.6 KiB
JavaScript

define(["./AttributeCompression-8f752c03","./BoundingSphere-9a3b5656","./Cartesian2-bd414876","./Cartesian3-e0307675","./defaultValue-81eec7ed","./TerrainEncoding-0f7ffc20","./IndexDatatype-3f3c99e8","./Check-741c5f3c","./Math-e73894ab","./OrientedBoundingBox-c5d2adb7","./Rectangle-cf3e0e3e","./createTaskProcessorWorker","./ComponentDatatype-aaeec80f","./WebGLConstants-508b9636","./Matrix4-4c545f70","./RuntimeError-26acdd3b","./Matrix2-dc0c61cc","./GeographicProjection-c931c7fb","./EllipsoidTangentPlane-4d138901","./AxisAlignedBoundingBox-8774439c","./IntersectionTests-80510c7b","./Plane-bc8b6777","./Transforms-5b829630","./when-422ea0ae","./Resource-8ae1a924","./combine-3c023bda"],(function(e,t,n,i,s,r,h,o,u,d,p,a,c,l,f,g,m,x,C,w,B,y,b,I,A,v){"use strict";const T={clipTriangleAtAxisAlignedThreshold:function(e,t,n,i,r,h){let o,u,d;s.defined(h)?h.length=0:h=[],t?(o=n<e,u=i<e,d=r<e):(o=n>e,u=i>e,d=r>e);const p=o+u+d;let a,c,l,f,g,m;return 1===p?o?(a=(e-n)/(i-n),c=(e-n)/(r-n),h.push(1),h.push(2),1!==c&&(h.push(-1),h.push(0),h.push(2),h.push(c)),1!==a&&(h.push(-1),h.push(0),h.push(1),h.push(a))):u?(l=(e-i)/(r-i),f=(e-i)/(n-i),h.push(2),h.push(0),1!==f&&(h.push(-1),h.push(1),h.push(0),h.push(f)),1!==l&&(h.push(-1),h.push(1),h.push(2),h.push(l))):d&&(g=(e-r)/(n-r),m=(e-r)/(i-r),h.push(0),h.push(1),1!==m&&(h.push(-1),h.push(2),h.push(1),h.push(m)),1!==g&&(h.push(-1),h.push(2),h.push(0),h.push(g))):2===p?o||n===e?u||i===e?d||r===e||(c=(e-n)/(r-n),l=(e-i)/(r-i),h.push(2),h.push(-1),h.push(0),h.push(2),h.push(c),h.push(-1),h.push(1),h.push(2),h.push(l)):(m=(e-r)/(i-r),a=(e-n)/(i-n),h.push(1),h.push(-1),h.push(2),h.push(1),h.push(m),h.push(-1),h.push(0),h.push(1),h.push(a)):(f=(e-i)/(n-i),g=(e-r)/(n-r),h.push(0),h.push(-1),h.push(1),h.push(0),h.push(f),h.push(-1),h.push(2),h.push(0),h.push(g)):3!==p&&(h.push(0),h.push(1),h.push(2)),h},computeBarycentricCoordinates:function(e,t,n,r,h,o,u,d,p){const a=n-u,c=u-h,l=o-d,f=r-d,g=1/(l*a+c*f),m=t-d,x=e-u,C=(l*x+c*m)*g,w=(-f*x+a*m)*g,B=1-C-w;return s.defined(p)?(p.x=C,p.y=w,p.z=B,p):new i.Cartesian3(C,w,B)},computeLineSegmentLineSegmentIntersection:function(e,t,i,r,h,o,u,d,p){const a=(d-o)*(i-e)-(u-h)*(r-t);if(0===a)return;const c=((u-h)*(t-o)-(d-o)*(e-h))/a,l=((i-e)*(t-o)-(r-t)*(e-h))/a;return c>=0&&c<=1&&l>=0&&l<=1?(s.defined(p)||(p=new n.Cartesian2),p.x=e+c*(i-e),p.y=t+c*(r-t),p):void 0}},M=32767,z=16383,V=[],N=[],R=[],E=new n.Cartographic;let H=new i.Cartesian3;const O=[],S=[],P=[],U=[],F=[],k=new i.Cartesian3,D=new t.BoundingSphere,W=new d.OrientedBoundingBox,X=new n.Cartesian2,K=new i.Cartesian3;function L(){this.vertexBuffer=void 0,this.index=void 0,this.first=void 0,this.second=void 0,this.ratio=void 0}L.prototype.clone=function(e){return s.defined(e)||(e=new L),e.uBuffer=this.uBuffer,e.vBuffer=this.vBuffer,e.heightBuffer=this.heightBuffer,e.normalBuffer=this.normalBuffer,e.index=this.index,e.first=this.first,e.second=this.second,e.ratio=this.ratio,e},L.prototype.initializeIndexed=function(e,t,n,i,s){this.uBuffer=e,this.vBuffer=t,this.heightBuffer=n,this.normalBuffer=i,this.index=s,this.first=void 0,this.second=void 0,this.ratio=void 0},L.prototype.initializeFromClipResult=function(e,t,n){let i=t+1;return-1!==e[t]?n[e[t]].clone(this):(this.vertexBuffer=void 0,this.index=void 0,this.first=n[e[i]],++i,this.second=n[e[i]],++i,this.ratio=e[i],++i),i},L.prototype.getKey=function(){return this.isIndexed()?this.index:JSON.stringify({first:this.first.getKey(),second:this.second.getKey(),ratio:this.ratio})},L.prototype.isIndexed=function(){return s.defined(this.index)},L.prototype.getH=function(){return s.defined(this.index)?this.heightBuffer[this.index]:u.CesiumMath.lerp(this.first.getH(),this.second.getH(),this.ratio)},L.prototype.getU=function(){return s.defined(this.index)?this.uBuffer[this.index]:u.CesiumMath.lerp(this.first.getU(),this.second.getU(),this.ratio)},L.prototype.getV=function(){return s.defined(this.index)?this.vBuffer[this.index]:u.CesiumMath.lerp(this.first.getV(),this.second.getV(),this.ratio)};let Y=new n.Cartesian2,G=-1;const _=[new i.Cartesian3,new i.Cartesian3],j=[new i.Cartesian3,new i.Cartesian3];function J(t,n){++G;let s=_[G],r=j[G];return s=e.AttributeCompression.octDecode(t.first.getNormalX(),t.first.getNormalY(),s),r=e.AttributeCompression.octDecode(t.second.getNormalX(),t.second.getNormalY(),r),H=i.Cartesian3.lerp(s,r,t.ratio,H),i.Cartesian3.normalize(H,H),e.AttributeCompression.octEncode(H,n),--G,n}L.prototype.getNormalX=function(){return s.defined(this.index)?this.normalBuffer[2*this.index]:(Y=J(this,Y),Y.x)},L.prototype.getNormalY=function(){return s.defined(this.index)?this.normalBuffer[2*this.index+1]:(Y=J(this,Y),Y.y)};const Z=[];function q(e,t,n,i,r,h,o,u,d){if(0===o.length)return;let p=0,a=0;for(;a<o.length;)a=Z[p++].initializeFromClipResult(o,a,u);for(let r=0;r<p;++r){const o=Z[r];if(o.isIndexed())o.newIndex=h[o.index],o.uBuffer=e,o.vBuffer=t,o.heightBuffer=n,d&&(o.normalBuffer=i);else{const r=o.getKey();if(s.defined(h[r]))o.newIndex=h[r];else{const s=e.length;e.push(o.getU()),t.push(o.getV()),n.push(o.getH()),d&&(i.push(o.getNormalX()),i.push(o.getNormalY())),o.newIndex=s,h[r]=s}}}3===p?(r.push(Z[0].newIndex),r.push(Z[1].newIndex),r.push(Z[2].newIndex)):4===p&&(r.push(Z[0].newIndex),r.push(Z[1].newIndex),r.push(Z[2].newIndex),r.push(Z[0].newIndex),r.push(Z[2].newIndex),r.push(Z[3].newIndex))}return Z.push(new L),Z.push(new L),Z.push(new L),Z.push(new L),a((function(e,s){const o=e.isEastChild,a=e.isNorthChild,c=o?z:0,l=o?M:z,f=a?z:0,g=a?M:z,m=O,x=S,C=P,w=F;m.length=0,x.length=0,C.length=0,w.length=0;const B=U;B.length=0;const y={},b=e.vertices;let I=e.indices;I=I.subarray(0,e.indexCountWithoutSkirts);const A=r.TerrainEncoding.clone(e.encoding),v=A.hasVertexNormals;let Y=0;const G=e.vertexCountWithoutSkirts,_=e.minimumHeight,j=e.maximumHeight,J=new Array(G),Z=new Array(G),Q=new Array(G),$=v?new Array(2*G):void 0;let ee,te,ne,ie,se;for(te=0,ne=0;te<G;++te,ne+=2){const e=A.decodeTextureCoordinates(b,te,X);if(ee=A.decodeHeight(b,te),ie=u.CesiumMath.clamp(e.x*M|0,0,M),se=u.CesiumMath.clamp(e.y*M|0,0,M),Q[te]=u.CesiumMath.clamp((ee-_)/(j-_)*M|0,0,M),ie<20&&(ie=0),se<20&&(se=0),M-ie<20&&(ie=M),M-se<20&&(se=M),J[te]=ie,Z[te]=se,v){const e=A.getOctEncodedNormal(b,te,K);$[ne]=e.x,$[ne+1]=e.y}(o&&ie>=z||!o&&ie<=z)&&(a&&se>=z||!a&&se<=z)&&(y[te]=Y,m.push(ie),x.push(se),C.push(Q[te]),v&&(w.push($[ne]),w.push($[ne+1])),++Y)}const re=[];re.push(new L),re.push(new L),re.push(new L);const he=[];let oe,ue;for(he.push(new L),he.push(new L),he.push(new L),te=0;te<I.length;te+=3){const e=I[te],t=I[te+1],n=I[te+2],i=J[e],s=J[t],r=J[n];re[0].initializeIndexed(J,Z,Q,$,e),re[1].initializeIndexed(J,Z,Q,$,t),re[2].initializeIndexed(J,Z,Q,$,n);const h=T.clipTriangleAtAxisAlignedThreshold(z,o,i,s,r,V);oe=0,oe>=h.length||(oe=he[0].initializeFromClipResult(h,oe,re),oe>=h.length||(oe=he[1].initializeFromClipResult(h,oe,re),oe>=h.length||(oe=he[2].initializeFromClipResult(h,oe,re),ue=T.clipTriangleAtAxisAlignedThreshold(z,a,he[0].getV(),he[1].getV(),he[2].getV(),N),q(m,x,C,w,B,y,ue,he,v),oe<h.length&&(he[2].clone(he[1]),he[2].initializeFromClipResult(h,oe,re),ue=T.clipTriangleAtAxisAlignedThreshold(z,a,he[0].getV(),he[1].getV(),he[2].getV(),N),q(m,x,C,w,B,y,ue,he,v)))))}const de=o?-32767:0,pe=a?-32767:0,ae=[],ce=[],le=[],fe=[];let ge=Number.MAX_VALUE,me=-ge;const xe=R;xe.length=0;const Ce=n.Ellipsoid.clone(e.ellipsoid),we=p.Rectangle.clone(e.childRectangle),Be=we.north,ye=we.south;let be=we.east;const Ie=we.west;for(be<Ie&&(be+=u.CesiumMath.TWO_PI),te=0;te<m.length;++te)ie=Math.round(m[te]),ie<=c?(ae.push(te),ie=0):ie>=l?(le.push(te),ie=M):ie=2*ie+de,m[te]=ie,se=Math.round(x[te]),se<=f?(ce.push(te),se=0):se>=g?(fe.push(te),se=M):se=2*se+pe,x[te]=se,ee=u.CesiumMath.lerp(_,j,C[te]/M),ee<ge&&(ge=ee),ee>me&&(me=ee),C[te]=ee,E.longitude=u.CesiumMath.lerp(Ie,be,ie/M),E.latitude=u.CesiumMath.lerp(ye,Be,se/M),E.height=ee,Ce.cartographicToCartesian(E,H),xe.push(H.x),xe.push(H.y),xe.push(H.z);const Ae=t.BoundingSphere.fromVertices(xe,i.Cartesian3.ZERO,3,D),ve=d.OrientedBoundingBox.fromRectangle(we,ge,me,Ce,W),Te=new r.EllipsoidalOccluder(Ce).computeHorizonCullingPointFromVerticesPossiblyUnderEllipsoid(Ae.center,xe,3,Ae.center,ge,k),Me=me-ge,ze=new Uint16Array(m.length+x.length+C.length);for(te=0;te<m.length;++te)ze[te]=m[te];let Ve=m.length;for(te=0;te<x.length;++te)ze[Ve+te]=x[te];for(Ve+=x.length,te=0;te<C.length;++te)ze[Ve+te]=M*(C[te]-ge)/Me;const Ne=h.IndexDatatype.createTypedArray(m.length,B);let Re;if(v){const e=new Uint8Array(w);s.push(ze.buffer,Ne.buffer,e.buffer),Re=e.buffer}else s.push(ze.buffer,Ne.buffer);return{vertices:ze.buffer,encodedNormals:Re,indices:Ne.buffer,minimumHeight:ge,maximumHeight:me,westIndices:ae,southIndices:ce,eastIndices:le,northIndices:fe,boundingSphere:Ae,orientedBoundingBox:ve,horizonOcclusionPoint:Te}}))}));