2 lines
9.2 KiB
JavaScript
2 lines
9.2 KiB
JavaScript
/* 2020-9-22 15:23:25 | 版权所有 军懋国兴 */
|
|
define(["./when-cbf8cd21","./Check-35e1a91d","./Math-69007a69","./Cartesian2-43e3a3be","./Transforms-2d1ac5ec","./RuntimeError-f4c64df1","./WebGLConstants-95ceb4e9","./ComponentDatatype-607c9a0c","./AttributeCompression-ea810287","./IndexDatatype-79bb407c","./IntersectionTests-459f6f08","./Plane-46b5436f","./createTaskProcessorWorker","./EllipsoidTangentPlane-b5927ee3","./OrientedBoundingBox-5e0b7a7c","./TerrainEncoding-848fa40b"],function(v,C,ce,ge,me,e,i,r,n,we,t,s,h,u,xe,ve){"use strict";var Ce={clipTriangleAtAxisAlignedThreshold:function(e,i,r,t,n,s){if(!v.defined(e))throw new C.DeveloperError("threshold is required.");if(!v.defined(i))throw new C.DeveloperError("keepAbove is required.");if(!v.defined(r))throw new C.DeveloperError("u0 is required.");if(!v.defined(t))throw new C.DeveloperError("u1 is required.");if(!v.defined(n))throw new C.DeveloperError("u2 is required.");var h,u,o;v.defined(s)?s.length=0:s=[],o=i?(h=r<e,u=t<e,n<e):(h=e<r,u=e<t,e<n);var d,p,a,f,l,c,g=h+u+o;return 1===g?h?(d=(e-r)/(t-r),p=(e-r)/(n-r),s.push(1),s.push(2),1!==p&&(s.push(-1),s.push(0),s.push(2),s.push(p)),1!==d&&(s.push(-1),s.push(0),s.push(1),s.push(d))):u?(a=(e-t)/(n-t),f=(e-t)/(r-t),s.push(2),s.push(0),1!==f&&(s.push(-1),s.push(1),s.push(0),s.push(f)),1!==a&&(s.push(-1),s.push(1),s.push(2),s.push(a))):o&&(l=(e-n)/(r-n),c=(e-n)/(t-n),s.push(0),s.push(1),1!==c&&(s.push(-1),s.push(2),s.push(1),s.push(c)),1!==l&&(s.push(-1),s.push(2),s.push(0),s.push(l))):2===g?h||r===e?u||t===e?o||n===e||(p=(e-r)/(n-r),a=(e-t)/(n-t),s.push(2),s.push(-1),s.push(0),s.push(2),s.push(p),s.push(-1),s.push(1),s.push(2),s.push(a)):(c=(e-n)/(t-n),d=(e-r)/(t-r),s.push(1),s.push(-1),s.push(2),s.push(1),s.push(c),s.push(-1),s.push(0),s.push(1),s.push(d)):(f=(e-t)/(r-t),l=(e-n)/(r-n),s.push(0),s.push(-1),s.push(1),s.push(0),s.push(f),s.push(-1),s.push(2),s.push(0),s.push(l)):3!==g&&(s.push(0),s.push(1),s.push(2)),s},computeBarycentricCoordinates:function(e,i,r,t,n,s,h,u,o){if(!v.defined(e))throw new C.DeveloperError("x is required.");if(!v.defined(i))throw new C.DeveloperError("y is required.");if(!v.defined(r))throw new C.DeveloperError("x1 is required.");if(!v.defined(t))throw new C.DeveloperError("y1 is required.");if(!v.defined(n))throw new C.DeveloperError("x2 is required.");if(!v.defined(s))throw new C.DeveloperError("y2 is required.");if(!v.defined(h))throw new C.DeveloperError("x3 is required.");if(!v.defined(u))throw new C.DeveloperError("y3 is required.");var d=r-h,p=h-n,a=s-u,f=t-u,l=1/(a*d+p*f),c=i-u,g=e-h,m=(a*g+p*c)*l,w=(-f*g+d*c)*l,x=1-m-w;return v.defined(o)?(o.x=m,o.y=w,o.z=x,o):new ge.Cartesian3(m,w,x)},computeLineSegmentLineSegmentIntersection:function(e,i,r,t,n,s,h,u,o){C.Check.typeOf.number("x00",e),C.Check.typeOf.number("y00",i),C.Check.typeOf.number("x01",r),C.Check.typeOf.number("y01",t),C.Check.typeOf.number("x10",n),C.Check.typeOf.number("y10",s),C.Check.typeOf.number("x11",h),C.Check.typeOf.number("y11",u);var d=(u-s)*(r-e)-(h-n)*(t-i);if(0!=d){var p=((h-n)*(i-s)-(u-s)*(e-n))/d,a=((r-e)*(i-s)-(t-i)*(e-n))/d;return 0<=p&&p<=1&&0<=a&&a<=1?(v.defined(o)||(o=new ge.Cartesian2),o.x=e+p*(r-e),o.y=i+p*(t-i),o):void 0}}},ye=32767,be=16383,Be=[],Ie=[],Ae=[],Ee=new ge.Cartographic,De=new ge.Cartesian3,Te=[],Oe=[],ze=[],ke=[],Me=[],Ne=new ge.Cartesian3,Ve=new me.BoundingSphere,qe=new xe.OrientedBoundingBox,Re=new ge.Cartesian2,He=new ge.Cartesian3;function Se(){this.vertexBuffer=void 0,this.index=void 0,this.first=void 0,this.second=void 0,this.ratio=void 0}Se.prototype.clone=function(e){return v.defined(e)||(e=new Se),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},Se.prototype.initializeIndexed=function(e,i,r,t,n){this.uBuffer=e,this.vBuffer=i,this.heightBuffer=r,this.normalBuffer=t,this.index=n,this.first=void 0,this.second=void 0,this.ratio=void 0},Se.prototype.initializeFromClipResult=function(e,i,r){var t=i+1;return-1!==e[i]?r[e[i]].clone(this):(this.vertexBuffer=void 0,this.index=void 0,this.first=r[e[t]],++t,this.second=r[e[t]],++t,this.ratio=e[t],++t),t},Se.prototype.getKey=function(){return this.isIndexed()?this.index:JSON.stringify({first:this.first.getKey(),second:this.second.getKey(),ratio:this.ratio})},Se.prototype.isIndexed=function(){return v.defined(this.index)},Se.prototype.getH=function(){return v.defined(this.index)?this.heightBuffer[this.index]:ce.CesiumMath.lerp(this.first.getH(),this.second.getH(),this.ratio)},Se.prototype.getU=function(){return v.defined(this.index)?this.uBuffer[this.index]:ce.CesiumMath.lerp(this.first.getU(),this.second.getU(),this.ratio)},Se.prototype.getV=function(){return v.defined(this.index)?this.vBuffer[this.index]:ce.CesiumMath.lerp(this.first.getV(),this.second.getV(),this.ratio)};var o=new ge.Cartesian2,d=-1,p=[new ge.Cartesian3,new ge.Cartesian3],a=[new ge.Cartesian3,new ge.Cartesian3];function f(e,i){var r=p[++d],t=a[d],r=n.AttributeCompression.octDecode(e.first.getNormalX(),e.first.getNormalY(),r),t=n.AttributeCompression.octDecode(e.second.getNormalX(),e.second.getNormalY(),t);return De=ge.Cartesian3.lerp(r,t,e.ratio,De),ge.Cartesian3.normalize(De,De),n.AttributeCompression.octEncode(De,i),--d,i}Se.prototype.getNormalX=function(){return v.defined(this.index)?this.normalBuffer[2*this.index]:(o=f(this,o)).x},Se.prototype.getNormalY=function(){return v.defined(this.index)?this.normalBuffer[2*this.index+1]:(o=f(this,o)).y};var g=[];function Ue(e,i,r,t,n,s,h,u,o){if(0!==h.length){for(var d=0,p=0;p<h.length;)p=g[d++].initializeFromClipResult(h,p,u);for(var a=0;a<d;++a){var f,l,c=g[a];c.isIndexed()?(c.newIndex=s[c.index],c.uBuffer=e,c.vBuffer=i,c.heightBuffer=r,o&&(c.normalBuffer=t)):(f=c.getKey(),v.defined(s[f])?c.newIndex=s[f]:(l=e.length,e.push(c.getU()),i.push(c.getV()),r.push(c.getH()),o&&(t.push(c.getNormalX()),t.push(c.getNormalY())),c.newIndex=l,s[f]=l))}3===d?(n.push(g[0].newIndex),n.push(g[1].newIndex),n.push(g[2].newIndex)):4===d&&(n.push(g[0].newIndex),n.push(g[1].newIndex),n.push(g[2].newIndex),n.push(g[0].newIndex),n.push(g[2].newIndex),n.push(g[3].newIndex))}}return g.push(new Se),g.push(new Se),g.push(new Se),g.push(new Se),h(function(e,i){var r=e.isEastChild,t=e.isNorthChild,n=r?be:0,s=r?ye:be,h=t?be:0,u=t?ye:be,o=Te,d=Oe,p=ze,a=Me;o.length=0,d.length=0,p.length=0,a.length=0;var f=ke;f.length=0;for(var l={},c=e.vertices,g=(g=e.indices).subarray(0,e.indexCountWithoutSkirts),m=ve.TerrainEncoding.clone(e.encoding),w=m.hasVertexNormals,x=e.exaggeration,v=0,C=e.vertexCountWithoutSkirts,y=e.minimumHeight,b=e.maximumHeight,B=new Array(C),I=new Array(C),A=new Array(C),E=w?new Array(2*C):void 0,D=0,T=0;D<C;++D,T+=2){var O,z=m.decodeTextureCoordinates(c,D,Re),k=m.decodeHeight(c,D)/x,M=ce.CesiumMath.clamp(z.x*ye|0,0,ye),N=ce.CesiumMath.clamp(z.y*ye|0,0,ye);A[D]=ce.CesiumMath.clamp((k-y)/(b-y)*ye|0,0,ye),M<20&&(M=0),N<20&&(N=0),ye-M<20&&(M=ye),ye-N<20&&(N=ye),B[D]=M,I[D]=N,w&&(O=m.getOctEncodedNormal(c,D,He),E[T]=O.x,E[T+1]=O.y),(r&&be<=M||!r&&M<=be)&&(t&&be<=N||!t&&N<=be)&&(l[D]=v,o.push(M),d.push(N),p.push(A[D]),w&&(a.push(E[T]),a.push(E[T+1])),++v)}var V=[];V.push(new Se),V.push(new Se),V.push(new Se);var q=[];for(q.push(new Se),q.push(new Se),q.push(new Se),D=0;D<g.length;D+=3){var R=g[D],H=g[D+1],S=g[D+2],U=B[R],F=B[H],P=B[S];V[0].initializeIndexed(B,I,A,E,R),V[1].initializeIndexed(B,I,A,E,H),V[2].initializeIndexed(B,I,A,E,S);var W,X=Ce.clipTriangleAtAxisAlignedThreshold(be,r,U,F,P,Be);X.length<=0||(W=q[0].initializeFromClipResult(X,0,V))>=X.length||(W=q[1].initializeFromClipResult(X,W,V))>=X.length||(W=q[2].initializeFromClipResult(X,W,V),Ue(o,d,p,a,f,l,Ce.clipTriangleAtAxisAlignedThreshold(be,t,q[0].getV(),q[1].getV(),q[2].getV(),Ie),q,w),W<X.length&&(q[2].clone(q[1]),q[2].initializeFromClipResult(X,W,V),Ue(o,d,p,a,f,l,Ce.clipTriangleAtAxisAlignedThreshold(be,t,q[0].getV(),q[1].getV(),q[2].getV(),Ie),q,w)))}var K=r?-ye:0,L=t?-ye:0,Y=[],_=[],G=[],J=[],Z=Number.MAX_VALUE,j=-Z,Q=Ae;Q.length=0;var $=ge.Ellipsoid.clone(e.ellipsoid),ee=ge.Rectangle.clone(e.childRectangle),ie=ee.north,re=ee.south,te=ee.east,ne=ee.west;for(te<ne&&(te+=ce.CesiumMath.TWO_PI),D=0;D<o.length;++D)M=(M=Math.round(o[D]))<=n?(Y.push(D),0):s<=M?(G.push(D),ye):2*M+K,o[D]=M,N=(N=Math.round(d[D]))<=h?(_.push(D),0):u<=N?(J.push(D),ye):2*N+L,d[D]=N,(k=ce.CesiumMath.lerp(y,b,p[D]/ye))<Z&&(Z=k),j<k&&(j=k),p[D]=k,Ee.longitude=ce.CesiumMath.lerp(ne,te,M/ye),Ee.latitude=ce.CesiumMath.lerp(re,ie,N/ye),Ee.height=k,$.cartographicToCartesian(Ee,De),Q.push(De.x),Q.push(De.y),Q.push(De.z);var se=me.BoundingSphere.fromVertices(Q,ge.Cartesian3.ZERO,3,Ve),he=xe.OrientedBoundingBox.fromRectangle(ee,Z,j,$,qe),ue=new ve.EllipsoidalOccluder($).computeHorizonCullingPointFromVerticesPossiblyUnderEllipsoid(se.center,Q,3,se.center,Z,Ne),oe=j-Z,de=new Uint16Array(o.length+d.length+p.length);for(D=0;D<o.length;++D)de[D]=o[D];var pe=o.length;for(D=0;D<d.length;++D)de[pe+D]=d[D];for(pe+=d.length,D=0;D<p.length;++D)de[pe+D]=ye*(p[D]-Z)/oe;var ae,fe,le=we.IndexDatatype.createTypedArray(o.length,f);return w?(fe=new Uint8Array(a),i.push(de.buffer,le.buffer,fe.buffer),ae=fe.buffer):i.push(de.buffer,le.buffer),{vertices:de.buffer,encodedNormals:ae,indices:le.buffer,minimumHeight:Z,maximumHeight:j,westIndices:Y,southIndices:_,eastIndices:G,northIndices:J,boundingSphere:se,orientedBoundingBox:he,horizonOcclusionPoint:ue}})}); |