2 lines
9.3 KiB
JavaScript
2 lines
9.3 KiB
JavaScript
define(["exports","./Cartesian4-b0ddc4ba","./Check-7b2a090c","./when-b60132fc","./buildModuleUrl-8cce5713","./Plane-5716a082","./GeometryAttribute-923c2729","./earcut-2.2.1-20c8012f","./FeatureDetection-ab6f364c","./EllipsoidRhumbLine-3ee4574a","./Math-31e539c2","./WebGLConstants-aba9fc67"],(function(e,t,a,n,i,r,s,o,u,l,m,c){"use strict";function d(e,a,i){this.minimum=t.Cartesian3.clone(n.defaultValue(e,t.Cartesian3.ZERO)),this.maximum=t.Cartesian3.clone(n.defaultValue(a,t.Cartesian3.ZERO)),i=n.defined(i)?t.Cartesian3.clone(i):t.Cartesian3.midpoint(this.minimum,this.maximum,new t.Cartesian3),this.center=i}d.fromPoints=function(e,a){if(n.defined(a)||(a=new d),!n.defined(e)||0===e.length)return a.minimum=t.Cartesian3.clone(t.Cartesian3.ZERO,a.minimum),a.maximum=t.Cartesian3.clone(t.Cartesian3.ZERO,a.maximum),a.center=t.Cartesian3.clone(t.Cartesian3.ZERO,a.center),a;for(var i=e[0].x,r=e[0].y,s=e[0].z,o=e[0].x,u=e[0].y,l=e[0].z,m=e.length,c=1;c<m;c++){var h=e[c],p=h.x,C=h.y,f=h.z;i=Math.min(p,i),o=Math.max(p,o),r=Math.min(C,r),u=Math.max(C,u),s=Math.min(f,s),l=Math.max(f,l)}var y=a.minimum;y.x=i,y.y=r,y.z=s;var g=a.maximum;return g.x=o,g.y=u,g.z=l,a.center=t.Cartesian3.midpoint(y,g,a.center),a},d.clone=function(e,a){if(n.defined(e))return n.defined(a)?(a.minimum=t.Cartesian3.clone(e.minimum,a.minimum),a.maximum=t.Cartesian3.clone(e.maximum,a.maximum),a.center=t.Cartesian3.clone(e.center,a.center),a):new d(e.minimum,e.maximum,e.center)},d.equals=function(e,a){return e===a||n.defined(e)&&n.defined(a)&&t.Cartesian3.equals(e.center,a.center)&&t.Cartesian3.equals(e.minimum,a.minimum)&&t.Cartesian3.equals(e.maximum,a.maximum)};var h=new t.Cartesian3;d.intersectPlane=function(e,a){h=t.Cartesian3.subtract(e.maximum,e.minimum,h);var n=t.Cartesian3.multiplyByScalar(h,.5,h),r=a.normal,s=n.x*Math.abs(r.x)+n.y*Math.abs(r.y)+n.z*Math.abs(r.z),o=t.Cartesian3.dot(e.center,r)+a.distance;return o-s>0?i.Intersect.INSIDE:o+s<0?i.Intersect.OUTSIDE:i.Intersect.INTERSECTING},d.prototype.clone=function(e){return d.clone(this,e)},d.prototype.intersectPlane=function(e){return d.intersectPlane(this,e)},d.prototype.equals=function(e){return d.equals(this,e)};var p=new t.Cartesian4;function C(e,a){e=(a=n.defaultValue(a,i.Ellipsoid.WGS84)).scaleToGeodeticSurface(e);var o=s.Transforms.eastNorthUpToFixedFrame(e,a);this._ellipsoid=a,this._origin=e,this._xAxis=t.Cartesian3.fromCartesian4(i.Matrix4.getColumn(o,0,p)),this._yAxis=t.Cartesian3.fromCartesian4(i.Matrix4.getColumn(o,1,p));var u=t.Cartesian3.fromCartesian4(i.Matrix4.getColumn(o,2,p));this._plane=r.Plane.fromPointNormal(e,u)}Object.defineProperties(C.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},origin:{get:function(){return this._origin}},plane:{get:function(){return this._plane}},xAxis:{get:function(){return this._xAxis}},yAxis:{get:function(){return this._yAxis}},zAxis:{get:function(){return this._plane.normal}}});var f=new d;C.fromPoints=function(e,t){return new C(d.fromPoints(e,f).center,t)};var y=new r.Ray,g=new t.Cartesian3;C.prototype.projectPointOntoPlane=function(e,a){var s=y;s.origin=e,t.Cartesian3.normalize(e,s.direction);var o=r.IntersectionTests.rayPlane(s,this._plane,g);if(n.defined(o)||(t.Cartesian3.negate(s.direction,s.direction),o=r.IntersectionTests.rayPlane(s,this._plane,g)),n.defined(o)){var u=t.Cartesian3.subtract(o,this._origin,o),l=t.Cartesian3.dot(this._xAxis,u),m=t.Cartesian3.dot(this._yAxis,u);return n.defined(a)?(a.x=l,a.y=m,a):new i.Cartesian2(l,m)}},C.prototype.projectPointsOntoPlane=function(e,t){n.defined(t)||(t=[]);for(var a=0,i=e.length,r=0;r<i;r++){var s=this.projectPointOntoPlane(e[r],t[a]);n.defined(s)&&(t[a]=s,a++)}return t.length=a,t},C.prototype.projectPointToNearestOnPlane=function(e,a){n.defined(a)||(a=new i.Cartesian2);var s=y;s.origin=e,t.Cartesian3.clone(this._plane.normal,s.direction);var o=r.IntersectionTests.rayPlane(s,this._plane,g);n.defined(o)||(t.Cartesian3.negate(s.direction,s.direction),o=r.IntersectionTests.rayPlane(s,this._plane,g));var u=t.Cartesian3.subtract(o,this._origin,o),l=t.Cartesian3.dot(this._xAxis,u),m=t.Cartesian3.dot(this._yAxis,u);return a.x=l,a.y=m,a},C.prototype.projectPointsToNearestOnPlane=function(e,t){n.defined(t)||(t=[]);var a=e.length;t.length=a;for(var i=0;i<a;i++)t[i]=this.projectPointToNearestOnPlane(e[i],t[i]);return t};var x=new t.Cartesian3;C.prototype.projectPointOntoEllipsoid=function(e,a){n.defined(a)||(a=new t.Cartesian3);var i=this._ellipsoid,r=this._origin,s=this._xAxis,o=this._yAxis,u=x;return t.Cartesian3.multiplyByScalar(s,e.x,u),a=t.Cartesian3.add(r,u,a),t.Cartesian3.multiplyByScalar(o,e.y,u),t.Cartesian3.add(a,u,a),i.scaleToGeocentricSurface(a,a),a},C.prototype.projectPointsOntoEllipsoid=function(e,t){var a=e.length;n.defined(t)?t.length=a:t=new Array(a);for(var i=0;i<a;++i)t[i]=this.projectPointOntoEllipsoid(e[i],t[i]);return t};var v={CLOCKWISE:c.WebGLConstants.CW,COUNTER_CLOCKWISE:c.WebGLConstants.CCW,validate:function(e){return e===v.CLOCKWISE||e===v.COUNTER_CLOCKWISE}},E=Object.freeze(v),P=new t.Cartesian3,A=new t.Cartesian3,w={computeArea2D:function(e){for(var t=e.length,a=0,n=t-1,i=0;i<t;n=i++){var r=e[n],s=e[i];a+=r.x*s.y-s.x*r.y}return.5*a},computeWindingOrder2D:function(e){return w.computeArea2D(e)>0?E.COUNTER_CLOCKWISE:E.CLOCKWISE},triangulate:function(e,t){var a=i.Cartesian2.packArray(e);return o.earcut(a,t,2)}},b=new t.Cartesian3,S=new t.Cartesian3,_=new t.Cartesian3,M=new t.Cartesian3,O=new t.Cartesian3,T=new t.Cartesian3,R=new t.Cartesian3;w.computeSubdivision=function(e,a,r,o,l){l=n.defaultValue(l,!1),o=n.defaultValue(o,m.Math3D.RADIANS_PER_DEGREE);var c,d=r.slice(0),h=a.length,p=new Array(3*h),C=0;for(c=0;c<h;c++){var f=a[c];p[C++]=f.x,p[C++]=f.y,p[C++]=f.z}for(var y=[],g={},x=e.maximumRadius,v=m.Math3D.chordLength(o,x),E=v*v;d.length>0;){var P,A,w=d.pop(),D=d.pop(),z=d.pop(),I=t.Cartesian3.fromArray(p,3*z,b),L=t.Cartesian3.fromArray(p,3*D,S),G=t.Cartesian3.fromArray(p,3*w,_),N=l?I:t.Cartesian3.multiplyByScalar(t.Cartesian3.normalize(I,M),x,M),W=l?L:t.Cartesian3.multiplyByScalar(t.Cartesian3.normalize(L,O),x,O),B=l?G:t.Cartesian3.multiplyByScalar(t.Cartesian3.normalize(G,T),x,T),j=t.Cartesian3.magnitudeSquared(t.Cartesian3.subtract(N,W,R)),U=t.Cartesian3.magnitudeSquared(t.Cartesian3.subtract(W,B,R)),q=t.Cartesian3.magnitudeSquared(t.Cartesian3.subtract(B,N,R)),V=Math.max(j,U,q);V>E?j===V?(c=g[P=Math.min(z,D)+" "+Math.max(z,D)],n.defined(c)||(A=t.Cartesian3.add(I,L,R),t.Cartesian3.multiplyByScalar(A,.5,A),p.push(A.x,A.y,A.z),c=p.length/3-1,g[P]=c),d.push(z,c,w),d.push(c,D,w)):U===V?(c=g[P=Math.min(D,w)+" "+Math.max(D,w)],n.defined(c)||(A=t.Cartesian3.add(L,G,R),t.Cartesian3.multiplyByScalar(A,.5,A),p.push(A.x,A.y,A.z),c=p.length/3-1,g[P]=c),d.push(D,c,z),d.push(c,w,z)):q===V&&(c=g[P=Math.min(w,z)+" "+Math.max(w,z)],n.defined(c)||(A=t.Cartesian3.add(G,I,R),t.Cartesian3.multiplyByScalar(A,.5,A),p.push(A.x,A.y,A.z),c=p.length/3-1,g[P]=c),d.push(w,c,D),d.push(c,z,D)):(y.push(z),y.push(D),y.push(w))}return new s.Geometry({attributes:{position:new s.GeometryAttribute({componentDatatype:u.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:p})},indices:y,primitiveType:i.PrimitiveType.TRIANGLES})};var D=new t.Cartographic,z=new t.Cartographic,I=new t.Cartographic,L=new t.Cartographic;w.computeRhumbLineSubdivision=function(e,a,r,o){o=n.defaultValue(o,m.Math3D.RADIANS_PER_DEGREE);var c,d=r.slice(0),h=a.length,p=new Array(3*h),C=0;for(c=0;c<h;c++){var f=a[c];p[C++]=f.x,p[C++]=f.y,p[C++]=f.z}for(var y=[],g={},x=e.maximumRadius,v=m.Math3D.chordLength(o,x),E=new l.EllipsoidRhumbLine(void 0,void 0,e),P=new l.EllipsoidRhumbLine(void 0,void 0,e),A=new l.EllipsoidRhumbLine(void 0,void 0,e);d.length>0;){var w=d.pop(),M=d.pop(),O=d.pop(),T=t.Cartesian3.fromArray(p,3*O,b),G=t.Cartesian3.fromArray(p,3*M,S),N=t.Cartesian3.fromArray(p,3*w,_),W=e.cartesianToCartographic(T,D),B=e.cartesianToCartographic(G,z),j=e.cartesianToCartographic(N,I);E.setEndPoints(W,B);var U=E.surfaceDistance;P.setEndPoints(B,j);var q=P.surfaceDistance;A.setEndPoints(j,W);var V,F,K,Z,k=A.surfaceDistance,H=Math.max(U,q,k);H>v?U===H?(c=g[V=Math.min(O,M)+" "+Math.max(O,M)],n.defined(c)||(F=E.interpolateUsingFraction(.5,L),K=.5*(W.height+B.height),Z=t.Cartesian3.fromRadians(F.longitude,F.latitude,K,e,R),p.push(Z.x,Z.y,Z.z),c=p.length/3-1,g[V]=c),d.push(O,c,w),d.push(c,M,w)):q===H?(c=g[V=Math.min(M,w)+" "+Math.max(M,w)],n.defined(c)||(F=P.interpolateUsingFraction(.5,L),K=.5*(B.height+j.height),Z=t.Cartesian3.fromRadians(F.longitude,F.latitude,K,e,R),p.push(Z.x,Z.y,Z.z),c=p.length/3-1,g[V]=c),d.push(M,c,O),d.push(c,w,O)):k===H&&(c=g[V=Math.min(w,O)+" "+Math.max(w,O)],n.defined(c)||(F=A.interpolateUsingFraction(.5,L),K=.5*(j.height+W.height),Z=t.Cartesian3.fromRadians(F.longitude,F.latitude,K,e,R),p.push(Z.x,Z.y,Z.z),c=p.length/3-1,g[V]=c),d.push(w,c,M),d.push(c,O,M)):(y.push(O),y.push(M),y.push(w))}return new s.Geometry({attributes:{position:new s.GeometryAttribute({componentDatatype:u.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:p})},indices:y,primitiveType:i.PrimitiveType.TRIANGLES})},w.scaleToGeodeticHeight=function(e,a,r,s){r=n.defaultValue(r,i.Ellipsoid.WGS84);var o=P,u=A;if(a=n.defaultValue(a,0),s=n.defaultValue(s,!0),n.defined(e))for(var l=e.length,m=0;m<l;m+=3)t.Cartesian3.fromArray(e,m,u),s&&(u=r.scaleToGeodeticSurface(u,u)),0!==a&&(o=r.geodeticSurfaceNormal(u,o),t.Cartesian3.multiplyByScalar(o,a,o),t.Cartesian3.add(u,o,u)),e[m]=u.x,e[m+1]=u.y,e[m+2]=u.z;return e},e.AxisAlignedBoundingBox=d,e.EllipsoidTangentPlane=C,e.PolygonPipeline=w,e.WindingOrder=E}));
|