/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/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 n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{surfaceElevationBelowRenderLocation as i}from"../intersectionUtils.js";function s(n,s,f=0){const a=n.state.constraints.collision;if(!a.enabled)return!1;const m=i(n,s.eye),d=n.renderCoordsHelper.getAltitude(s.eye),y=m+a.elevationMargin;if(d>=y)return!1;const p=e(s.eye);if(t(c,s.center,s.eye),s.eye=n.renderCoordsHelper.setAltitude(l,y,s.eye),1===f)s.center=r(c,s.eye,c);else if(2===f){const e=(p-d+y)/p;s.center=o(c,s.center,e)}return!0}const c=n(),l=n();export{s as applySurfaceCollisionConstraint};
