qa-regulatory-gwj-vue/static/map/cesium91/CesiumUnminified/Workers/BoundingSphere-9a3b5656.js

2 lines
12 KiB
JavaScript

define(["exports","./Cartesian3-e0307675","./Cartesian2-bd414876","./Check-741c5f3c","./defaultValue-81eec7ed","./GeographicProjection-c931c7fb","./Math-e73894ab","./Matrix4-4c545f70","./Rectangle-cf3e0e3e"],(function(e,n,t,a,r,i,s,c,o){"use strict";var u=Object.freeze({OUTSIDE:-1,INTERSECTING:0,INSIDE:1});function d(e,n){this.start=r.defaultValue(e,0),this.stop=r.defaultValue(n,0)}function C(e,t){this.center=n.Cartesian3.clone(r.defaultValue(e,n.Cartesian3.ZERO)),this.radius=r.defaultValue(t,0)}const l=new n.Cartesian3,f=new n.Cartesian3,y=new n.Cartesian3,m=new n.Cartesian3,x=new n.Cartesian3,g=new n.Cartesian3,h=new n.Cartesian3,z=new n.Cartesian3,w=new n.Cartesian3,p=new n.Cartesian3,S=new n.Cartesian3,q=new n.Cartesian3,b=4/3*s.CesiumMath.PI;C.fromPoints=function(e,t){if(r.defined(t)||(t=new C),!r.defined(e)||0===e.length)return t.center=n.Cartesian3.clone(n.Cartesian3.ZERO,t.center),t.radius=0,t;const a=n.Cartesian3.clone(e[0],h),i=n.Cartesian3.clone(a,l),s=n.Cartesian3.clone(a,f),c=n.Cartesian3.clone(a,y),o=n.Cartesian3.clone(a,m),u=n.Cartesian3.clone(a,x),d=n.Cartesian3.clone(a,g),b=e.length;let E;for(E=1;E<b;E++){n.Cartesian3.clone(e[E],a);const t=a.x,r=a.y,C=a.z;t<i.x&&n.Cartesian3.clone(a,i),t>o.x&&n.Cartesian3.clone(a,o),r<s.y&&n.Cartesian3.clone(a,s),r>u.y&&n.Cartesian3.clone(a,u),C<c.z&&n.Cartesian3.clone(a,c),C>d.z&&n.Cartesian3.clone(a,d)}const R=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(o,i,z)),M=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(u,s,z)),O=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(d,c,z));let P=i,V=o,I=R;M>I&&(I=M,P=s,V=u),O>I&&(I=O,P=c,V=d);const T=w;T.x=.5*(P.x+V.x),T.y=.5*(P.y+V.y),T.z=.5*(P.z+V.z);let D=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(V,T,z)),B=Math.sqrt(D);const Z=p;Z.x=i.x,Z.y=s.y,Z.z=c.z;const N=S;N.x=o.x,N.y=u.y,N.z=d.z;const j=n.Cartesian3.midpoint(Z,N,q);let G=0;for(E=0;E<b;E++){n.Cartesian3.clone(e[E],a);const t=n.Cartesian3.magnitude(n.Cartesian3.subtract(a,j,z));t>G&&(G=t);const r=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(a,T,z));if(r>D){const e=Math.sqrt(r);B=.5*(B+e),D=B*B;const n=e-B;T.x=(B*T.x+n*a.x)/e,T.y=(B*T.y+n*a.y)/e,T.z=(B*T.z+n*a.z)/e}}return B<G?(n.Cartesian3.clone(T,t.center),t.radius=B):(n.Cartesian3.clone(j,t.center),t.radius=G),t};const E=new i.GeographicProjection,R=new n.Cartesian3,M=new n.Cartesian3,O=new t.Cartographic,P=new t.Cartographic;C.fromRectangle2D=function(e,n,t){return C.fromRectangleWithHeights2D(e,n,0,0,t)},C.fromRectangleWithHeights2D=function(e,t,a,i,s){if(r.defined(s)||(s=new C),!r.defined(e))return s.center=n.Cartesian3.clone(n.Cartesian3.ZERO,s.center),s.radius=0,s;t=r.defaultValue(t,E),o.Rectangle.southwest(e,O),O.height=a,o.Rectangle.northeast(e,P),P.height=i;const c=t.project(O,R),u=t.project(P,M),d=u.x-c.x,l=u.y-c.y,f=u.z-c.z;s.radius=.5*Math.sqrt(d*d+l*l+f*f);const y=s.center;return y.x=c.x+.5*d,y.y=c.y+.5*l,y.z=c.z+.5*f,s};const V=[];C.fromRectangle3D=function(e,a,i,s){if(a=r.defaultValue(a,t.Ellipsoid.WGS84),i=r.defaultValue(i,0),r.defined(s)||(s=new C),!r.defined(e))return s.center=n.Cartesian3.clone(n.Cartesian3.ZERO,s.center),s.radius=0,s;const c=o.Rectangle.subsample(e,a,i,V);return C.fromPoints(c,s)},C.fromVertices=function(e,t,a,i){if(r.defined(i)||(i=new C),!r.defined(e)||0===e.length)return i.center=n.Cartesian3.clone(n.Cartesian3.ZERO,i.center),i.radius=0,i;t=r.defaultValue(t,n.Cartesian3.ZERO),a=r.defaultValue(a,3);const s=h;s.x=e[0]+t.x,s.y=e[1]+t.y,s.z=e[2]+t.z;const c=n.Cartesian3.clone(s,l),o=n.Cartesian3.clone(s,f),u=n.Cartesian3.clone(s,y),d=n.Cartesian3.clone(s,m),b=n.Cartesian3.clone(s,x),E=n.Cartesian3.clone(s,g),R=e.length;let M;for(M=0;M<R;M+=a){const a=e[M]+t.x,r=e[M+1]+t.y,i=e[M+2]+t.z;s.x=a,s.y=r,s.z=i,a<c.x&&n.Cartesian3.clone(s,c),a>d.x&&n.Cartesian3.clone(s,d),r<o.y&&n.Cartesian3.clone(s,o),r>b.y&&n.Cartesian3.clone(s,b),i<u.z&&n.Cartesian3.clone(s,u),i>E.z&&n.Cartesian3.clone(s,E)}const O=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(d,c,z)),P=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(b,o,z)),V=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(E,u,z));let I=c,T=d,D=O;P>D&&(D=P,I=o,T=b),V>D&&(D=V,I=u,T=E);const B=w;B.x=.5*(I.x+T.x),B.y=.5*(I.y+T.y),B.z=.5*(I.z+T.z);let Z=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(T,B,z)),N=Math.sqrt(Z);const j=p;j.x=c.x,j.y=o.y,j.z=u.z;const G=S;G.x=d.x,G.y=b.y,G.z=E.z;const k=n.Cartesian3.midpoint(j,G,q);let U=0;for(M=0;M<R;M+=a){s.x=e[M]+t.x,s.y=e[M+1]+t.y,s.z=e[M+2]+t.z;const a=n.Cartesian3.magnitude(n.Cartesian3.subtract(s,k,z));a>U&&(U=a);const r=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(s,B,z));if(r>Z){const e=Math.sqrt(r);N=.5*(N+e),Z=N*N;const n=e-N;B.x=(N*B.x+n*s.x)/e,B.y=(N*B.y+n*s.y)/e,B.z=(N*B.z+n*s.z)/e}}return N<U?(n.Cartesian3.clone(B,i.center),i.radius=N):(n.Cartesian3.clone(k,i.center),i.radius=U),i},C.fromEncodedCartesianVertices=function(e,t,a){if(r.defined(a)||(a=new C),!r.defined(e)||!r.defined(t)||e.length!==t.length||0===e.length)return a.center=n.Cartesian3.clone(n.Cartesian3.ZERO,a.center),a.radius=0,a;const i=h;i.x=e[0]+t[0],i.y=e[1]+t[1],i.z=e[2]+t[2];const s=n.Cartesian3.clone(i,l),c=n.Cartesian3.clone(i,f),o=n.Cartesian3.clone(i,y),u=n.Cartesian3.clone(i,m),d=n.Cartesian3.clone(i,x),b=n.Cartesian3.clone(i,g),E=e.length;let R;for(R=0;R<E;R+=3){const a=e[R]+t[R],r=e[R+1]+t[R+1],C=e[R+2]+t[R+2];i.x=a,i.y=r,i.z=C,a<s.x&&n.Cartesian3.clone(i,s),a>u.x&&n.Cartesian3.clone(i,u),r<c.y&&n.Cartesian3.clone(i,c),r>d.y&&n.Cartesian3.clone(i,d),C<o.z&&n.Cartesian3.clone(i,o),C>b.z&&n.Cartesian3.clone(i,b)}const M=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(u,s,z)),O=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(d,c,z)),P=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(b,o,z));let V=s,I=u,T=M;O>T&&(T=O,V=c,I=d),P>T&&(T=P,V=o,I=b);const D=w;D.x=.5*(V.x+I.x),D.y=.5*(V.y+I.y),D.z=.5*(V.z+I.z);let B=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(I,D,z)),Z=Math.sqrt(B);const N=p;N.x=s.x,N.y=c.y,N.z=o.z;const j=S;j.x=u.x,j.y=d.y,j.z=b.z;const G=n.Cartesian3.midpoint(N,j,q);let k=0;for(R=0;R<E;R+=3){i.x=e[R]+t[R],i.y=e[R+1]+t[R+1],i.z=e[R+2]+t[R+2];const a=n.Cartesian3.magnitude(n.Cartesian3.subtract(i,G,z));a>k&&(k=a);const r=n.Cartesian3.magnitudeSquared(n.Cartesian3.subtract(i,D,z));if(r>B){const e=Math.sqrt(r);Z=.5*(Z+e),B=Z*Z;const n=e-Z;D.x=(Z*D.x+n*i.x)/e,D.y=(Z*D.y+n*i.y)/e,D.z=(Z*D.z+n*i.z)/e}}return Z<k?(n.Cartesian3.clone(D,a.center),a.radius=Z):(n.Cartesian3.clone(G,a.center),a.radius=k),a},C.fromCornerPoints=function(e,t,a){r.defined(a)||(a=new C);const i=n.Cartesian3.midpoint(e,t,a.center);return a.radius=n.Cartesian3.distance(i,t),a},C.fromEllipsoid=function(e,t){return r.defined(t)||(t=new C),n.Cartesian3.clone(n.Cartesian3.ZERO,t.center),t.radius=e.maximumRadius,t};const I=new n.Cartesian3;C.fromBoundingSpheres=function(e,t){if(r.defined(t)||(t=new C),!r.defined(e)||0===e.length)return t.center=n.Cartesian3.clone(n.Cartesian3.ZERO,t.center),t.radius=0,t;const a=e.length;if(1===a)return C.clone(e[0],t);if(2===a)return C.union(e[0],e[1],t);const i=[];let s;for(s=0;s<a;s++)i.push(e[s].center);const c=(t=C.fromPoints(i,t)).center;let o=t.radius;for(s=0;s<a;s++){const t=e[s];o=Math.max(o,n.Cartesian3.distance(c,t.center,I)+t.radius)}return t.radius=o,t};const T=new n.Cartesian3,D=new n.Cartesian3,B=new n.Cartesian3;C.fromOrientedBoundingBox=function(e,t){r.defined(t)||(t=new C);const a=e.halfAxes,i=c.Matrix3.getColumn(a,0,T),s=c.Matrix3.getColumn(a,1,D),o=c.Matrix3.getColumn(a,2,B);return n.Cartesian3.add(i,s,i),n.Cartesian3.add(i,o,i),t.center=n.Cartesian3.clone(e.center,t.center),t.radius=n.Cartesian3.magnitude(i),t};const Z=new n.Cartesian3,N=new n.Cartesian3;C.fromTransformation=function(e,t){r.defined(t)||(t=new C);const a=c.Matrix4.getTranslation(e,Z),i=c.Matrix4.getScale(e,N),s=.5*n.Cartesian3.magnitude(i);return t.center=n.Cartesian3.clone(a,t.center),t.radius=s,t},C.clone=function(e,t){if(r.defined(e))return r.defined(t)?(t.center=n.Cartesian3.clone(e.center,t.center),t.radius=e.radius,t):new C(e.center,e.radius)},C.packedLength=4,C.pack=function(e,n,t){t=r.defaultValue(t,0);const a=e.center;return n[t++]=a.x,n[t++]=a.y,n[t++]=a.z,n[t]=e.radius,n},C.unpack=function(e,n,t){n=r.defaultValue(n,0),r.defined(t)||(t=new C);const a=t.center;return a.x=e[n++],a.y=e[n++],a.z=e[n++],t.radius=e[n],t};const j=new n.Cartesian3,G=new n.Cartesian3;C.union=function(e,t,a){r.defined(a)||(a=new C);const i=e.center,s=e.radius,c=t.center,o=t.radius,u=n.Cartesian3.subtract(c,i,j),d=n.Cartesian3.magnitude(u);if(s>=d+o)return e.clone(a),a;if(o>=d+s)return t.clone(a),a;const l=.5*(s+d+o),f=n.Cartesian3.multiplyByScalar(u,(-s+l)/d,G);return n.Cartesian3.add(f,i,f),n.Cartesian3.clone(f,a.center),a.radius=l,a};const k=new n.Cartesian3;C.expand=function(e,t,a){a=C.clone(e,a);const r=n.Cartesian3.magnitude(n.Cartesian3.subtract(t,a.center,k));return r>a.radius&&(a.radius=r),a},C.intersectPlane=function(e,t){const a=e.center,r=e.radius,i=t.normal,s=n.Cartesian3.dot(i,a)+t.distance;return s<-r?u.OUTSIDE:s<r?u.INTERSECTING:u.INSIDE},C.transform=function(e,n,t){return r.defined(t)||(t=new C),t.center=c.Matrix4.multiplyByPoint(n,e.center,t.center),t.radius=c.Matrix4.getMaximumScale(n)*e.radius,t};const U=new n.Cartesian3;C.distanceSquaredTo=function(e,t){const a=n.Cartesian3.subtract(e.center,t,U),r=n.Cartesian3.magnitude(a)-e.radius;return r<=0?0:r*r},C.transformWithoutScale=function(e,n,t){return r.defined(t)||(t=new C),t.center=c.Matrix4.multiplyByPoint(n,e.center,t.center),t.radius=e.radius,t};const W=new n.Cartesian3;C.computePlaneDistances=function(e,t,a,i){r.defined(i)||(i=new d);const s=n.Cartesian3.subtract(e.center,t,W),c=n.Cartesian3.dot(a,s);return i.start=c-e.radius,i.stop=c+e.radius,i};const v=new n.Cartesian3,A=new n.Cartesian3,H=new n.Cartesian3,_=new n.Cartesian3,L=new n.Cartesian3,X=new t.Cartographic,F=new Array(8);for(let e=0;e<8;++e)F[e]=new n.Cartesian3;const J=new i.GeographicProjection;C.projectTo2D=function(e,t,a){const i=(t=r.defaultValue(t,J)).ellipsoid;let s=e.center;const c=e.radius;let o;o=n.Cartesian3.equals(s,n.Cartesian3.ZERO)?n.Cartesian3.clone(n.Cartesian3.UNIT_X,v):i.geodeticSurfaceNormal(s,v);const u=n.Cartesian3.cross(n.Cartesian3.UNIT_Z,o,A);n.Cartesian3.normalize(u,u);const d=n.Cartesian3.cross(o,u,H);n.Cartesian3.normalize(d,d),n.Cartesian3.multiplyByScalar(o,c,o),n.Cartesian3.multiplyByScalar(d,c,d),n.Cartesian3.multiplyByScalar(u,c,u);const l=n.Cartesian3.negate(d,L),f=n.Cartesian3.negate(u,_),y=F;let m=y[0];n.Cartesian3.add(o,d,m),n.Cartesian3.add(m,u,m),m=y[1],n.Cartesian3.add(o,d,m),n.Cartesian3.add(m,f,m),m=y[2],n.Cartesian3.add(o,l,m),n.Cartesian3.add(m,f,m),m=y[3],n.Cartesian3.add(o,l,m),n.Cartesian3.add(m,u,m),n.Cartesian3.negate(o,o),m=y[4],n.Cartesian3.add(o,d,m),n.Cartesian3.add(m,u,m),m=y[5],n.Cartesian3.add(o,d,m),n.Cartesian3.add(m,f,m),m=y[6],n.Cartesian3.add(o,l,m),n.Cartesian3.add(m,f,m),m=y[7],n.Cartesian3.add(o,l,m),n.Cartesian3.add(m,u,m);const x=y.length;for(let e=0;e<x;++e){const a=y[e];n.Cartesian3.add(s,a,a);const r=i.cartesianToCartographic(a,X);t.project(r,a)}s=(a=C.fromPoints(y,a)).center;const g=s.x,h=s.y,z=s.z;return s.x=z,s.y=g,s.z=h,a},C.isOccluded=function(e,n){return!n.isBoundingSphereVisible(e)},C.equals=function(e,t){return e===t||r.defined(e)&&r.defined(t)&&n.Cartesian3.equals(e.center,t.center)&&e.radius===t.radius},C.prototype.intersectPlane=function(e){return C.intersectPlane(this,e)},C.prototype.distanceSquaredTo=function(e){return C.distanceSquaredTo(this,e)},C.prototype.computePlaneDistances=function(e,n,t){return C.computePlaneDistances(this,e,n,t)},C.prototype.isOccluded=function(e){return C.isOccluded(this,e)},C.prototype.equals=function(e){return C.equals(this,e)},C.prototype.clone=function(e){return C.clone(this,e)},C.prototype.volume=function(){const e=this.radius;return b*e*e*e},e.BoundingSphere=C,e.Intersect=u,e.Interval=d}));