diff --git a/src/animation/Animation.ts b/src/animation/Animation.ts index cf2ec8569..b901bceda 100644 --- a/src/animation/Animation.ts +++ b/src/animation/Animation.ts @@ -194,6 +194,20 @@ export default class Animation extends Eventful { this._startLoop(); } + seek(timestamp: number) { + this._time = getTime() - timestamp; + let clip = this._head; + while(clip) { + clip.loop = true; + clip.setStartTime(this._time + clip.getDelay()); + clip = clip.next; + } + this._pausedTime = 0; + this._pauseStart = getTime(); + this._paused = true; + this.update(); + } + /** * Stop animation. */ diff --git a/src/animation/Clip.ts b/src/animation/Clip.ts index 0acf6bf40..b71d3a719 100644 --- a/src/animation/Clip.ts +++ b/src/animation/Clip.ts @@ -75,6 +75,14 @@ export default class Clip { opts.easing && this.setEasing(opts.easing); } + getDelay() { + return this._delay; + } + + setStartTime(startTime: number) { + this._startTime = startTime; + } + step(globalTime: number, deltaTime: number): boolean { // Set startTime on first step, or _startTime may has milleseconds different between clips // PENDING