1 line
7.6 KiB
JavaScript
1 line
7.6 KiB
JavaScript
define(["./AttributeCompression-af389d04","./Transforms-d13cc04e","./Matrix2-9aa31791","./when-4bbc8319","./TerrainEncoding-ba779f11","./IndexDatatype-b7d979a6","./RuntimeError-346a3079","./ComponentDatatype-93750d1a","./OrientedBoundingBox-4b932f63","./createTaskProcessorWorker","./combine-83860057","./WebGLConstants-1c8239cc","./EllipsoidTangentPlane-eecce7e8","./AxisAlignedBoundingBox-07c6b7f2","./IntersectionTests-96a04219","./Plane-318d6937"],(function(e,t,i,n,s,r,h,u,o,a,p,d,f,l,c,g){"use strict";var m=function(e,t,i,s,r,h){var u,o,a;n.defined(h)?h.length=0:h=[],t?(u=i<e,o=s<e,a=r<e):(u=i>e,o=s>e,a=r>e);var p,d,f,l,c,g,m=u+o+a;return 1===m?u?(p=(e-i)/(s-i),d=(e-i)/(r-i),h.push(1),h.push(2),1!==d&&(h.push(-1),h.push(0),h.push(2),h.push(d)),1!==p&&(h.push(-1),h.push(0),h.push(1),h.push(p))):o?(f=(e-s)/(r-s),l=(e-s)/(i-s),h.push(2),h.push(0),1!==l&&(h.push(-1),h.push(1),h.push(0),h.push(l)),1!==f&&(h.push(-1),h.push(1),h.push(2),h.push(f))):a&&(c=(e-r)/(i-r),g=(e-r)/(s-r),h.push(0),h.push(1),1!==g&&(h.push(-1),h.push(2),h.push(1),h.push(g)),1!==c&&(h.push(-1),h.push(2),h.push(0),h.push(c))):2===m?u||i===e?o||s===e?a||r===e||(d=(e-i)/(r-i),f=(e-s)/(r-s),h.push(2),h.push(-1),h.push(0),h.push(2),h.push(d),h.push(-1),h.push(1),h.push(2),h.push(f)):(g=(e-r)/(s-r),p=(e-i)/(s-i),h.push(1),h.push(-1),h.push(2),h.push(1),h.push(g),h.push(-1),h.push(0),h.push(1),h.push(p)):(l=(e-s)/(i-s),c=(e-r)/(i-r),h.push(0),h.push(-1),h.push(1),h.push(0),h.push(l),h.push(-1),h.push(2),h.push(0),h.push(c)):3!==m&&(h.push(0),h.push(1),h.push(2)),h},x=32767,v=16383,w=[],C=[],B=[],y=new i.Cartographic,I=new i.Cartesian3,b=[],A=[],z=[],M=[],N=[],V=new i.Cartesian3,E=new t.BoundingSphere,R=new o.OrientedBoundingBox,H=new i.Cartesian2,T=new i.Cartesian3;function O(){this.vertexBuffer=void 0,this.index=void 0,this.first=void 0,this.second=void 0,this.ratio=void 0}O.prototype.clone=function(e){return n.defined(e)||(e=new O),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},O.prototype.initializeIndexed=function(e,t,i,n,s){this.uBuffer=e,this.vBuffer=t,this.heightBuffer=i,this.normalBuffer=n,this.index=s,this.first=void 0,this.second=void 0,this.ratio=void 0},O.prototype.initializeFromClipResult=function(e,t,i){var n=t+1;return-1!==e[t]?i[e[t]].clone(this):(this.vertexBuffer=void 0,this.index=void 0,this.first=i[e[n]],++n,this.second=i[e[n]],++n,this.ratio=e[n],++n),n},O.prototype.getKey=function(){return this.isIndexed()?this.index:JSON.stringify({first:this.first.getKey(),second:this.second.getKey(),ratio:this.ratio})},O.prototype.isIndexed=function(){return n.defined(this.index)},O.prototype.getH=function(){return n.defined(this.index)?this.heightBuffer[this.index]:u.CesiumMath.lerp(this.first.getH(),this.second.getH(),this.ratio)},O.prototype.getU=function(){return n.defined(this.index)?this.uBuffer[this.index]:u.CesiumMath.lerp(this.first.getU(),this.second.getU(),this.ratio)},O.prototype.getV=function(){return n.defined(this.index)?this.vBuffer[this.index]:u.CesiumMath.lerp(this.first.getV(),this.second.getV(),this.ratio)};var U=new i.Cartesian2,F=-1,P=[new i.Cartesian3,new i.Cartesian3],S=[new i.Cartesian3,new i.Cartesian3];function D(t,n){++F;var s=P[F],r=S[F];return s=e.AttributeCompression.octDecode(t.first.getNormalX(),t.first.getNormalY(),s),r=e.AttributeCompression.octDecode(t.second.getNormalX(),t.second.getNormalY(),r),I=i.Cartesian3.lerp(s,r,t.ratio,I),i.Cartesian3.normalize(I,I),e.AttributeCompression.octEncode(I,n),--F,n}O.prototype.getNormalX=function(){return n.defined(this.index)?this.normalBuffer[2*this.index]:(U=D(this,U)).x},O.prototype.getNormalY=function(){return n.defined(this.index)?this.normalBuffer[2*this.index+1]:(U=D(this,U)).y};var W=[];function X(e,t,i,s,r,h,u,o,a){if(0!==u.length){for(var p=0,d=0;d<u.length;)d=W[p++].initializeFromClipResult(u,d,o);for(var f=0;f<p;++f){var l=W[f];if(l.isIndexed())l.newIndex=h[l.index],l.uBuffer=e,l.vBuffer=t,l.heightBuffer=i,a&&(l.normalBuffer=s);else{var c=l.getKey();if(n.defined(h[c]))l.newIndex=h[c];else{var g=e.length;e.push(l.getU()),t.push(l.getV()),i.push(l.getH()),a&&(s.push(l.getNormalX()),s.push(l.getNormalY())),l.newIndex=g,h[c]=g}}}3===p?(r.push(W[0].newIndex),r.push(W[1].newIndex),r.push(W[2].newIndex)):4===p&&(r.push(W[0].newIndex),r.push(W[1].newIndex),r.push(W[2].newIndex),r.push(W[0].newIndex),r.push(W[2].newIndex),r.push(W[3].newIndex))}}return W.push(new O),W.push(new O),W.push(new O),W.push(new O),a((function(e,n){var h=e.isEastChild,a=e.isNorthChild,p=h?v:0,d=h?x:v,f=a?v:0,l=a?x:v,c=b,g=A,U=z,F=N;c.length=0,g.length=0,U.length=0,F.length=0;var P=M;P.length=0;var S={},D=e.vertices,W=e.indices;W=W.subarray(0,e.indexCountWithoutSkirts);var k,K,Y,L,_,G=s.TerrainEncoding.clone(e.encoding),J=G.hasVertexNormals,Z=0,j=e.vertexCountWithoutSkirts,q=e.minimumHeight,Q=e.maximumHeight,$=new Array(j),ee=new Array(j),te=new Array(j),ie=J?new Array(2*j):void 0;for(K=0,Y=0;K<j;++K,Y+=2){var ne=G.decodeTextureCoordinates(D,K,H);if(k=G.decodeHeight(D,K),L=u.CesiumMath.clamp(ne.x*x|0,0,x),_=u.CesiumMath.clamp(ne.y*x|0,0,x),te[K]=u.CesiumMath.clamp((k-q)/(Q-q)*x|0,0,x),L<20&&(L=0),_<20&&(_=0),x-L<20&&(L=x),x-_<20&&(_=x),$[K]=L,ee[K]=_,J){var se=G.getOctEncodedNormal(D,K,T);ie[Y]=se.x,ie[Y+1]=se.y}(h&&L>=v||!h&&L<=v)&&(a&&_>=v||!a&&_<=v)&&(S[K]=Z,c.push(L),g.push(_),U.push(te[K]),J&&(F.push(ie[Y]),F.push(ie[Y+1])),++Z)}var re=[];re.push(new O),re.push(new O),re.push(new O);var he,ue=[];for(ue.push(new O),ue.push(new O),ue.push(new O),K=0;K<W.length;K+=3){var oe=W[K],ae=W[K+1],pe=W[K+2],de=$[oe],fe=$[ae],le=$[pe];re[0].initializeIndexed($,ee,te,ie,oe),re[1].initializeIndexed($,ee,te,ie,ae),re[2].initializeIndexed($,ee,te,ie,pe);var ce=m(v,h,de,fe,le,w);(he=0)>=ce.length||(he=ue[0].initializeFromClipResult(ce,he,re))>=ce.length||(he=ue[1].initializeFromClipResult(ce,he,re))>=ce.length||(he=ue[2].initializeFromClipResult(ce,he,re),X(c,g,U,F,P,S,m(v,a,ue[0].getV(),ue[1].getV(),ue[2].getV(),C),ue,J),he<ce.length&&(ue[2].clone(ue[1]),ue[2].initializeFromClipResult(ce,he,re),X(c,g,U,F,P,S,m(v,a,ue[0].getV(),ue[1].getV(),ue[2].getV(),C),ue,J)))}var ge=h?-32767:0,me=a?-32767:0,xe=[],ve=[],we=[],Ce=[],Be=Number.MAX_VALUE,ye=-Be,Ie=B;Ie.length=0;var be=i.Ellipsoid.clone(e.ellipsoid),Ae=i.Rectangle.clone(e.childRectangle),ze=Ae.north,Me=Ae.south,Ne=Ae.east,Ve=Ae.west;for(Ne<Ve&&(Ne+=u.CesiumMath.TWO_PI),K=0;K<c.length;++K)(L=Math.round(c[K]))<=p?(xe.push(K),L=0):L>=d?(we.push(K),L=x):L=2*L+ge,c[K]=L,(_=Math.round(g[K]))<=f?(ve.push(K),_=0):_>=l?(Ce.push(K),_=x):_=2*_+me,g[K]=_,(k=u.CesiumMath.lerp(q,Q,U[K]/x))<Be&&(Be=k),k>ye&&(ye=k),U[K]=k,y.longitude=u.CesiumMath.lerp(Ve,Ne,L/x),y.latitude=u.CesiumMath.lerp(Me,ze,_/x),y.height=k,be.cartographicToCartesian(y,I),Ie.push(I.x),Ie.push(I.y),Ie.push(I.z);var Ee=t.BoundingSphere.fromVertices(Ie,i.Cartesian3.ZERO,3,E),Re=o.OrientedBoundingBox.fromRectangle(Ae,Be,ye,be,R),He=new s.EllipsoidalOccluder(be).computeHorizonCullingPointFromVerticesPossiblyUnderEllipsoid(Ee.center,Ie,3,Ee.center,Be,V),Te=ye-Be,Oe=new Uint16Array(c.length+g.length+U.length);for(K=0;K<c.length;++K)Oe[K]=c[K];var Ue=c.length;for(K=0;K<g.length;++K)Oe[Ue+K]=g[K];for(Ue+=g.length,K=0;K<U.length;++K)Oe[Ue+K]=x*(U[K]-Be)/Te;var Fe,Pe=r.IndexDatatype.createTypedArray(c.length,P);if(J){var Se=new Uint8Array(F);n.push(Oe.buffer,Pe.buffer,Se.buffer),Fe=Se.buffer}else n.push(Oe.buffer,Pe.buffer);return{vertices:Oe.buffer,encodedNormals:Fe,indices:Pe.buffer,minimumHeight:Be,maximumHeight:ye,westIndices:xe,southIndices:ve,eastIndices:we,northIndices:Ce,boundingSphere:Ee,orientedBoundingBox:Re,horizonOcclusionPoint:He}}))})); |