/** * @license * Cesium - https://github.com/CesiumGS/cesium * Version 1.144.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-VPJRLZMB.js";import{a as ft}from"./chunk-WORPNHJT.js";import{a as i,b}from"./chunk-SWCW4GSU.js";import{a as y}from"./chunk-PZM5FOOW.js";import{a as w,b as $}from"./chunk-3MNKUQ6L.js";import{f as g}from"./chunk-J4SK6SKL.js";var tt={};tt.computeDiscriminant=function(t,r,e){if(typeof t!="number")throw new w("a is a required number.");if(typeof r!="number")throw new w("b is a required number.");if(typeof e!="number")throw new w("c is a required number.");return r*r-4*t*e};function mt(t,r,e){let n=t+r;return y.sign(t)!==y.sign(r)&&Math.abs(n/Math.max(Math.abs(t),Math.abs(r)))f&&f/u0?[a/t,e/a]:[e/a,a/t]};var z=tt;var et={};et.computeDiscriminant=function(t,r,e,n){if(typeof t!="number")throw new w("a is a required number.");if(typeof r!="number")throw new w("b is a required number.");if(typeof e!="number")throw new w("c is a required number.");if(typeof n!="number")throw new w("d is a required number.");let o=t*t,s=r*r,c=e*e,a=n*n;return 18*t*r*e*n+s*c-27*o*a-4*(t*c*e+s*r*n)};function nt(t,r,e,n){let o=t,s=r/3,c=e/3,a=n,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 F,G,_;h*f>=u*d?(F=o,G=p,_=-2*s*p+o*q):(F=a,G=m,_=-a*q+2*c*m);let ut=-(_<0?-1:1)*Math.abs(F)*Math.sqrt(-l);x=-_+ut;let J=x/2,Y=J<0?-Math.pow(-J,1/3):Math.pow(J,1/3),K=x===ut?-Y:-G/Y;return E=G<=0?Y+K:-_/(Y*Y+K*K+G),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 k=-a,Z=x+S<2*c?x+c:S+c,A=k/Z,Rt=N*Z,at=-M*Z-N*k,bt=M*k,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]}et.computeRealRoots=function(t,r,e,n){if(typeof t!="number")throw new w("a is a required number.");if(typeof r!="number")throw new w("b is a required number.");if(typeof e!="number")throw new w("c is a required number.");if(typeof n!="number")throw new w("d is a required number.");let o,s;if(t===0)return z.computeRealRoots(r,e,n);if(r===0){if(e===0){if(n===0)return[0,0,0];s=-n/t;let c=s<0?-Math.pow(-s,1/3):Math.pow(s,1/3);return[c,c,c]}else if(n===0)return o=z.computeRealRoots(t,0,e),o.Length===0?[0]:[o[0],0,o[1]];return nt(t,0,e,n)}else{if(e===0)return n===0?(s=-r/t,s<0?[s,0,0]:[0,0,s]):nt(t,r,0,n);if(n===0)return o=z.computeRealRoots(t,r,e),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 nt(t,r,e,n)};var H=et;var rt={};rt.computeDiscriminant=function(t,r,e,n,o){if(typeof t!="number")throw new w("a is a required number.");if(typeof r!="number")throw new w("b is a required number.");if(typeof e!="number")throw new w("c is a required number.");if(typeof n!="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=r*r,u=a*r,f=e*e,h=f*e,d=n*n,p=d*n,q=o*o,m=q*o;return a*f*d-4*u*p-4*t*h*d+18*t*r*e*p-27*s*d*d+256*c*m+o*(18*u*e*n-4*a*h+16*t*f*f-80*t*r*f*n-6*t*a*d+144*s*e*d)+q*(144*t*a*e-27*a*a-128*s*f-192*s*r*n)};function T(t,r,e,n){let o=t*t,s=r-3*o/8,c=e-r*t/2+o*t/8,a=n-e*t/4+r*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=r-d,q=p*p,m=t/2,l=p/2,E=q-4*n,x=q+4*Math.abs(n),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,r,e,n,o,s){let c=O.rayTriangleParametric(t,r,e,n,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,r,e,n,o,s,c){if(!g(t))throw new w("v0 is required.");if(!g(r))throw new w("v1 is required.");if(!g(e))throw new w("p0 is required.");if(!g(n))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(r,t,a.direction),i.normalize(a.direction,a.direction);let u=O.rayTriangleParametric(a,e,n,o,s);if(!(!g(u)||u<0||u>i.distance(t,r)))return g(c)||(c=new i),i.multiplyByScalar(a.direction,u,c),i.add(a.origin,c,c)};function Ct(t,r,e,n){let o=r*r-4*t*e;if(o<0)return;if(o>0){let c=1/(2*t),a=Math.sqrt(o),u=(-r+a)*c,f=(-r-a)*c;return uc))return n.start=Math.max(n.start,0),n.stop=Math.min(n.stop,c),n};var It=new i,xt=new i;O.rayEllipsoid=function(t,r){if(!g(t))throw new w("ray is required.");if(!g(r))throw new w("ellipsoid is required.");let e=r.oneOverRadii,n=i.multiplyComponents(e,t.origin,It),o=i.multiplyComponents(e,t.direction,xt),s=i.magnitudeSquared(n),c=i.dot(n,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?n.start:o.start,e.stop=n.stopo.stop||o.start>n.stop)&&!(e.start>s.stop||s.start>e.stop))return s.start>e.start&&(e.start=s.start),s.stop0?q.push(new i(n,o*R,o*-N)):N!==0?(q.push(new i(n,o*R,o*-N)),q.push(new i(n,o*R,o*N)),++P):q.push(new i(n,o*R,o*N))}return q};var ct=new i,wt=new i,qt=new i,X=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,r){if(!g(t))throw new w("ray is required.");if(!g(r))throw new w("ellipsoid is required.");let e=t.origin,n=t.direction;if(!i.equals(e,i.ZERO)){let I=r.geodeticSurfaceNormal(e,ct);if(i.dot(n,I)>=0)return e}let o=g(this.rayEllipsoid(t,r)),s=r.transformPositionToScaledSpace(n,ct),c=i.normalize(s,s),a=i.mostOrthogonalAxis(s,X),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(r.radii,At),q=b.fromScale(r.oneOverRadii,Ut),m=Vt;m[0]=0,m[1]=-n.z,m[2]=n.y,m[3]=n.z,m[4]=0,m[5]=-n.x,m[6]=-n.y,m[7]=n.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,e,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=r.cartesianToCartographic(I,Zt);return C=y.clamp(C,0,1),L=i.magnitude(i.subtract(I,e,X))*Math.sqrt(1-C*C),L=o?-L:L,P.height=L,r.cartographicToCartesian(P,new i)}};var kt=new i;O.lineSegmentPlane=function(t,r,e,n){if(!g(t))throw new w("endPoint0 is required.");if(!g(r))throw new w("endPoint1 is required.");if(!g(e))throw new w("plane is required.");g(n)||(n=new i);let o=i.subtract(r,t,kt),s=e.normal,c=i.dot(s,o);if(Math.abs(c)1))return i.multiplyByScalar(o,u,n),i.add(t,n,n),n};O.trianglePlaneIntersection=function(t,r,e,n){if(!g(t)||!g(r)||!g(e)||!g(n))throw new w("p0, p1, p2, and plane are required.");let o=n.normal,s=n.distance,c=i.dot(o,t)+s<0,a=i.dot(o,r)+s<0,u=i.dot(o,e)+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,r,n,h),O.lineSegmentPlane(t,e,n,d),{positions:[t,r,e,h,d],indices:[0,3,4,1,2,4,1,4,3]};if(a)return O.lineSegmentPlane(r,e,n,h),O.lineSegmentPlane(r,t,n,d),{positions:[t,r,e,h,d],indices:[1,3,4,2,0,4,2,4,3]};if(u)return O.lineSegmentPlane(e,t,n,h),O.lineSegmentPlane(e,r,n,d),{positions:[t,r,e,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,e,n,h),O.lineSegmentPlane(r,e,n,d),{positions:[t,r,e,h,d],indices:[0,1,4,0,4,3,2,3,4]}}else return O.lineSegmentPlane(e,r,n,h),O.lineSegmentPlane(t,r,n,d),{positions:[t,r,e,h,d],indices:[2,0,4,2,4,3,1,3,4]};else return O.lineSegmentPlane(r,t,n,h),O.lineSegmentPlane(e,t,n,d),{positions:[t,r,e,h,d],indices:[1,2,4,1,4,3,0,3,4]}};var gn=O;export{it as a,gn as b};