/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
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 s}from"../../../../core/accessorSupport/decorators.js";import{d as a,e as r,n as o,b as n,i as m,j as c,l as h}from"../../../../chunks/vec32.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 y}from"./PointToPointAnimationController.js";import{excludeTerrain as g,zoomStepDistanceClamp as w,getTiltScaleFactor as b,maxZoomStepDistanceModifier as j,distanceComparisonTolerance as v}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 F=class extends y{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 s=this.view.state;this.animation.finished?this._beginCamera.copyFrom(s.camera):this.animation.cameraAt(1,this._beginCamera),this._tmpCamera.copyFrom(s.camera);const h=new d(this.view.state.viewingMode);let _=!1;t>0?(_=this._intersectionHelper.intersectScreenFreePointFallback(e,this._zoomLocation,this.view.basemapTerrain.invisible?g:{}),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:a(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);r(S,this._tmpCamera.eye,this._zoomLocation),o(S,S);const y=Math.abs(this.view.camera.position.z),v=i(b(M,S,j)*y,w[0],w[1]);C=null!=C?C:v;const u=p();r(u,this._zoomLocation,this._tmpCamera.eye),(C<n(u)||!_)&&(o(u,u),m(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){r(this._tmpRayDir,e,t.eye);const s=n(this._tmpRayDir);let a=s*i;const o=i<=1,m=Math.max(R,1.01*t.nearFar[0]);0!==a&&(o&&a<m&&(a=m,i=a/s),Math.abs(s-a)<v||(c(this._tmpRayDir,this._tmpRayDir,i),t.eye=r(x,e,this._tmpRayDir),t.center=h(x,t.center,e,1-i),l(this.view,t,this._constraintOptions)))}};F=t([s("esri.views.3d.state.controllers.ZoomStepControllerLocal")],F);const x=p(),M=_(0,0,1),S=p();export{F as ZoomStepControllerLocal};
