skinview3d/types/animation.d.ts

34 lines
807 B
TypeScript
Raw Normal View History

2018-02-09 05:29:42 +01:00
import { PlayerObject } from "./model";
2018-02-04 15:15:03 +01:00
2018-02-09 05:55:04 +01:00
export interface IAnimation {
2018-02-09 05:29:42 +01:00
play(player: PlayerObject, time: number): void;
2018-02-05 02:14:43 +01:00
}
export type AnimationFn = (player: PlayerObject, time: number) => void;
2018-02-09 05:29:42 +01:00
export type Animation = AnimationFn | IAnimation;
2018-02-04 15:15:03 +01:00
2018-02-09 05:44:12 +01:00
export function invokeAnimation(
2018-02-09 05:29:42 +01:00
animation: Animation,
player: PlayerObject,
time: number,
): void;
2018-02-04 15:15:03 +01:00
2018-02-09 05:44:49 +01:00
export interface AnimationHandle extends IAnimation {
readonly animation: Animation;
paused: boolean;
speed: number;
2018-02-04 15:15:03 +01:00
2018-02-09 05:44:49 +01:00
reset(): void;
2018-02-04 15:15:03 +01:00
}
2018-02-05 02:14:43 +01:00
export class CompositeAnimation implements IAnimation {
2018-02-09 05:29:42 +01:00
constructor();
2018-02-04 15:15:03 +01:00
2018-02-09 05:41:14 +01:00
public add(animation: Animation): AnimationHandle;
2018-02-04 15:15:03 +01:00
2018-02-09 05:41:14 +01:00
public play(player: PlayerObject, time: number): void;
2018-02-04 15:15:03 +01:00
}
2018-02-12 03:39:20 +01:00
export const WalkingAnimation: AnimationFn;
export const RunningAnimation: AnimationFn;
export const RotatingAnimation: AnimationFn;