Skip to content

Commit

Permalink
feat: expanded types to add some missing properties
Browse files Browse the repository at this point in the history
  • Loading branch information
liamf1986 committed Aug 17, 2021
1 parent 32c22b0 commit 5dba914
Showing 1 changed file with 100 additions and 1 deletion.
101 changes: 100 additions & 1 deletion packages/base/src/core/ISkeleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,45 @@ import type {TextureRegion} from './TextureRegion';

import type {Matrix} from '@pixi/math';

/**
* @public
*/
export enum BlendMode {
Normal,
Additive,
Multiply,
Screen
}

/**
* @public
*/
export enum MixBlend {
setup,
first,
replace,
add
}

/**
* @public
*/
export enum MixDirection {
mixIn,
mixOut
}

/**
* @public
*/
export enum TransformMode {
Normal,
OnlyTranslation,
NoRotationOrReflection,
NoScale,
NoScaleOrReflection
}

/**
* @public
*/
Expand All @@ -24,6 +63,24 @@ export interface ISkin {
attachAll (skeleton: ISkeleton, oldSkin: ISkin): void;
}

/**
* @public
*/
export interface IAnimation {
name: string;
timelines: ITimeline[];
duration: number;

apply (skeleton: ISkeleton, lastTime: number, time: number, loop: boolean, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
}

/**
* @public
*/
export interface ITimeline {
apply (skeleton: ISkeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
}

/**
* @public
*/
Expand Down Expand Up @@ -73,6 +130,30 @@ export interface IMeshAttachment extends IVertexAttachment {
*/
export interface ISlotData {
index: number;
name: string;
boneData: IBoneData;
color: Color;
darkColor: Color;
attachmentName: string;
blendMode: BlendMode;
}

/**
* @public
*/
export interface IBoneData {
index: number;
name: string;
parent: IBoneData;
length: number;
x: number;
y: number;
rotation: number;
scaleX: number;
scaleY: number;
shearX: number;
shearY: number;
transformMode: TransformMode;
}

/**
Expand Down Expand Up @@ -139,12 +220,24 @@ export interface ISkeletonParser {
*/
export interface ISkeletonData {
name: string;
bones: IBoneData[];
slots: ISlotData[];
skins: ISkin[];
defaultSkin: ISkin;
events: IEventData[];
animations: IAnimation[];
version: string;
hash: string;
width: number;
height: number;

findBone(boneName: string): IBone | null;
findBoneIndex(boneName: string): number;
findSlot(slotName: string): ISlot | null;
findSlotIndex (slotName: string): number;
findSkin (skinName: string): ISkin | null;
findEvent (eventDataName: string): IEventData | null;
findAnimation (animationName: string): IAnimation | null;
}

/**
Expand All @@ -164,7 +257,9 @@ export interface ITrackEntry {
* @public
*/
export interface IAnimationState {
tracks: ITrackEntry;
data: IAnimationStateData;
tracks: ITrackEntry[];
listeners: IAnimationStateListener[];
timeScale: number;

update(dt: number): void;
Expand All @@ -187,8 +282,12 @@ export interface IAnimationState {
* @public
*/
export interface IAnimationStateData {
skeletonData: ISkeletonData;
animationToMixTime: Map<number>;
defaultMix: number;
setMix (fromName: string, toName: string, duration: number): void;
setMixWith (from: Animation, to: Animation, duration: number): void;
getMix (from: Animation, to: Animation): number;
}

/**
Expand Down

0 comments on commit 5dba914

Please sign in to comment.