UNPKG

skinview3d-blockbench

Version:

SkinView3d animation provider for blockbench bedrock minecraft animations

80 lines (79 loc) 2.32 kB
import { SkinViewBlockbench } from './SkinViewBlockbench'; export interface BlockbenchAnimationProviderProps { /** Animation object/json */ animation: AnimationFileType; /** * Name of animation to play * * Playing first if not specified */ animationName?: string; /** * Overrides for bones names * * If not specified using LeftLeg, Head, etc. */ bonesOverrides?: BonesOverrides; /** Override animation loop state */ forceLoop?: boolean; /** Animate cape position with body */ connectCape?: boolean; /** Callback for animation finishing */ onFinish?: (animation?: SkinViewBlockbench) => unknown; /** Callback for animation loop finished */ onLoopEnd?: (animation?: SkinViewBlockbench) => unknown; } /** Overrides for bones names */ export interface BonesOverrides { head?: string; body?: string; leftLeg?: string; leftArm?: string; rightLeg?: string; rightArm?: string; torso?: string; all?: string; cape?: string; } /** Type of .json animation file */ export interface AnimationFileType { format_version: string; animations: { [anim_name: string]: AnimationsObject; }; } /** Type of single animation */ export interface AnimationsObject { loop?: boolean | string; animation_length: number; bones: { [bone: string]: BonesAnimation<KeyframeValue>; }; } export type KeyframeValue = number[] | ExtendedKeyframe; /** Type of bone animation */ export interface BonesAnimation<V = ExtendedKeyframe> { rotation?: Record<string, V>; position?: Record<string, V>; } export type SingleKeyframeListItem = { str: string[]; num: number[]; }; export interface ExtendedKeyframe { pre?: number[]; post?: number[]; lerp_mode?: string; } export type NormalizedBonesNames = 'head' | 'body' | 'leftArm' | 'rightArm' | 'leftLeg' | 'rightLeg' | 'all' | 'torso' | 'cape'; export interface KeyframesList { rotation?: SingleKeyframeListItem; position?: SingleKeyframeListItem; } export type InternalAnimationObject = { bones: Record<NormalizedBonesNames, BonesAnimation<ExtendedKeyframe>>; keyframes_list: Record<string, KeyframesList>; animation_length: number; animation_name: string; animation_loop: boolean; };