/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../core/ObjectStack","../../chunks/mat4","../../chunks/vec3","../../chunks/vec3f64","../../chunks/vec4","../../chunks/vec4f64","./clipRay","./plane","./vectorStacks"],(function(n,e,t,T,o,_,i,P,O,R){"use strict";function r(n){return n?[O.create(n[0]),O.create(n[1]),O.create(n[2]),O.create(n[3]),O.create(n[4]),O.create(n[5])]:[O.create(),O.create(),O.create(),O.create(),O.create(),O.create()]}function I(){return[o.create(),o.create(),o.create(),o.create(),o.create(),o.create(),o.create(),o.create()]}function c(e,t){for(let T=0;T<n.NumPlanes.NUM;T++)O.copy(e[T],t[T])}function a(e,o,i,P=L){const O=t.multiply(R.sm4d.get(),o,e);t.invert(O,O);for(let t=0;t<n.NumPoints.NUM;++t){const n=_.transformMat4(R.sv4d.get(),G[t],O);T.set(P[t],n[0]/n[3],n[1]/n[3],n[2]/n[3])}A(i,P)}function A(e,t){O.fromPoints(t[n.PointIndex.FAR_BOTTOM_LEFT],t[n.PointIndex.NEAR_BOTTOM_LEFT],t[n.PointIndex.NEAR_TOP_LEFT],e[n.PlaneIndex.LEFT]),O.fromPoints(t[n.PointIndex.NEAR_BOTTOM_RIGHT],t[n.PointIndex.FAR_BOTTOM_RIGHT],t[n.PointIndex.FAR_TOP_RIGHT],e[n.PlaneIndex.RIGHT]),O.fromPoints(t[n.PointIndex.FAR_BOTTOM_LEFT],t[n.PointIndex.FAR_BOTTOM_RIGHT],t[n.PointIndex.NEAR_BOTTOM_RIGHT],e[n.PlaneIndex.BOTTOM]),O.fromPoints(t[n.PointIndex.NEAR_TOP_LEFT],t[n.PointIndex.NEAR_TOP_RIGHT],t[n.PointIndex.FAR_TOP_RIGHT],e[n.PlaneIndex.TOP]),O.fromPoints(t[n.PointIndex.NEAR_BOTTOM_LEFT],t[n.PointIndex.NEAR_BOTTOM_RIGHT],t[n.PointIndex.NEAR_TOP_RIGHT],e[n.PlaneIndex.NEAR]),O.fromPoints(t[n.PointIndex.FAR_BOTTOM_RIGHT],t[n.PointIndex.FAR_BOTTOM_LEFT],t[n.PointIndex.FAR_TOP_LEFT],e[n.PlaneIndex.FAR])}function d(e,t){for(let T=0;T<n.NumPlanes.NUM;T++){const n=e[T];if(n[0]*t[0]+n[1]*t[1]+n[2]*t[2]+n[3]>=t[3])return!1}return!0}function s(n,e){return N(n,P.fromRay(e,H.get()))}function F(e,t){for(let T=0;T<n.NumPlanes.NUM;T++){const n=e[T];if(!O.clipInfinite(n,t))return!1}return!0}function E(n,e,t){return N(n,P.fromLineSegmentAndDirection(e,t,H.get()))}function u(e,t){for(let T=0;T<n.NumPlanes.NUM;T++){if(O.signedDistance(e[T],t)>0)return!1}return!0}function x(e,t){for(let T=0;T<n.NumPlanes.NUM;T++)if(O.isAABBFullyInside(e[T],t))return!1;return!0}function N(e,t){for(let T=0;T<n.NumPlanes.NUM;T++)if(!O.clip(e[T],t))return!1;return!0}var f,l;n.PlaneIndex=void 0,(f=n.PlaneIndex||(n.PlaneIndex={}))[f.LEFT=0]="LEFT",f[f.RIGHT=1]="RIGHT",f[f.BOTTOM=2]="BOTTOM",f[f.TOP=3]="TOP",f[f.NEAR=4]="NEAR",f[f.FAR=5]="FAR",n.PointIndex=void 0,(l=n.PointIndex||(n.PointIndex={}))[l.NEAR_BOTTOM_LEFT=0]="NEAR_BOTTOM_LEFT",l[l.NEAR_BOTTOM_RIGHT=1]="NEAR_BOTTOM_RIGHT",l[l.NEAR_TOP_RIGHT=2]="NEAR_TOP_RIGHT",l[l.NEAR_TOP_LEFT=3]="NEAR_TOP_LEFT",l[l.FAR_BOTTOM_LEFT=4]="FAR_BOTTOM_LEFT",l[l.FAR_BOTTOM_RIGHT=5]="FAR_BOTTOM_RIGHT",l[l.FAR_TOP_RIGHT=6]="FAR_TOP_RIGHT",l[l.FAR_TOP_LEFT=7]="FAR_TOP_LEFT";const M={bottom:[n.PointIndex.FAR_BOTTOM_RIGHT,n.PointIndex.NEAR_BOTTOM_RIGHT,n.PointIndex.NEAR_BOTTOM_LEFT,n.PointIndex.FAR_BOTTOM_LEFT],near:[n.PointIndex.NEAR_BOTTOM_LEFT,n.PointIndex.NEAR_BOTTOM_RIGHT,n.PointIndex.NEAR_TOP_RIGHT,n.PointIndex.NEAR_TOP_LEFT],far:[n.PointIndex.FAR_BOTTOM_RIGHT,n.PointIndex.FAR_BOTTOM_LEFT,n.PointIndex.FAR_TOP_LEFT,n.PointIndex.FAR_TOP_RIGHT],right:[n.PointIndex.NEAR_BOTTOM_RIGHT,n.PointIndex.FAR_BOTTOM_RIGHT,n.PointIndex.FAR_TOP_RIGHT,n.PointIndex.NEAR_TOP_RIGHT],left:[n.PointIndex.FAR_BOTTOM_LEFT,n.PointIndex.NEAR_BOTTOM_LEFT,n.PointIndex.NEAR_TOP_LEFT,n.PointIndex.FAR_TOP_LEFT],top:[n.PointIndex.FAR_TOP_LEFT,n.PointIndex.NEAR_TOP_LEFT,n.PointIndex.NEAR_TOP_RIGHT,n.PointIndex.FAR_TOP_RIGHT]};var m,B;n.NumPlanes=void 0,(m=n.NumPlanes||(n.NumPlanes={}))[m.NUM=6]="NUM",n.NumPoints=void 0,(B=n.NumPoints||(n.NumPoints={}))[B.NUM=8]="NUM";const G=[i.fromValues(-1,-1,-1,1),i.fromValues(1,-1,-1,1),i.fromValues(1,1,-1,1),i.fromValues(-1,1,-1,1),i.fromValues(-1,-1,1,1),i.fromValues(1,-1,1,1),i.fromValues(1,1,1,1),i.fromValues(-1,1,1,1)],H=new e.ObjectStack(P.create),L=I();n.computePlanes=A,n.copy=c,n.create=r,n.createPoints=I,n.fromMatrix=a,n.intersectClipRay=F,n.intersectsAABB=x,n.intersectsLineSegment=E,n.intersectsPoint=u,n.intersectsRay=s,n.intersectsSphere=d,n.planePointIndices=M,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
