@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 1.3 kB
JavaScript
import{Milliseconds as t,millisecondsFromSeconds as i}from"../../../../core/time.js";import{b as e,l as r,c as n}from"../../../../chunks/vec3.js";import{c as m}from"../../../../chunks/vec3f64.js";import s from"./Camera.js";import{Camera as a}from"../../webgl-engine/lib/Camera.js";import{Animation as o}from"../../../animation/pointToPoint/Animation.js";const c=m();class h{get finished(){return this.currentTime>=this._animation.time}get time(){return this._animation.time}constructor(i){this.currentTime=t(0),this._animation=new o((()=>new s(i))),this._current=new s(i)}update(i,m,s){const a=this._animation.definition.source,o=this._animation.definition.target,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.lookAtDirection,h),n(o.lookAtDirection,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){return this._animation.cameraAt(t,this._current),i=i||new a,this._current.copyToRenderCamera(i),i}step(e,r){return this.finished||(this.currentTime=t(this.currentTime+i(e)),this.currentTime>=this.time&&(this.currentTime=this.time)),this.cameraAt(this.currentTime/this.time,r)}}export{h as Animation};