/** * @license * Cesium - https://github.com/CesiumGS/cesium * Version 1.99 * * 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. */ define(["exports","./Matrix3-edb29a7e","./defaultValue-135942ca","./Transforms-3ea76111","./Math-a304e2d6"],(function(t,n,e,a,i){"use strict";const r={};function s(t,n,e){const a=t+n;return i.CesiumMath.sign(t)!==i.CesiumMath.sign(n)&&Math.abs(a/Math.max(Math.abs(t),Math.abs(n)))r&&r/n0?[o/t,e/o]:[e/o,o/t]};var o=r;const c={};function u(t,n,e,a){const i=t,r=n/3,s=e/3,o=a,c=i*s,u=r*o,l=r*r,C=s*s,M=i*s-l,h=i*o-r*s,m=r*o-C,d=4*M*m-h*h;let f,g;if(d<0){let t,n,e;l*u>=c*C?(t=i,n=M,e=-2*r*M+i*h):(t=o,n=m,e=-o*h+2*s*m);const a=-(e<0?-1:1)*Math.abs(t)*Math.sqrt(-d);g=-e+a;const p=g/2,w=p<0?-Math.pow(-p,1/3):Math.pow(p,1/3),R=g===a?-w:-n/w;return f=n<=0?w+R:-e/(w*w+R*R+n),l*u>=c*C?[(f-r)/i]:[-o/(f+s)]}const p=M,w=-2*r*M+i*h,R=m,S=-o*h+2*s*m,O=Math.sqrt(d),x=Math.sqrt(3)/2;let y=Math.abs(Math.atan2(i*O,-w)/3);f=2*Math.sqrt(-p);let P=Math.cos(y);g=f*P;let N=f*(-P/2-x*Math.sin(y));const b=g+N>2*r?g-r:N-r,q=i,L=b/q;y=Math.abs(Math.atan2(o*O,-S)/3),f=2*Math.sqrt(-R),P=Math.cos(y),g=f*P,N=f*(-P/2-x*Math.sin(y));const I=-o,E=g+N<2*s?g+s:N+s,v=I/E,z=-b*E-q*I,T=(s*z-r*(b*I))/(-r*z+s*(q*E));return L<=T?L<=v?T<=v?[L,T,v]:[L,v,T]:[v,L,T]:L<=v?[T,L,v]:T<=v?[T,v,L]:[v,T,L]}c.computeDiscriminant=function(t,n,e,a){const i=n*n,r=e*e;return 18*t*n*e*a+i*r-27*(t*t)*(a*a)-4*(t*r*e+i*n*a)},c.computeRealRoots=function(t,n,e,a){let i,r;if(0===t)return o.computeRealRoots(n,e,a);if(0===n){if(0===e){if(0===a)return[0,0,0];r=-a/t;const n=r<0?-Math.pow(-r,1/3):Math.pow(r,1/3);return[n,n,n]}return 0===a?(i=o.computeRealRoots(t,0,e),0===i.Length?[0]:[i[0],0,i[1]]):u(t,0,e,a)}return 0===e?0===a?(r=-n/t,r<0?[r,0,0]:[0,0,r]):u(t,n,0,a):0===a?(i=o.computeRealRoots(t,n,e),0===i.length?[0]:i[1]<=0?[i[0],i[1],0]:i[0]>=0?[0,i[0],i[1]]:[i[0],0,i[1]]):u(t,n,e,a)};var l=c;const C={};function M(t,n,e,a){const r=t*t,s=n-3*r/8,c=e-n*t/2+r*t/8,u=a-e*t/4+n*r/16-3*r*r/256,C=l.computeRealRoots(1,2*s,s*s-4*u,-c*c);if(C.length>0){const n=-t/4,e=C[C.length-1];if(Math.abs(e)=0&&a>=0){const t=Math.sqrt(e),i=Math.sqrt(a);return[n-i,n-t,n+t,n+i]}if(e>=0&&a<0)return i=Math.sqrt(e),[n-i,n+i];if(e<0&&a>=0)return i=Math.sqrt(a),[n-i,n+i]}return[]}if(e>0){const t=Math.sqrt(e),a=(s+e-c/t)/2,i=(s+e+c/t)/2,r=o.computeRealRoots(1,t,a),u=o.computeRealRoots(1,-t,i);return 0!==r.length?(r[0]+=n,r[1]+=n,0!==u.length?(u[0]+=n,u[1]+=n,r[1]<=u[0]?[r[0],r[1],u[0],u[1]]:u[1]<=r[0]?[u[0],u[1],r[0],r[1]]:r[0]>=u[0]&&r[1]<=u[1]?[u[0],r[0],r[1],u[1]]:u[0]>=r[0]&&u[1]<=r[1]?[r[0],u[0],u[1],r[1]]:r[0]>u[0]&&r[0]0){const s=C[0],c=n-s,u=c*c,l=t/2,M=c/2,h=u-4*a,m=u+4*Math.abs(a),d=r-4*s,f=r+4*Math.abs(s);let g,p,w,R,S,O;if(s<0||h*f=y[0]&&x[1]<=y[1]?[y[0],x[0],x[1],y[1]]:y[0]>=x[0]&&y[1]<=x[1]?[x[0],y[0],y[1],x[1]]:x[0]>y[0]&&x[0]h)return;if(d=n.Cartesian3.cross(m,l,S),O=n.Cartesian3.dot(u,d),O<0||f+O>h)return;x=n.Cartesian3.dot(C,d)/h}else{if(Math.abs(h)1)return;if(d=n.Cartesian3.cross(m,l,S),O=n.Cartesian3.dot(u,d)*t,O<0||f+O>1)return;x=n.Cartesian3.dot(C,d)*t}return x},f.rayTriangle=function(t,a,i,r,s,o){const c=f.rayTriangleParametric(t,a,i,r,s);if(e.defined(c)&&!(c<0))return e.defined(o)||(o=new n.Cartesian3),n.Cartesian3.multiplyByScalar(t.direction,c,o),n.Cartesian3.add(t.origin,o,o)};const O=new d;f.lineSegmentTriangle=function(t,a,i,r,s,o,c){const u=O;n.Cartesian3.clone(t,u.origin),n.Cartesian3.subtract(a,t,u.direction),n.Cartesian3.normalize(u.direction,u.direction);const l=f.rayTriangleParametric(u,i,r,s,o);if(!(!e.defined(l)||l<0||l>n.Cartesian3.distance(t,a)))return e.defined(c)||(c=new n.Cartesian3),n.Cartesian3.multiplyByScalar(u.direction,l,c),n.Cartesian3.add(u.origin,c,c)};const x={root0:0,root1:0};function y(t,i,r){e.defined(r)||(r=new a.Interval);const s=t.origin,o=t.direction,c=i.center,u=i.radius*i.radius,l=n.Cartesian3.subtract(s,c,w),C=function(t,n,e,a){const i=n*n-4*t*e;if(i<0)return;if(i>0){const e=1/(2*t),r=Math.sqrt(i),s=(-n+r)*e,o=(-n-r)*e;return sc))return r.start=Math.max(r.start,0),r.stop=Math.min(r.stop,c),r};const N=new n.Cartesian3,b=new n.Cartesian3;function q(t,n,e){const a=t+n;return i.CesiumMath.sign(t)!==i.CesiumMath.sign(n)&&Math.abs(a/Math.max(Math.abs(t),Math.abs(n)))1){if(c>=0)return;const t=c*c;if(u=o-1,l=n.Cartesian3.magnitudeSquared(s),C=l*u,tC){M=c*c-C,h=-c+Math.sqrt(M);const t=h/l,n=u/h;return t=0)return r}const c=e.defined(this.rayEllipsoid(t,a)),u=a.transformPositionToScaledSpace(s,L),l=n.Cartesian3.normalize(u,u),C=n.Cartesian3.mostOrthogonalAxis(u,v),M=n.Cartesian3.normalize(n.Cartesian3.cross(C,l,I),I),h=n.Cartesian3.normalize(n.Cartesian3.cross(l,M,E),E),d=T;d[0]=l.x,d[1]=l.y,d[2]=l.z,d[3]=M.x,d[4]=M.y,d[5]=M.z,d[6]=h.x,d[7]=h.y,d[8]=h.z;const f=n.Matrix3.transpose(d,U),g=n.Matrix3.fromScale(a.radii,W),p=n.Matrix3.fromScale(a.oneOverRadii,B),w=V;w[0]=0,w[1]=-s.z,w[2]=s.y,w[3]=s.z,w[4]=0,w[5]=-s.x,w[6]=-s.y,w[7]=s.x,w[8]=0;const R=n.Matrix3.multiply(n.Matrix3.multiply(f,p,Z),w,Z),S=n.Matrix3.multiply(n.Matrix3.multiply(R,g,A),d,A),O=n.Matrix3.multiplyByVector(R,r,z),x=function(t,e,a,r,s){const c=r*r,u=s*s,l=(t[n.Matrix3.COLUMN1ROW1]-t[n.Matrix3.COLUMN2ROW2])*u,C=s*(r*q(t[n.Matrix3.COLUMN1ROW0],t[n.Matrix3.COLUMN0ROW1],i.CesiumMath.EPSILON15)+e.y),M=t[n.Matrix3.COLUMN0ROW0]*c+t[n.Matrix3.COLUMN2ROW2]*u+r*e.x+a,h=u*q(t[n.Matrix3.COLUMN2ROW1],t[n.Matrix3.COLUMN1ROW2],i.CesiumMath.EPSILON15),d=s*(r*q(t[n.Matrix3.COLUMN2ROW0],t[n.Matrix3.COLUMN0ROW2])+e.z);let f;const g=[];if(0===d&&0===h){if(f=o.computeRealRoots(l,C,M),0===f.length)return g;const t=f[0],e=Math.sqrt(Math.max(1-t*t,0));if(g.push(new n.Cartesian3(r,s*t,s*-e)),g.push(new n.Cartesian3(r,s*t,s*e)),2===f.length){const t=f[1],e=Math.sqrt(Math.max(1-t*t,0));g.push(new n.Cartesian3(r,s*t,s*-e)),g.push(new n.Cartesian3(r,s*t,s*e))}return g}const p=d*d,w=h*h,R=d*h,S=l*l+w,O=2*(C*l+R),x=2*M*l+C*C-w+p,y=2*(M*C-R),P=M*M-p;if(0===S&&0===O&&0===x&&0===y)return g;f=m.computeRealRoots(S,O,x,y,P);const N=f.length;if(0===N)return g;for(let t=0;t0?g.push(new n.Cartesian3(r,s*e,s*-c)):0!==c?(g.push(new n.Cartesian3(r,s*e,s*-c)),g.push(new n.Cartesian3(r,s*e,s*c)),++t):g.push(new n.Cartesian3(r,s*e,s*c))}return g}(S,n.Cartesian3.negate(O,L),0,0,1);let y,P;const N=x.length;if(N>0){let t=n.Cartesian3.clone(n.Cartesian3.ZERO,F),e=Number.NEGATIVE_INFINITY;for(let a=0;ae&&(e=o,t=n.Cartesian3.clone(y,t))}const o=a.cartesianToCartographic(t,G);return e=i.CesiumMath.clamp(e,0,1),P=n.Cartesian3.magnitude(n.Cartesian3.subtract(t,r,v))*Math.sqrt(1-e*e),P=c?-P:P,o.height=P,a.cartographicToCartesian(o,new n.Cartesian3)}};const Y=new n.Cartesian3;f.lineSegmentPlane=function(t,a,r,s){e.defined(s)||(s=new n.Cartesian3);const o=n.Cartesian3.subtract(a,t,Y),c=r.normal,u=n.Cartesian3.dot(c,o);if(Math.abs(u)1?void 0:(n.Cartesian3.multiplyByScalar(o,C,s),n.Cartesian3.add(t,s,s),s)},f.trianglePlaneIntersection=function(t,e,a,i){const r=i.normal,s=i.distance,o=n.Cartesian3.dot(r,t)+s<0,c=n.Cartesian3.dot(r,e)+s<0,u=n.Cartesian3.dot(r,a)+s<0;let l,C,M=0;if(M+=o?1:0,M+=c?1:0,M+=u?1:0,1!==M&&2!==M||(l=new n.Cartesian3,C=new n.Cartesian3),1===M){if(o)return f.lineSegmentPlane(t,e,i,l),f.lineSegmentPlane(t,a,i,C),{positions:[t,e,a,l,C],indices:[0,3,4,1,2,4,1,4,3]};if(c)return f.lineSegmentPlane(e,a,i,l),f.lineSegmentPlane(e,t,i,C),{positions:[t,e,a,l,C],indices:[1,3,4,2,0,4,2,4,3]};if(u)return f.lineSegmentPlane(a,t,i,l),f.lineSegmentPlane(a,e,i,C),{positions:[t,e,a,l,C],indices:[2,3,4,0,1,4,0,4,3]}}else if(2===M){if(!o)return f.lineSegmentPlane(e,t,i,l),f.lineSegmentPlane(a,t,i,C),{positions:[t,e,a,l,C],indices:[1,2,4,1,4,3,0,3,4]};if(!c)return f.lineSegmentPlane(a,e,i,l),f.lineSegmentPlane(t,e,i,C),{positions:[t,e,a,l,C],indices:[2,0,4,2,4,3,1,3,4]};if(!u)return f.lineSegmentPlane(t,a,i,l),f.lineSegmentPlane(e,a,i,C),{positions:[t,e,a,l,C],indices:[0,1,4,0,4,3,2,3,4]}}};var _=f;t.IntersectionTests=_,t.Ray=d}));