Skip to content

Commit

Permalink
Merge pull request #404 from liamf1986/master
Browse files Browse the repository at this point in the history
Expanding types to closer match runtimes
  • Loading branch information
ivanpopelyshev authored Aug 10, 2021
2 parents 7fc8440 + 32c22b0 commit ccf3573
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions packages/base/src/core/ISkeleton.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {AttachmentType} from './AttachmentType';
import type {Color, Vector2} from './Utils';
import type {Color, Vector2, Map} from './Utils';
import type {TextureRegion} from './TextureRegion';

import type {Matrix} from '@pixi/math';
Expand All @@ -12,6 +12,18 @@ export interface IBone {
matrix: Matrix;
}

/**
* @public
*/
export interface ISkin {
name: string;
attachments: Array<Map<IAttachment>>;

setAttachment (slotIndex: number, name: string, attachment: IAttachment): void;
getAttachment (slotIndex: number, name: string): IAttachment | null;
attachAll (skeleton: ISkeleton, oldSkin: ISkin): void;
}

/**
* @public
*/
Expand Down Expand Up @@ -93,17 +105,21 @@ export interface ISlot {
/**
* @public
*/
export interface ISkeleton<Bone extends IBone = IBone, Slot extends ISlot = ISlot> {
export interface ISkeleton<Bone extends IBone = IBone, Slot extends ISlot = ISlot, Skin extends ISkin = ISkin> {
bones: Bone[]
slots: Slot[]
drawOrder: Slot[]
skin: Skin;
data: ISkeletonData;
updateWorldTransform (): void;
setToSetupPose (): void;
findSlotIndex (slotName: string): number;
getAttachmentByName (slotName: string, attachmentName: string): IAttachment;

setBonesToSetupPose (): void;
setSlotsToSetupPose (): void;
findBone (boneName: string): Bone;
findSlot (slotName: string): Slot;
findBoneIndex (boneName: string): number;
findSlotIndex (slotName: string): number;
setSkinByName (skinName: string): void;
Expand All @@ -125,6 +141,10 @@ export interface ISkeletonData {
name: string;
version: string;
hash: string;
width: number;
height: number;

findSkin (skinName: string): ISkin | null;
}

/**
Expand All @@ -133,6 +153,8 @@ export interface ISkeletonData {
export interface ITrackEntry {
trackIndex: number;
loop: boolean;
animationEnd: number;
listener: IAnimationStateListener;

delay: number; trackTime: number; trackLast: number; nextTrackLast: number; trackEnd: number; timeScale: number;
alpha: number; mixTime: number; mixDuration: number; interruptAlpha: number; totalAlpha: number;
Expand All @@ -142,16 +164,23 @@ export interface ITrackEntry {
* @public
*/
export interface IAnimationState {
tracks: ITrackEntry;
timeScale: number;

update(dt: number): void;
apply(skeleton: ISkeleton): boolean;

setAnimation (trackIndex: number, animationName: string, loop: boolean): ITrackEntry;
addAnimation (trackIndex: number, animationName: string, loop: boolean, delay: number): ITrackEntry;
addEmptyAnimation (trackIndex: number, mixDuration: number, delay: number): ITrackEntry;
setEmptyAnimation (trackIndex: number, mixDuration: number): ITrackEntry;
setEmptyAnimations (mixDuration: number): void;
hasAnimation(animationName: string): boolean;
addListener (listener: IAnimationStateListener);
removeListener (listener: IAnimationStateListener);
addListener (listener: IAnimationStateListener): void;
removeListener (listener: IAnimationStateListener): void;
clearListeners (): void;
clearTracks (): void;
clearTrack (index: number): void;
}

/**
Expand Down

0 comments on commit ccf3573

Please sign in to comment.