/** * @license * Cesium - https://github.com/CesiumGS/cesium * Version 1.137.0 * * 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{b as U}from"./chunk-BNHFHP3L.js";import{a as ft}from"./chunk-ICY67TC6.js";import{a as i,b}from"./chunk-G2EMNOST.js";import{a as y}from"./chunk-4VFKVGYI.js";import{a as w,b as tt}from"./chunk-3WJNS2B6.js";import{e as g}from"./chunk-XCN226AA.js";var nt={};nt.computeDiscriminant=function(t,n,r){if(typeof t!="number")throw new w("a is a required number.");if(typeof n!="number")throw new w("b is a required number.");if(typeof r!="number")throw new w("c is a required number.");return n*n-4*t*r};function mt(t,n,r){let e=t+n;return y.sign(t)!==y.sign(n)&&Math.abs(e/Math.max(Math.abs(t),Math.abs(n)))f&&f/u0?[a/t,r/a]:[r/a,a/t]};var z=nt;var rt={};rt.computeDiscriminant=function(t,n,r,e){if(typeof t!="number")throw new w("a is a required number.");if(typeof n!="number")throw new w("b is a required number.");if(typeof r!="number")throw new w("c is a required number.");if(typeof e!="number")throw new w("d is a required number.");let o=t*t,s=n*n,c=r*r,a=e*e;return 18*t*n*r*e+s*c-27*o*a-4*(t*c*r+s*n*e)};function et(t,n,r,e){let o=t,s=n/3,c=r/3,a=e,u=o*c,f=s*a,h=s*s,d=c*c,p=o*c-h,q=o*a-s*c,m=s*a-d,l=4*p*m-q*q,E,x;if(l<0){let J,k,G;h*f>=u*d?(J=o,k=p,G=-2*s*p+o*q):(J=a,k=m,G=-a*q+2*c*m);let ut=-(G<0?-1:1)*Math.abs(J)*Math.sqrt(-l);x=-G+ut;let K=x/2,Y=K<0?-Math.pow(-K,1/3):Math.pow(K,1/3),$=x===ut?-Y:-k/Y;return E=k<=0?Y+$:-G/(Y*Y+$*$+k),h*f>=u*d?[(E-s)/o]:[-a/(E+c)]}let v=p,W=-2*s*p+o*q,L=m,B=-a*q+2*c*m,I=Math.sqrt(l),C=Math.sqrt(3)/2,P=Math.abs(Math.atan2(o*I,-W)/3);E=2*Math.sqrt(-v);let R=Math.cos(P);x=E*R;let S=E*(-R/2-C*Math.sin(P)),M=x+S>2*s?x-s:S-s,N=o,D=M/N;P=Math.abs(Math.atan2(a*I,-B)/3),E=2*Math.sqrt(-L),R=Math.cos(P),x=E*R,S=E*(-R/2-C*Math.sin(P));let _=-a,Z=x+S<2*c?x+c:S+c,A=_/Z,Rt=N*Z,at=-M*Z-N*_,bt=M*_,V=(c*at-s*bt)/(-s*at+c*Rt);return D<=V?D<=A?V<=A?[D,V,A]:[D,A,V]:[A,D,V]:D<=A?[V,D,A]:V<=A?[V,A,D]:[A,V,D]}rt.computeRealRoots=function(t,n,r,e){if(typeof t!="number")throw new w("a is a required number.");if(typeof n!="number")throw new w("b is a required number.");if(typeof r!="number")throw new w("c is a required number.");if(typeof e!="number")throw new w("d is a required number.");let o,s;if(t===0)return z.computeRealRoots(n,r,e);if(n===0){if(r===0){if(e===0)return[0,0,0];s=-e/t;let c=s<0?-Math.pow(-s,1/3):Math.pow(s,1/3);return[c,c,c]}else if(e===0)return o=z.computeRealRoots(t,0,r),o.Length===0?[0]:[o[0],0,o[1]];return et(t,0,r,e)}else{if(r===0)return e===0?(s=-n/t,s<0?[s,0,0]:[0,0,s]):et(t,n,0,e);if(e===0)return o=z.computeRealRoots(t,n,r),o.length===0?[0]:o[1]<=0?[o[0],o[1],0]:o[0]>=0?[0,o[0],o[1]]:[o[0],0,o[1]]}return et(t,n,r,e)};var H=rt;var ot={};ot.computeDiscriminant=function(t,n,r,e,o){if(typeof t!="number")throw new w("a is a required number.");if(typeof n!="number")throw new w("b is a required number.");if(typeof r!="number")throw new w("c is a required number.");if(typeof e!="number")throw new w("d is a required number.");if(typeof o!="number")throw new w("e is a required number.");let s=t*t,c=s*t,a=n*n,u=a*n,f=r*r,h=f*r,d=e*e,p=d*e,q=o*o,m=q*o;return a*f*d-4*u*p-4*t*h*d+18*t*n*r*p-27*s*d*d+256*c*m+o*(18*u*r*e-4*a*h+16*t*f*f-80*t*n*f*e-6*t*a*d+144*s*r*d)+q*(144*t*a*r-27*a*a-128*s*f-192*s*n*e)};function T(t,n,r,e){let o=t*t,s=n-3*o/8,c=r-n*t/2+o*t/8,a=e-r*t/4+n*o/16-3*o*o/256,u=H.computeRealRoots(1,2*s,s*s-4*a,-c*c);if(u.length>0){let f=-t/4,h=u[u.length-1];if(Math.abs(h)=0&&q>=0){let l=Math.sqrt(p),E=Math.sqrt(q);return[f-E,f-l,f+l,f+E]}else{if(p>=0&&q<0)return m=Math.sqrt(p),[f-m,f+m];if(p<0&&q>=0)return m=Math.sqrt(q),[f-m,f+m]}}return[]}else if(h>0){let d=Math.sqrt(h),p=(s+h-c/d)/2,q=(s+h+c/d)/2,m=z.computeRealRoots(1,d,p),l=z.computeRealRoots(1,-d,q);return m.length!==0?(m[0]+=f,m[1]+=f,l.length!==0?(l[0]+=f,l[1]+=f,m[1]<=l[0]?[m[0],m[1],l[0],l[1]]:l[1]<=m[0]?[l[0],l[1],m[0],m[1]]:m[0]>=l[0]&&m[1]<=l[1]?[l[0],m[0],m[1],l[1]]:l[0]>=m[0]&&l[1]<=m[1]?[m[0],l[0],l[1],m[1]]:m[0]>l[0]&&m[0]0){let d=h[0],p=n-d,q=p*p,m=t/2,l=p/2,E=q-4*e,x=q+4*Math.abs(e),v=c-4*d,W=c+4*Math.abs(d),L,B;if(d<0||E*W=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]h)||(p=i.cross(d,a,lt),m=i.dot(c,p),m<0||q+m>h))return;l=i.dot(u,p)/h}else{if(Math.abs(h)1||(p=i.cross(d,a,lt),m=i.dot(c,p)*E,m<0||q+m>1))return;l=i.dot(u,p)*E}return l};O.rayTriangle=function(t,n,r,e,o,s){let c=O.rayTriangleParametric(t,n,r,e,o);if(!(!g(c)||c<0))return g(s)||(s=new i),i.multiplyByScalar(t.direction,c,s),i.add(t.origin,s,s)};var Et=new it;O.lineSegmentTriangle=function(t,n,r,e,o,s,c){if(!g(t))throw new w("v0 is required.");if(!g(n))throw new w("v1 is required.");if(!g(r))throw new w("p0 is required.");if(!g(e))throw new w("p1 is required.");if(!g(o))throw new w("p2 is required.");let a=Et;i.clone(t,a.origin),i.subtract(n,t,a.direction),i.normalize(a.direction,a.direction);let u=O.rayTriangleParametric(a,r,e,o,s);if(!(!g(u)||u<0||u>i.distance(t,n)))return g(c)||(c=new i),i.multiplyByScalar(a.direction,u,c),i.add(a.origin,c,c)};function Ct(t,n,r,e){let o=n*n-4*t*r;if(o<0)return;if(o>0){let c=1/(2*t),a=Math.sqrt(o),u=(-n+a)*c,f=(-n-a)*c;return uc))return e.start=Math.max(e.start,0),e.stop=Math.min(e.stop,c),e};var It=new i,xt=new i;O.rayEllipsoid=function(t,n){if(!g(t))throw new w("ray is required.");if(!g(n))throw new w("ellipsoid is required.");let r=n.oneOverRadii,e=i.multiplyComponents(r,t.origin,It),o=i.multiplyComponents(r,t.direction,xt),s=i.magnitudeSquared(e),c=i.dot(e,o),a,u,f,h,d;if(s>1){if(c>=0)return;let p=c*c;if(a=s-1,u=i.magnitudeSquared(o),f=u*a,pf){h=c*c-f,d=-c+Math.sqrt(h);let m=d/u,l=a/d;return mo.start?e.start:o.start,r.stop=e.stopo.stop||o.start>e.stop)&&!(r.start>s.stop||s.start>r.stop))return s.start>r.start&&(r.start=s.start),s.stop0?q.push(new i(e,o*R,o*-N)):N!==0?(q.push(new i(e,o*R,o*-N)),q.push(new i(e,o*R,o*N)),++P):q.push(new i(e,o*R,o*N))}return q};var ct=new i,wt=new i,qt=new i,F=new i,Tt=new i,vt=new b,Wt=new b,At=new b,Ut=new b,Vt=new b,gt=new b,pt=new b,St=new i,Qt=new i,Zt=new ft;O.grazingAltitudeLocation=function(t,n){if(!g(t))throw new w("ray is required.");if(!g(n))throw new w("ellipsoid is required.");let r=t.origin,e=t.direction;if(!i.equals(r,i.ZERO)){let I=n.geodeticSurfaceNormal(r,ct);if(i.dot(e,I)>=0)return r}let o=g(this.rayEllipsoid(t,n)),s=n.transformPositionToScaledSpace(e,ct),c=i.normalize(s,s),a=i.mostOrthogonalAxis(s,F),u=i.normalize(i.cross(a,c,wt),wt),f=i.normalize(i.cross(c,u,qt),qt),h=vt;h[0]=c.x,h[1]=c.y,h[2]=c.z,h[3]=u.x,h[4]=u.y,h[5]=u.z,h[6]=f.x,h[7]=f.y,h[8]=f.z;let d=b.transpose(h,Wt),p=b.fromScale(n.radii,At),q=b.fromScale(n.oneOverRadii,Ut),m=Vt;m[0]=0,m[1]=-e.z,m[2]=e.y,m[3]=e.z,m[4]=0,m[5]=-e.x,m[6]=-e.y,m[7]=e.x,m[8]=0;let l=b.multiply(b.multiply(d,q,gt),m,gt),E=b.multiply(b.multiply(l,p,pt),h,pt),x=b.multiplyByVector(l,r,Tt),v=O.quadraticVectorExpression(E,i.negate(x,ct),0,0,1),W,L,B=v.length;if(B>0){let I=i.clone(i.ZERO,Qt),C=Number.NEGATIVE_INFINITY;for(let R=0;RC&&(C=M,I=i.clone(W,I))}let P=n.cartesianToCartographic(I,Zt);return C=y.clamp(C,0,1),L=i.magnitude(i.subtract(I,r,F))*Math.sqrt(1-C*C),L=o?-L:L,P.height=L,n.cartographicToCartesian(P,new i)}};var _t=new i;O.lineSegmentPlane=function(t,n,r,e){if(!g(t))throw new w("endPoint0 is required.");if(!g(n))throw new w("endPoint1 is required.");if(!g(r))throw new w("plane is required.");g(e)||(e=new i);let o=i.subtract(n,t,_t),s=r.normal,c=i.dot(s,o);if(Math.abs(c)1))return i.multiplyByScalar(o,u,e),i.add(t,e,e),e};O.trianglePlaneIntersection=function(t,n,r,e){if(!g(t)||!g(n)||!g(r)||!g(e))throw new w("p0, p1, p2, and plane are required.");let o=e.normal,s=e.distance,c=i.dot(o,t)+s<0,a=i.dot(o,n)+s<0,u=i.dot(o,r)+s<0,f=0;f+=c?1:0,f+=a?1:0,f+=u?1:0;let h,d;if((f===1||f===2)&&(h=new i,d=new i),f===1){if(c)return O.lineSegmentPlane(t,n,e,h),O.lineSegmentPlane(t,r,e,d),{positions:[t,n,r,h,d],indices:[0,3,4,1,2,4,1,4,3]};if(a)return O.lineSegmentPlane(n,r,e,h),O.lineSegmentPlane(n,t,e,d),{positions:[t,n,r,h,d],indices:[1,3,4,2,0,4,2,4,3]};if(u)return O.lineSegmentPlane(r,t,e,h),O.lineSegmentPlane(r,n,e,d),{positions:[t,n,r,h,d],indices:[2,3,4,0,1,4,0,4,3]}}else if(f===2)if(c)if(a){if(!u)return O.lineSegmentPlane(t,r,e,h),O.lineSegmentPlane(n,r,e,d),{positions:[t,n,r,h,d],indices:[0,1,4,0,4,3,2,3,4]}}else return O.lineSegmentPlane(r,n,e,h),O.lineSegmentPlane(t,n,e,d),{positions:[t,n,r,h,d],indices:[2,0,4,2,4,3,1,3,4]};else return O.lineSegmentPlane(n,t,e,h),O.lineSegmentPlane(r,t,e,d),{positions:[t,n,r,h,d],indices:[1,2,4,1,4,3,0,3,4]}};var gn=O;export{it as a,gn as b};