/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{Milliseconds as t,millisecondsFromSeconds as i}from"../../../../core/time.js";import{e,b as r,d as n}from"../../../../chunks/vec32.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Camera as s}from"./Camera.js";import{Animation as a}from"../../../animation/pointToPoint/Animation.js";class o{get finished(){return this.currentTime>=this._animation.time}get time(){return this._animation.time}constructor(i){this.currentTime=t(0),this._animation=new a(()=>new s(i)),this._current=new s(i)}update(i,m,s){const{source:a,target:o}=this._animation.definition,h=e(c,m.center,i.center),u=r(h);u>=1e-5?(h[0]/=u,h[1]/=u,h[2]/=u):(h[0]=0,h[1]=1,h[0]=0),n(a.direction,h),n(o.direction,h),a.copyFromRenderCamera(i),o.copyFromRenderCamera(m),this._current.copyFrom(a),this._animation.update(a,o,s),this.currentTime=t(0),i.almostEquals(m)&&(this.currentTime=this._animation.time)}cameraAt(t,i){this._animation.cameraAt(t,this._current),this._current.copyToRenderCamera(i)}step(e,r){this.finished||(this.currentTime=t(this.currentTime+i(e)),this.currentTime>=this.time&&(this.currentTime=this.time)),this.cameraAt(this.currentTime/this.time,r)}}const c=m();export{o as Animation};
