skinview3d/types/animation.d.ts

44 lines
902 B
TypeScript
Raw Normal View History

2018-02-04 15:15:03 +01:00
import { PlayerObject } from './model'
2018-02-05 02:14:43 +01:00
type AnimationFn = (player: PlayerObject, time: number) => void
interface IAnimation {
play(player: PlayerObject, time: number): void
}
export type Animation =
| AnimationFn
| IAnimation
| {
play(player: PlayerObject, time: number): void
[x: string]: any
}
2018-02-04 15:15:03 +01:00
declare function invokeAnimation(
2018-02-04 16:23:27 +01:00
animation: Animation,
2018-02-04 15:15:03 +01:00
player: PlayerObject,
time: number
): void
2018-02-05 02:14:43 +01:00
declare class AnimationHandle implements IAnimation {
readonly animation: Animation
2018-02-04 15:15:03 +01:00
paused: boolean
speed: number
2018-02-04 16:23:27 +01:00
constructor(animation: Animation)
2018-02-04 15:15:03 +01:00
play(player: PlayerObject, time: number): void
reset(): void
}
2018-02-05 02:14:43 +01:00
export class CompositeAnimation implements IAnimation {
readonly handles: Set<AnimationHandle>
2018-02-04 15:15:03 +01:00
constructor()
2018-02-04 16:23:27 +01:00
add(animation: Animation): AnimationHandle
2018-02-04 15:15:03 +01:00
play(player: PlayerObject, time: number): void
}
2018-02-05 02:14:43 +01:00
export const WalkAnimation: AnimationFn