/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as t}from"tslib";import{clamp as i}from"../../../../core/mathUtils.js";import{Milliseconds as e}from"../../../../core/time.js";import{subclass as r}from"../../../../core/accessorSupport/decorators.js";import{copy as o,subtract as s,normalize as a,length as m,add as n,scale as c,lerp as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p,fromValues as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{applyAll as l}from"../../camera/constraintUtils.js";import{ConstraintOptions as C}from"../../camera/constraintUtils/ConstraintOptions.js";import{getVoxelWasm as f}from"../../layers/VoxelWasm.js";import{PointToPointAnimationController as g}from"./PointToPointAnimationController.js";import{excludeTerrain as y,zoomStepDistanceClamp as w,getTiltScaleFactor as b,maxZoomStepDistanceModifier as v,distanceComparisonTolerance as j}from"../utils/navigationUtils.js";import u from"../../webgl/RenderCamera.js";import{Intersector as d}from"../../webgl-engine/lib/Intersector.js";import{outExpo as z}from"../../../animation/easing.js";const L=.6,R=4,D=60;let x=class extends g{constructor(){super(...arguments),this._zoomLocation=p(),this._tmpCamera=new u,this._tmpRayDir=p(),this._tmpCenter=p(),this._beginCamera=new u,this._constraintOptions=new C(15,1,null,this._beginCamera)}step(t,e){if(!this.running)return;const r=this.view.state;this.animation.finished?this._beginCamera.copyFrom(r.camera):this.animation.cameraAt(1,this._beginCamera),this._tmpCamera.copyFrom(r.camera);const h=new d(this.view.state.viewingMode);let _=!1;t>0?(_=this._intersectionHelper.intersectScreenFreePointFallback(e,this._zoomLocation,this.view.basemapTerrain.invisible?y:{}),this._intersectionHelper.intersectRay(this._tmpCamera.ray,h,this._tmpCenter)&&(this._tmpCamera.center=this._tmpCenter)):this._intersectionHelper.intersectRay(this._tmpCamera.ray,h,this._zoomLocation)?this._tmpCamera.center=this._zoomLocation:o(this._zoomLocation,this._tmpCamera.center);const l=L**t;let C=this.view.stage.renderView.getMinimalDepthForArea(f(this.view),e[0],e[1],this.view.state.camera,D);s(S,this._tmpCamera.eye,this._zoomLocation),a(S,S);const g=Math.abs(this.view.camera.position.z),j=i(b(M,S,v)*g,w[0],w[1]);C=null!=C?C:j;const u=p();s(u,this._zoomLocation,this._tmpCamera.eye),(C<m(u)||!_)&&(a(u,u),n(this._zoomLocation,this._tmpCamera.eye,c(u,u,C))),this._updateCamera(this._tmpCamera,l,this._zoomLocation),this.begin(this._tmpCamera)}animationSettings(){return{duration:e(600),easing:z}}_updateCamera(t,i,e){s(this._tmpRayDir,e,t.eye);const r=m(this._tmpRayDir);let o=r*i;const a=i<=1,n=Math.max(R,1.01*t.nearFar[0]);0!==o&&(a&&o<n&&(o=n,i=o/r),Math.abs(r-o)<j||(c(this._tmpRayDir,this._tmpRayDir,i),t.eye=s(F,e,this._tmpRayDir),t.center=h(F,t.center,e,1-i),l(this.view,t,this._constraintOptions)))}};x=t([r("esri.views.3d.state.controllers.ZoomStepControllerLocal")],x);const F=p(),M=_(0,0,1),S=p();export{x as ZoomStepControllerLocal};
