@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 1.32 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{Milliseconds as t,millisecondsFromSeconds as i}from"../../../../core/time.js";import{subtract as e,length as r,copy as n}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Camera as o}from"./Camera.js";import{Animation as s}from"../../../animation/pointToPoint/Animation.js";class a{get finished(){return this.currentTime>=this._animation.time}get time(){return this._animation.time}constructor(i){this.currentTime=t(0),this._animation=new s(()=>new o(i)),this._current=new o(i)}update(i,m,o){const{source:s,target:a}=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(s.direction,h),n(a.direction,h),s.copyFromRenderCamera(i),a.copyFromRenderCamera(m),this._current.copyFrom(s),this._animation.update(s,a,o),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{a as Animation};