/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{length as e,subtract as t,add as r,scale as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{surfaceElevationBelowRenderLocation as n}from"../intersectionUtils.js";function s(i,s,a,f=0){const m=i.state.constraints.collision;if(!m.enabled)return!1;const y=s||a,d=n(i,y.eye),p=i.renderCoordsHelper.getAltitude(y.eye),u=d+m.elevationMargin;if(p>=u)return!(!s||a.equalsView(s))&&(a.copyViewFrom(s),!0);const g=e(y.eye);if(t(c,y.center,y.eye),a.eye=i.renderCoordsHelper.setAltitude(l,u,y.eye),1===f)a.center=r(c,a.eye,c);else if(2===f){const e=(g-p+u)/g;a.center=o(c,y.center,e)}return!0}const c=i(),l=i();export{s as applySurfaceCollisionConstraint};
