/** * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author David Sehnal */ import { ParamDefinition as PD } from 'mol-util/param-definition'; import { PluginContext } from 'mol-plugin/context'; export { PluginStateAnimation } // TODO: helpers for building animations (once more animations are added) // for example "composite animation" interface PluginStateAnimation

{ name: string, readonly display: { readonly name: string, readonly description?: string }, params: (ctx: PluginContext) => PD.For

, initialState(params: P, ctx: PluginContext): S, /** * Apply the current frame and modify the state. * @param t Current absolute time since the animation started. */ apply(state: S, t: PluginStateAnimation.Time, ctx: PluginStateAnimation.Context

): Promise>, /** * The state must be serializable to JSON. If JSON.stringify is not enough, * custom converted to an object that works with JSON.stringify can be provided. */ stateSerialization?: { toJSON(state: S): any, fromJSON(data: any): S } } namespace PluginStateAnimation { export interface Time { lastApplied: number, current: number } export type ApplyResult = { kind: 'finished' } | { kind: 'skip' } | { kind: 'next', state: S } export interface Context

{ params: P, plugin: PluginContext } export function create(params: PluginStateAnimation) { return params; } }