/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{castRenderScreenPointArray3 as r,screenPointObjectToArray as e}from"../../../../core/screenUtils.js";import{copy as n}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{normalize as t,subtract as o,copy as i,set as c}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as u}from"../../../../geometry/support/ray.js";import{sv3d as l}from"../../../../geometry/support/vectorStacks.js";function m(r,n,o=u()){return s(r,e(n),o),t(o.direction,o.direction),o}function s(e,n,t){return g(e,e.screenToRender(n,r(l.get())),t)}function g(e,t,i){if(null==t)return null;const c=r(n(l.get(),t));if(c[2]=0,!e.unprojectFromRenderScreen(c,i.origin))return null;const u=r(n(l.get(),t));u[2]=1;const m=e.unprojectFromRenderScreen(u,l.get());return null==m?null:(o(i.direction,m,i.origin),i)}function p(e,n,t){return f(e,e.screenToRender(n,r(l.get())),t)}function f(r,e,n){i(n.origin,r.eye);const t=c(l.get(),e[0],e[1],1),u=r.unprojectFromRenderScreen(t,l.get());return null==u?null:(o(n.direction,u,n.origin),n)}export{g as fromRender,f as fromRenderAtEye,s as fromScreen,p as fromScreenAtEye,m as fromScreenNormalized};
