Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expanded types to add more missing properties #405

Merged
merged 2 commits into from
Aug 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 91 additions & 1 deletion packages/base/src/core/ISkeleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,36 @@ import type {Color, Vector2, Map} from './Utils';
import type {TextureRegion} from './TextureRegion';

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

/**
* @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 +54,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 +121,30 @@ export interface IMeshAttachment extends IVertexAttachment {
*/
export interface ISlotData {
index: number;
name: string;
boneData: IBoneData;
color: Color;
darkColor: Color;
attachmentName: string;
blendMode: BLEND_MODES;
}

/**
* @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 +211,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 +248,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 +273,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