You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
15 KiB

/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.128
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import{c as Z}from"./chunk-LS5UR5C2.js";import{a as o,b as at,e as b}from"./chunk-KLDIEE7M.js";import{a as R}from"./chunk-BF7B4FIR.js";import{a as w,b as tt}from"./chunk-IQDUXDOM.js";import{e as g}from"./chunk-GDY26PU3.js";var et={};et.computeDiscriminant=function(t,e,r){if(typeof t!="number")throw new w("a is a required number.");if(typeof e!="number")throw new w("b is a required number.");if(typeof r!="number")throw new w("c is a required number.");return e*e-4*t*r};function ft(t,e,r){let n=t+e;return R.sign(t)!==R.sign(e)&&Math.abs(n/Math.max(Math.abs(t),Math.abs(e)))<r?0:n}et.computeRealRoots=function(t,e,r){if(typeof t!="number")throw new w("a is a required number.");if(typeof e!="number")throw new w("b is a required number.");if(typeof r!="number")throw new w("c is a required number.");let n;if(t===0)return e===0?[]:[-r/e];if(e===0){if(r===0)return[0,0];let a=Math.abs(r),f=Math.abs(t);if(a<f&&a/f<R.EPSILON14)return[0,0];if(a>f&&f/a<R.EPSILON14)return[];if(n=-r/t,n<0)return[];let l=Math.sqrt(n);return[-l,l]}else if(r===0)return n=-e/t,n<0?[n,0]:[0,n];let i=e*e,c=4*t*r,s=ft(i,-c,R.EPSILON14);if(s<0)return[];let u=-.5*ft(e,R.sign(e)*Math.sqrt(s),R.EPSILON14);return e>0?[u/t,r/u]:[r/u,u/t]};var T=et;var rt={};rt.computeDiscriminant=function(t,e,r,n){if(typeof t!="number")throw new w("a is a required number.");if(typeof e!="number")throw new w("b is a required number.");if(typeof r!="number")throw new w("c is a required number.");if(typeof n!="number")throw new w("d is a required number.");let i=t*t,c=e*e,s=r*r,u=n*n;return 18*t*e*r*n+c*s-27*i*u-4*(t*s*r+c*e*n)};function nt(t,e,r,n){let i=t,c=e/3,s=r/3,u=n,a=i*s,f=c*u,l=c*c,m=s*s,p=i*s-l,q=i*u-c*s,d=c*u-m,h=4*p*d-q*q,E,D;if(h<0){let K,k,G;l*f>=a*m?(K=i,k=p,G=-2*c*p+i*q):(K=u,k=d,G=-u*q+2*s*d);let ut=-(G<0?-1:1)*Math.abs(K)*Math.sqrt(-h);D=-G+ut;let X=D/2,j=X<0?-Math.pow(-X,1/3):Math.pow(X,1/3),$=D===ut?-j:-k/j;return E=k<=0?j+$:-G/(j*j+$*$+k),l*f>=a*m?[(E-c)/i]:[-u/(E+s)]}let W=p,v=-2*c*p+i*q,L=d,B=-u*q+2*s*d,I=Math.sqrt(h),C=Math.sqrt(3)/2,P=Math.abs(Math.atan2(i*I,-v)/3);E=2*Math.sqrt(-W);let y=Math.cos(P);D=E*y;let S=E*(-y/2-C*Math.sin(P)),M=D+S>2*c?D-c:S-c,N=i,x=M/N;P=Math.abs(Math.atan2(u*I,-B)/3),E=2*Math.sqrt(-L),y=Math.cos(P),D=E*y,S=E*(-y/2-C*Math.sin(P));let _=-u,A=D+S<2*s?D+s:S+s,U=_/A,Rt=N*A,ct=-M*A-N*_,yt=M*_,V=(s*ct-c*yt)/(-c*ct+s*Rt);return x<=V?x<=U?V<=U?[x,V,U]:[x,U,V]:[U,x,V]:x<=U?[V,x,U]:V<=U?[V,U,x]:[U,V,x]}rt.computeRealRoots=function(t,e,r,n){if(typeof t!="number")throw new w("a is a required number.");if(typeof e!="number")throw new w("b is a required number.");if(typeof r!="number")throw new w("c is a required number.");if(typeof n!="number")throw new w("d is a required number.");let i,c;if(t===0)return T.computeRealRoots(e,r,n);if(e===0){if(r===0){if(n===0)return[0,0,0];c=-n/t;let s=c<0?-Math.pow(-c,1/3):Math.pow(c,1/3);return[s,s,s]}else if(n===0)return i=T.computeRealRoots(t,0,r),i.Length===0?[0]:[i[0],0,i[1]];return nt(t,0,r,n)}else{if(r===0)return n===0?(c=-e/t,c<0?[c,0,0]:[0,0,c]):nt(t,e,0,n);if(n===0)return i=T.computeRealRoots(t,e,r),i.length===0?[0]:i[1]<=0?[i[0],i[1],0]:i[0]>=0?[0,i[0],i[1]]:[i[0],0,i[1]]}return nt(t,e,r,n)};var Y=rt;var ot={};ot.computeDiscriminant=function(t,e,r,n,i){if(typeof t!="number")throw new w("a is a required number.");if(typeof e!="number")throw new w("b is a required number.");if(typeof r!="number")throw new w("c is a required number.");if(typeof n!="number")throw new w("d is a required number.");if(typeof i!="number")throw new w("e is a required number.");let c=t*t,s=c*t,u=e*e,a=u*e,f=r*r,l=f*r,m=n*n,p=m*n,q=i*i,d=q*i;return u*f*m-4*a*p-4*t*l*m+18*t*e*r*p-27*c*m*m+256*s*d+i*(18*a*r*n-4*u*l+16*t*f*f-80*t*e*f*n-6*t*u*m+144*c*r*m)+q*(144*t*u*r-27*u*u-128*c*f-192*c*e*n)};function z(t,e,r,n){let i=t*t,c=e-3*i/8,s=r-e*t/2+i*t/8,u=n-r*t/4+e*i/16-3*i*i/256,a=Y.computeRealRoots(1,2*c,c*c-4*u,-s*s);if(a.length>0){let f=-t/4,l=a[a.length-1];if(Math.abs(l)<R.EPSILON14){let m=T.computeRealRoots(1,c,u);if(m.length===2){let p=m[0],q=m[1],d;if(p>=0&&q>=0){let h=Math.sqrt(p),E=Math.sqrt(q);return[f-E,f-h,f+h,f+E]}else{if(p>=0&&q<0)return d=Math.sqrt(p),[f-d,f+d];if(p<0&&q>=0)return d=Math.sqrt(q),[f-d,f+d]}}return[]}else if(l>0){let m=Math.sqrt(l),p=(c+l-s/m)/2,q=(c+l+s/m)/2,d=T.computeRealRoots(1,m,p),h=T.computeRealRoots(1,-m,q);return d.length!==0?(d[0]+=f,d[1]+=f,h.length!==0?(h[0]+=f,h[1]+=f,d[1]<=h[0]?[d[0],d[1],h[0],h[1]]:h[1]<=d[0]?[h[0],h[1],d[0],d[1]]:d[0]>=h[0]&&d[1]<=h[1]?[h[0],d[0],d[1],h[1]]:h[0]>=d[0]&&h[1]<=d[1]?[d[0],h[0],h[1],d[1]]:d[0]>h[0]&&d[0]<h[1]?[h[0],d[0],h[1],d[1]]:[d[0],h[0],d[1],h[1]]):d):h.length!==0?(h[0]+=f,h[1]+=f,h):[]}}return[]}function H(t,e,r,n){let i=r*r,c=e*e,s=t*t,u=-2*e,a=r*t+c-4*n,f=s*n-r*e*t+i,l=Y.computeRealRoots(1,u,a,f);if(l.length>0){let m=l[0],p=e-m,q=p*p,d=t/2,h=p/2,E=q-4*n,D=q+4*Math.abs(n),W=s-4*m,v=s+4*Math.abs(m),L,B;if(m<0||E*v<W*D){let N=Math.sqrt(W);L=N/2,B=N===0?0:(t*h-r)/N}else{let N=Math.sqrt(E);L=N===0?0:(t*h-r)/N,B=N/2}let I,C;d===0&&L===0?(I=0,C=0):R.sign(d)===R.sign(L)?(I=d+L,C=m/I):(C=d-L,I=m/C);let P,y;h===0&&B===0?(P=0,y=0):R.sign(h)===R.sign(B)?(P=h+B,y=n/P):(y=h-B,P=n/y);let S=T.computeRealRoots(1,I,P),M=T.computeRealRoots(1,C,y);if(S.length!==0)return M.length!==0?S[1]<=M[0]?[S[0],S[1],M[0],M[1]]:M[1]<=S[0]?[M[0],M[1],S[0],S[1]]:S[0]>=M[0]&&S[1]<=M[1]?[M[0],S[0],S[1],M[1]]:M[0]>=S[0]&&M[1]<=S[1]?[S[0],M[0],M[1],S[1]]:S[0]>M[0]&&S[0]<M[1]?[M[0],S[0],M[1],S[1]]:[S[0],M[0],S[1],M[1]]:S;if(M.length!==0)return M}return[]}ot.computeRealRoots=function(t,e,r,n,i){if(typeof t!="number")throw new w("a is a required number.");if(typeof e!="number")throw new w("b is a required number.");if(typeof r!="number")throw new w("c is a required number.");if(typeof n!="number")throw new w("d is a required number.");if(typeof i!="number")throw new w("e is a required number.");if(Math.abs(t)<R.EPSILON15)return Y.computeRealRoots(e,r,n,i);let c=e/t,s=r/t,u=n/t,a=i/t,f=c<0?1:0;switch(f+=s<0?f+1:f,f+=u<0?f+1:f,f+=a<0?f+1:f,f){case 0:return z(c,s,u,a);case 1:return H(c,s,u,a);case 2:return H(c,s,u,a);case 3:return z(c,s,u,a);case 4:return z(c,s,u,a);case 5:return H(c,s,u,a);case 6:return z(c,s,u,a);case 7:return z(c,s,u,a);case 8:return H(c,s,u,a);case 9:return z(c,s,u,a);case 10:return z(c,s,u,a);case 11:return H(c,s,u,a);case 12:return z(c,s,u,a);case 13:return z(c,s,u,a);case 14:return z(c,s,u,a);case 15:return z(c,s,u,a);default:return}};var dt=ot;function F(t,e){e=o.clone(e??o.ZERO),o.equals(e,o.ZERO)||o.normalize(e,e),this.origin=o.clone(t??o.ZERO),this.direction=e}F.clone=function(t,e){if(g(t))return g(e)?(e.origin=o.clone(t.origin),e.direction=o.clone(t.direction),e):new F(t.origin,t.direction)};F.getPoint=function(t,e,r){return tt.typeOf.object("ray",t),tt.typeOf.number("t",e),g(r)||(r=new o),r=o.multiplyByScalar(t.direction,e,r),o.add(t.origin,r,r)};var it=F;var O={};O.rayPlane=function(t,e,r){if(!g(t))throw new w("ray is required.");if(!g(e))throw new w("plane is required.");g(r)||(r=new o);let n=t.origin,i=t.direction,c=e.normal,s=o.dot(c,i);if(Math.abs(s)<R.EPSILON15)return;let u=(-e.distance-o.dot(c,n))/s;if(!(u<0))return r=o.multiplyByScalar(i,u,r),o.add(n,r,r)};var bt=new o,Ot=new o,St=new o,mt=new o,lt=new o;O.rayTriangleParametric=function(t,e,r,n,i){if(!g(t))throw new w("ray is required.");if(!g(e))throw new w("p0 is required.");if(!g(r))throw new w("p1 is required.");if(!g(n))throw new w("p2 is required.");i=i??!1;let c=t.origin,s=t.direction,u=o.subtract(r,e,bt),a=o.subtract(n,e,Ot),f=o.cross(s,a,St),l=o.dot(u,f),m,p,q,d,h;if(i){if(l<R.EPSILON6||(m=o.subtract(c,e,mt),q=o.dot(m,f),q<0||q>l)||(p=o.cross(m,u,lt),d=o.dot(s,p),d<0||q+d>l))return;h=o.dot(a,p)/l}else{if(Math.abs(l)<R.EPSILON6)return;let E=1/l;if(m=o.subtract(c,e,mt),q=o.dot(m,f)*E,q<0||q>1||(p=o.cross(m,u,lt),d=o.dot(s,p)*E,d<0||q+d>1))return;h=o.dot(a,p)*E}return h};O.rayTriangle=function(t,e,r,n,i,c){let s=O.rayTriangleParametric(t,e,r,n,i);if(!(!g(s)||s<0))return g(c)||(c=new o),o.multiplyByScalar(t.direction,s,c),o.add(t.origin,c,c)};var Pt=new it;O.lineSegmentTriangle=function(t,e,r,n,i,c,s){if(!g(t))throw new w("v0 is required.");if(!g(e))throw new w("v1 is required.");if(!g(r))throw new w("p0 is required.");if(!g(n))throw new w("p1 is required.");if(!g(i))throw new w("p2 is required.");let u=Pt;o.clone(t,u.origin),o.subtract(e,t,u.direction),o.normalize(u.direction,u.direction);let a=O.rayTriangleParametric(u,r,n,i,c);if(!(!g(a)||a<0||a>o.distance(t,e)))return g(s)||(s=new o),o.multiplyByScalar(u.direction,a,s),o.add(u.origin,s,s)};function Et(t,e,r,n){let i=e*e-4*t*r;if(i<0)return;if(i>0){let s=1/(2*t),u=Math.sqrt(i),a=(-e+u)*s,f=(-e-u)*s;return a<f?(n.root0=a,n.root1=f):(n.root0=f,n.root1=a),n}let c=-e/(2*t);if(c!==0)return n.root0=n.root1=c,n}var Ct={root0:0,root1:0};function Mt(t,e,r){g(r)||(r=new Z);let n=t.origin,i=t.direction,c=e.center,s=e.radius*e.radius,u=o.subtract(n,c,St),a=o.dot(i,i),f=2*o.dot(i,u),l=o.magnitudeSquared(u)-s,m=Et(a,f,l,Ct);if(g(m))return r.start=m.root0,r.stop=m.root1,r}O.raySphere=function(t,e,r){if(!g(t))throw new w("ray is required.");if(!g(e))throw new w("sphere is required.");if(r=Mt(t,e,r),!(!g(r)||r.stop<0))return r.start=Math.max(r.start,0),r};var Nt=new it;O.lineSegmentSphere=function(t,e,r,n){if(!g(t))throw new w("p0 is required.");if(!g(e))throw new w("p1 is required.");if(!g(r))throw new w("sphere is required.");let i=Nt;o.clone(t,i.origin);let c=o.subtract(e,t,i.direction),s=o.magnitude(c);if(o.normalize(c,c),n=Mt(i,r,n),!(!g(n)||n.stop<0||n.start>s))return n.start=Math.max(n.start,0),n.stop=Math.min(n.stop,s),n};var Lt=new o,It=new o;O.rayEllipsoid=function(t,e){if(!g(t))throw new w("ray is required.");if(!g(e))throw new w("ellipsoid is required.");let r=e.oneOverRadii,n=o.multiplyComponents(r,t.origin,Lt),i=o.multiplyComponents(r,t.direction,It),c=o.magnitudeSquared(n),s=o.dot(n,i),u,a,f,l,m;if(c>1){if(s>=0)return;let p=s*s;if(u=c-1,a=o.magnitudeSquared(i),f=a*u,p<f)return;if(p>f){l=s*s-f,m=-s+Math.sqrt(l);let d=m/a,h=u/m;return d<h?new Z(d,h):{start:h,stop:d}}let q=Math.sqrt(u/a);return new Z(q,q)}else if(c<1)return u=c-1,a=o.magnitudeSquared(i),f=a*u,l=s*s-f,m=-s+Math.sqrt(l),new Z(0,m/a);if(s<0)return a=o.magnitudeSquared(i),new Z(0,-s/a)};function Q(t,e,r){let n=t+e;return R.sign(t)!==R.sign(e)&&Math.abs(n/Math.max(Math.abs(t),Math.abs(e)))<r?0:n}O.quadraticVectorExpression=function(t,e,r,n,i){let c=n*n,s=i*i,u=(t[b.COLUMN1ROW1]-t[b.COLUMN2ROW2])*s,a=i*(n*Q(t[b.COLUMN1ROW0],t[b.COLUMN0ROW1],R.EPSILON15)+e.y),f=t[b.COLUMN0ROW0]*c+t[b.COLUMN2ROW2]*s+n*e.x+r,l=s*Q(t[b.COLUMN2ROW1],t[b.COLUMN1ROW2],R.EPSILON15),m=i*(n*Q(t[b.COLUMN2ROW0],t[b.COLUMN0ROW2])+e.z),p,q=[];if(m===0&&l===0){if(p=T.computeRealRoots(u,a,f),p.length===0)return q;let P=p[0],y=Math.sqrt(Math.max(1-P*P,0));if(q.push(new o(n,i*P,i*-y)),q.push(new o(n,i*P,i*y)),p.length===2){let S=p[1],M=Math.sqrt(Math.max(1-S*S,0));q.push(new o(n,i*S,i*-M)),q.push(new o(n,i*S,i*M))}return q}let d=m*m,h=l*l,E=u*u,D=m*l,W=E+h,v=2*(a*u+D),L=2*f*u+a*a-h+d,B=2*(f*a-D),I=f*f-d;if(W===0&&v===0&&L===0&&B===0)return q;p=dt.computeRealRoots(W,v,L,B,I);let C=p.length;if(C===0)return q;for(let P=0;P<C;++P){let y=p[P],S=y*y,M=Math.max(1-S,0),N=Math.sqrt(M),x;R.sign(u)===R.sign(f)?x=Q(u*S+f,a*y,R.EPSILON12):R.sign(f)===R.sign(a*y)?x=Q(u*S,a*y+f,R.EPSILON12):x=Q(u*S+a*y,f,R.EPSILON12);let _=Q(l*y,m,R.EPSILON15),A=x*_;A<0?q.push(new o(n,i*y,i*N)):A>0?q.push(new o(n,i*y,i*-N)):N!==0?(q.push(new o(n,i*y,i*-N)),q.push(new o(n,i*y,i*N)),++P):q.push(new o(n,i*y,i*N))}return q};var st=new o,ht=new o,wt=new o,J=new o,Dt=new o,Bt=new b,xt=new b,Tt=new b,zt=new b,Wt=new b,qt=new b,gt=new b,pt=new o,vt=new o,Ut=new at;O.grazingAltitudeLocation=function(t,e){if(!g(t))throw new w("ray is required.");if(!g(e))throw new w("ellipsoid is required.");let r=t.origin,n=t.direction;if(!o.equals(r,o.ZERO)){let I=e.geodeticSurfaceNormal(r,st);if(o.dot(n,I)>=0)return r}let i=g(this.rayEllipsoid(t,e)),c=e.transformPositionToScaledSpace(n,st),s=o.normalize(c,c),u=o.mostOrthogonalAxis(c,J),a=o.normalize(o.cross(u,s,ht),ht),f=o.normalize(o.cross(s,a,wt),wt),l=Bt;l[0]=s.x,l[1]=s.y,l[2]=s.z,l[3]=a.x,l[4]=a.y,l[5]=a.z,l[6]=f.x,l[7]=f.y,l[8]=f.z;let m=b.transpose(l,xt),p=b.fromScale(e.radii,Tt),q=b.fromScale(e.oneOverRadii,zt),d=Wt;d[0]=0,d[1]=-n.z,d[2]=n.y,d[3]=n.z,d[4]=0,d[5]=-n.x,d[6]=-n.y,d[7]=n.x,d[8]=0;let h=b.multiply(b.multiply(m,q,qt),d,qt),E=b.multiply(b.multiply(h,p,gt),l,gt),D=b.multiplyByVector(h,r,Dt),W=O.quadraticVectorExpression(E,o.negate(D,st),0,0,1),v,L,B=W.length;if(B>0){let I=o.clone(o.ZERO,vt),C=Number.NEGATIVE_INFINITY;for(let y=0;y<B;++y){v=b.multiplyByVector(p,b.multiplyByVector(l,W[y],pt),pt);let S=o.normalize(o.subtract(v,r,J),J),M=o.dot(S,n);M>C&&(C=M,I=o.clone(v,I))}let P=e.cartesianToCartographic(I,Ut);return C=R.clamp(C,0,1),L=o.magnitude(o.subtract(I,r,J))*Math.sqrt(1-C*C),L=i?-L:L,P.height=L,e.cartographicToCartesian(P,new o)}};var Vt=new o;O.lineSegmentPlane=function(t,e,r,n){if(!g(t))throw new w("endPoint0 is required.");if(!g(e))throw new w("endPoint1 is required.");if(!g(r))throw new w("plane is required.");g(n)||(n=new o);let i=o.subtract(e,t,Vt),c=r.normal,s=o.dot(c,i);if(Math.abs(s)<R.EPSILON6)return;let u=o.dot(c,t),a=-(r.distance+u)/s;if(!(a<0||a>1))return o.multiplyByScalar(i,a,n),o.add(t,n,n),n};O.trianglePlaneIntersection=function(t,e,r,n){if(!g(t)||!g(e)||!g(r)||!g(n))throw new w("p0, p1, p2, and plane are required.");let i=n.normal,c=n.distance,s=o.dot(i,t)+c<0,u=o.dot(i,e)+c<0,a=o.dot(i,r)+c<0,f=0;f+=s?1:0,f+=u?1:0,f+=a?1:0;let l,m;if((f===1||f===2)&&(l=new o,m=new o),f===1){if(s)return O.lineSegmentPlane(t,e,n,l),O.lineSegmentPlane(t,r,n,m),{positions:[t,e,r,l,m],indices:[0,3,4,1,2,4,1,4,3]};if(u)return O.lineSegmentPlane(e,r,n,l),O.lineSegmentPlane(e,t,n,m),{positions:[t,e,r,l,m],indices:[1,3,4,2,0,4,2,4,3]};if(a)return O.lineSegmentPlane(r,t,n,l),O.lineSegmentPlane(r,e,n,m),{positions:[t,e,r,l,m],indices:[2,3,4,0,1,4,0,4,3]}}else if(f===2)if(s)if(u){if(!a)return O.lineSegmentPlane(t,r,n,l),O.lineSegmentPlane(e,r,n,m),{positions:[t,e,r,l,m],indices:[0,1,4,0,4,3,2,3,4]}}else return O.lineSegmentPlane(r,e,n,l),O.lineSegmentPlane(t,e,n,m),{positions:[t,e,r,l,m],indices:[2,0,4,2,4,3,1,3,4]};else return O.lineSegmentPlane(e,t,n,l),O.lineSegmentPlane(r,t,n,m),{positions:[t,e,r,l,m],indices:[1,2,4,1,4,3,0,3,4]}};var me=O;export{it as a,me as b};