From 5dba914af2a95d12fff5a496ef8a4946c564b092 Mon Sep 17 00:00:00 2001 From: Liam Faulkner Date: Tue, 17 Aug 2021 10:33:49 +0100 Subject: [PATCH 1/2] feat: expanded types to add some missing properties --- packages/base/src/core/ISkeleton.ts | 101 +++++++++++++++++++++++++++- 1 file changed, 100 insertions(+), 1 deletion(-) diff --git a/packages/base/src/core/ISkeleton.ts b/packages/base/src/core/ISkeleton.ts index b3afb47f..d353af75 100644 --- a/packages/base/src/core/ISkeleton.ts +++ b/packages/base/src/core/ISkeleton.ts @@ -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 */ @@ -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, alpha: number, blend: MixBlend, direction: MixDirection): void; +} + +/** + * @public + */ +export interface ITimeline { + apply (skeleton: ISkeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; +} + /** * @public */ @@ -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; } /** @@ -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; } /** @@ -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; @@ -187,8 +282,12 @@ export interface IAnimationState { * @public */ export interface IAnimationStateData { + skeletonData: ISkeletonData; + animationToMixTime: Map; defaultMix: number; setMix (fromName: string, toName: string, duration: number): void; + setMixWith (from: Animation, to: Animation, duration: number): void; + getMix (from: Animation, to: Animation): number; } /** From a47dc9affed630a04af8a8b5749ca9fe25e9b91d Mon Sep 17 00:00:00 2001 From: Liam Faulkner Date: Tue, 17 Aug 2021 11:58:14 +0100 Subject: [PATCH 2/2] fix: accessing BLEND_MODES from pixi.js --- packages/base/src/core/ISkeleton.ts | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/packages/base/src/core/ISkeleton.ts b/packages/base/src/core/ISkeleton.ts index d353af75..6000aa01 100644 --- a/packages/base/src/core/ISkeleton.ts +++ b/packages/base/src/core/ISkeleton.ts @@ -3,16 +3,7 @@ import type {Color, Vector2, Map} from './Utils'; import type {TextureRegion} from './TextureRegion'; import type {Matrix} from '@pixi/math'; - -/** - * @public - */ - export enum BlendMode { - Normal, - Additive, - Multiply, - Screen -} +import {BLEND_MODES} from '@pixi/constants'; /** * @public @@ -135,7 +126,7 @@ export interface ISlotData { color: Color; darkColor: Color; attachmentName: string; - blendMode: BlendMode; + blendMode: BLEND_MODES; } /**