/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{create as r}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{distance as n,copy as t,subtract as i,scale as e,dot as c,add as o,normalize as l}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getNormal as f,signedDistance as p}from"../../../geometry/support/plane.js";function s(r,n,t){return r[0]*n[0]+r[1]*n[1]+r[2]*n[2]+r[3]<t}function m(r,n,t){const i=n[0],e=n[1],c=n[2];return!(r[0][0]*i+r[0][1]*e+r[0][2]*c+r[0][3]>t)&&(!(r[1][0]*i+r[1][1]*e+r[1][2]*c+r[1][3]>t)&&(!(r[2][0]*i+r[2][1]*e+r[2][2]*c+r[2][3]>t)&&(!(r[3][0]*i+r[3][1]*e+r[3][2]*c+r[3][3]>t)&&(!(r[4][0]*i+r[4][1]*e+r[4][2]*c+r[4][3]>t)&&!(r[5][0]*i+r[5][1]*e+r[5][2]*c+r[5][3]>t)))))}function a(r,n,t,i){return h(r,n,null,x(i,n,t,!1))}function d(r,n){for(let t=0;t<6;t++){if(p(r[t],n)>0)return!1}return!0}function g(r,n,t,i){return h(r,n,t,x(i,n,t,!0))}function b(r,n,t,l){const u=c(t,i(r,l,n));return o(r,n,e(r,t,u))}const j={dir:u(),len:0,clip:r()};function x(r,c,o,u){const f=j;return r?(o&&u&&(f.len=n(c,o)),t(f.dir,r)):u?(f.len=n(c,o),i(f.dir,o,c),e(f.dir,f.dir,1/f.len)):(i(f.dir,o,c),l(f.dir,f.dir)),f}function v(r,n,t){const i=c(f(r),t.dir),e=-p(r,n);if(e<0&&i>=0)return!1;if(i>-1e-6&&i<1e-6)return e>0;if((e<0||i<0)&&!(e<0&&i<0))return!0;const o=e/i;return i>0?o<t.clip[1]&&(t.clip[1]=o):o>t.clip[0]&&(t.clip[0]=o),t.clip[0]<=t.clip[1]}function h(r,n,t,i){i.clip[0]=0,i.clip[1]=t?i.len:Number.MAX_VALUE;for(let e=0;e<r.length;e++)if(!v(r[e],n,i))return!1;return!0}export{b as closestPointOnRay,g as frustumLineSegment,d as frustumPoint,a as frustumRay,m as frustumSphere,s as planeSphere};
