/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{screenPointObjectToArray as r,castRenderScreenPointArray3 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(e,n,o=u()){return s(e,r(n),o),t(o.direction,o.direction),o}function s(r,n,t){return g(r,r.screenToRender(n,e(l.get())),t)}function g(r,t,i){if(null==t)return null;const c=e(n(l.get(),t));if(c[2]=0,!r.unprojectFromRenderScreen(c,i.origin))return null;const u=e(n(l.get(),t));u[2]=1;const m=r.unprojectFromRenderScreen(u,l.get());return null==m?null:(o(i.direction,m,i.origin),i)}function p(r,n,t){return f(r,r.screenToRender(n,e(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};
