diff --git a/packages/base/package.json b/packages/base/package.json index 391fa6a6..b0fe2784 100644 --- a/packages/base/package.json +++ b/packages/base/package.json @@ -15,6 +15,8 @@ "@pixi/math": "^6.1.0", "@pixi/mesh": "^6.1.0", "@pixi/mesh-extras": "^6.1.0", + "@pixi/runner": "^6.1.0", + "@pixi/settings": "^6.1.0", "@pixi/sprite": "^6.1.0", "@pixi/utils": "^6.1.0" }, diff --git a/packages/base/src/SpineBase.ts b/packages/base/src/SpineBase.ts index de015fa8..53a346d2 100644 --- a/packages/base/src/SpineBase.ts +++ b/packages/base/src/SpineBase.ts @@ -4,7 +4,9 @@ import {TextureAtlasRegion} from './core/TextureAtlas'; import {MathUtils} from './core/Utils'; import type { IAnimationState, - IAnimationStateData, + IAnimationStateData +} from './core/IAnimation'; +import type { IAttachment, IClippingAttachment, IMeshAttachment, IRegionAttachment, ISkeleton, diff --git a/packages/base/src/core/IAnimation.ts b/packages/base/src/core/IAnimation.ts new file mode 100644 index 00000000..74292755 --- /dev/null +++ b/packages/base/src/core/IAnimation.ts @@ -0,0 +1,136 @@ +import {ISkeleton, ISkeletonData} from './ISkeleton'; +import type {Map} from './Utils'; + +// Those enums were moved from Animation.ts of spine 3.8 and 4.0 + +/** Controls how a timeline value is mixed with the setup pose value or current pose value when a timeline's `alpha` + * < 1. + * + * See Timeline {@link Timeline#apply(Skeleton, float, float, Array, float, MixBlend, MixDirection)}. + * @public + * */ +export enum MixBlend { + /** Transitions from the setup value to the timeline value (the current value is not used). Before the first key, the setup + * value is set. */ + setup, + /** Transitions from the current value to the timeline value. Before the first key, transitions from the current value to + * the setup value. Timelines which perform instant transitions, such as DrawOrderTimeline or + * AttachmentTimeline, use the setup value before the first key. + * + * `first` is intended for the first animations applied, not for animations layered on top of those. */ + first, + /** Transitions from the current value to the timeline value. No change is made before the first key (the current value is + * kept until the first key). + * + * `replace` is intended for animations layered on top of others, not for the first animations applied. */ + replace, + /** Transitions from the current value to the current value plus the timeline value. No change is made before the first key + * (the current value is kept until the first key). + * + * `add` is intended for animations layered on top of others, not for the first animations applied. Properties + * keyed by additive animations must be set manually or by another animation before applying the additive animations, else + * the property values will increase continually. */ + add +} + +/** Indicates whether a timeline's `alpha` is mixing out over time toward 0 (the setup or current pose value) or + * mixing in toward 1 (the timeline's value). + * + * See Timeline {@link Timeline#apply(Skeleton, float, float, Array, float, MixBlend, MixDirection)}. + * @public + * */ +export enum MixDirection { + mixIn, mixOut +} + +/** + * @public + */ +export interface IAnimation { + name: string; + timelines: Timeline[]; + duration: number; +} + +/** + * @public + */ + export interface IAnimationState { + data: AnimationStateData; + tracks: ITrackEntry[]; + listeners: IAnimationStateListener[]; + 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): void; + removeListener (listener: IAnimationStateListener): void; + clearListeners (): void; + clearTracks (): void; + clearTrack (index: number): void; +} + +/** + * @public + */ + export interface IAnimationStateData { + skeletonData: SkeletonData; + 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; +} + +/** + * @public + */ + export interface IAnimationStateListener { + start? (entry: ITrackEntry): void; + interrupt? (entry: ITrackEntry): void; + end? (entry: ITrackEntry): void; + dispose? (entry: ITrackEntry): void; + complete? (entry: ITrackEntry): void; + event? (entry: ITrackEntry, event: IEvent): void; +} + +/** + * @public + */ +export interface ITimeline { +} + +/** + * @public + */ + 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; +} + +/** + * @public + */ +export interface IEventData { + name: string; +} + +/** + * @public + */ +export interface IEvent { + time: number; + data: IEventData; +} diff --git a/packages/base/src/core/IConstraint.ts b/packages/base/src/core/IConstraint.ts new file mode 100644 index 00000000..c7242d00 --- /dev/null +++ b/packages/base/src/core/IConstraint.ts @@ -0,0 +1,104 @@ + +// These enums were moved from PathConstraintData.ts of spine 3.7, 3.8 and 4.0 + +/** Controls how the first bone is positioned along the path. + * + * See [Position mode](http://esotericsoftware.com/spine-path-constraints#Position-mode) in the Spine User Guide. + * @public + * */ +export enum PositionMode { + Fixed, Percent +} + +/** Controls how bones are rotated, translated, and scaled to match the path. + * + * [Rotate mode](http://esotericsoftware.com/spine-path-constraints#Rotate-mod) in the Spine User Guide. + * @public + * */ +export enum RotateMode { + Tangent, Chain, ChainScale +} + +/** + * @public + */ +export interface IConstraintData { + name: string; + order: number; +} + +/** + * @public + */ +export interface IIkConstraint { + data: IIkConstraintData; + /** -1 | 0 | 1 */ + bendDirection: number; + compress: boolean; + stretch: boolean; + + /** A percentage (0-1) */ + mix: number; +} + +/** + * @public + */ +export interface IIkConstraintData extends IConstraintData { + /** -1 | 0 | 1 */ + bendDirection: number; + compress: boolean; + stretch: boolean; + uniform: boolean; + + /** A percentage (0-1) */ + mix: number; +} + +/** + * @public + */ +export interface IPathConstraint { + data: IPathConstraintData; + position: number; + spacing: number; + + spaces: number[]; + positions: number[]; + world: number[]; + curves: number[]; + lengths: number[]; + segments: number[]; +} + +/** + * @public + */ +export interface IPathConstraintData extends IConstraintData { + positionMode: PositionMode; + rotateMode: RotateMode; + offsetRotation: number; + position: number; + spacing: number; +} + +/** + * @public + */ +export interface ITransformConstraint { + data: ITransformConstraintData; +} + +/** + * @public + */ +export interface ITransformConstraintData extends IConstraintData { + offsetRotation: number; + offsetX: number; + offsetY: number; + offsetScaleX: number; + offsetScaleY: number; + offsetShearY: number; + relative: boolean; + local: boolean; +} diff --git a/packages/base/src/core/ISkeleton.ts b/packages/base/src/core/ISkeleton.ts index 6000aa01..4574d8c0 100644 --- a/packages/base/src/core/ISkeleton.ts +++ b/packages/base/src/core/ISkeleton.ts @@ -1,31 +1,17 @@ import {AttachmentType} from './AttachmentType'; +import {IAnimation, IEventData} from "./IAnimation"; +import {IIkConstraintData, IPathConstraintData, ITransformConstraintData} from './IConstraint'; 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 -} +// This enum was moved from BoneData.ts of spine 3.7, 3.8 and 4.0 -/** +/** Determines how a bone inherits world transforms from parent bones. * @public - */ + * */ export enum TransformMode { Normal, OnlyTranslation, @@ -49,27 +35,7 @@ export interface ISkin { name: string; attachments: Array>; - setAttachment (slotIndex: number, name: string, attachment: IAttachment): void; getAttachment (slotIndex: number, name: string): IAttachment | null; - 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; } /** @@ -177,12 +143,15 @@ export interface ISlot { /** * @public */ -export interface ISkeleton { +export interface ISkeleton { bones: Bone[] slots: Slot[] drawOrder: Slot[] skin: Skin; - data: ISkeletonData; + data: SkeletonData; updateWorldTransform (): void; setToSetupPose (): void; findSlotIndex (slotName: string): number; @@ -209,101 +178,38 @@ export interface ISkeletonParser { /** * @public */ -export interface ISkeletonData { +export interface ISkeletonData { name: string; - bones: IBoneData[]; - slots: ISlotData[]; - skins: ISkin[]; - defaultSkin: ISkin; - events: IEventData[]; - animations: IAnimation[]; + bones: BoneData[]; + slots: SlotData[]; + skins: Skin[]; + defaultSkin: Skin; + events: EventData[]; + animations: Animation[]; version: string; hash: string; width: number; height: number; + ikConstraints: IkConstraintData[]; + transformConstraints: TransformConstraintData[]; + pathConstraints: PathConstraintData[]; - findBone(boneName: string): IBone | null; + findBone(boneName: string): BoneData | null; findBoneIndex(boneName: string): number; - findSlot(slotName: string): ISlot | null; + findSlot(slotName: string): SlotData | null; findSlotIndex (slotName: string): number; - findSkin (skinName: string): ISkin | null; - findEvent (eventDataName: string): IEventData | null; - findAnimation (animationName: string): IAnimation | null; -} - -/** - * @public - */ -export interface ITrackEntry { - trackIndex: number; - loop: boolean; - animationEnd: number; - listener: IAnimationStateListener; + findSkin (skinName: string): Skin | null; - delay: number; trackTime: number; trackLast: number; nextTrackLast: number; trackEnd: number; timeScale: number; - alpha: number; mixTime: number; mixDuration: number; interruptAlpha: number; totalAlpha: number; -} - -/** - * @public - */ -export interface IAnimationState { - data: IAnimationStateData; - tracks: ITrackEntry[]; - listeners: IAnimationStateListener[]; - 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): void; - removeListener (listener: IAnimationStateListener): void; - clearListeners (): void; - clearTracks (): void; - clearTrack (index: number): void; -} - -/** - * @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; -} - -/** - * @public - */ -export interface IEventData { - name: string; -} - -/** - * @public - */ -export interface IEvent { - time: number; - data: IEventData; -} - -/** - * @public - */ -export interface IAnimationStateListener { - start? (entry: ITrackEntry): void; - interrupt? (entry: ITrackEntry): void; - end? (entry: ITrackEntry): void; - dispose? (entry: ITrackEntry): void; - complete? (entry: ITrackEntry): void; - event? (entry: ITrackEntry, event: IEvent): void; + findEvent (eventDataName: string): EventData | null; + findAnimation (animationName: string): Animation | null; + findIkConstraint (constraintName: string): IkConstraintData | null; + findTransformConstraint (constraintName: string): TransformConstraintData | null; + findPathConstraint (constraintName: string): PathConstraintData | null; } diff --git a/packages/base/src/index.ts b/packages/base/src/index.ts index 5c6d195c..38259601 100644 --- a/packages/base/src/index.ts +++ b/packages/base/src/index.ts @@ -1,6 +1,8 @@ /// export * from './core/AttachmentType'; export * from './core/BinaryInput'; +export * from './core/IAnimation'; +export * from './core/IConstraint'; export * from './core/ISkeleton'; export * from './core/TextureAtlas'; export * from './core/TextureRegion'; diff --git a/packages/runtime-3.7/src/core/Animation.ts b/packages/runtime-3.7/src/core/Animation.ts index a88a9953..c6be1d9b 100644 --- a/packages/runtime-3.7/src/core/Animation.ts +++ b/packages/runtime-3.7/src/core/Animation.ts @@ -1,7 +1,7 @@ import {Event} from './Event'; import type {Skeleton} from "./Skeleton"; import {Attachment, VertexAttachment} from "./attachments"; -import {ArrayLike, MathUtils, Utils} from '@pixi-spine/base'; +import {ArrayLike, MathUtils, Utils, MixBlend, MixDirection, IAnimation, ITimeline} from '@pixi-spine/base'; import {Slot} from "./Slot"; import {IkConstraint} from "./IkConstraint"; import {TransformConstraint} from "./TransformConstraint"; @@ -10,7 +10,7 @@ import {PathConstraint} from "./PathConstraint"; /** * @public */ -export class Animation { +export class Animation implements IAnimation { name: string; timelines: Array; duration: number; @@ -61,28 +61,11 @@ export class Animation { /** * @public */ -export interface Timeline { +export interface Timeline extends ITimeline { apply (skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection): void; getPropertyId (): number; } -/** - * @public - */ -export enum MixBlend { - setup, - first, - replace, - add -} - -/** - * @public - */ -export enum MixDirection { - in, out -} - /** * @public */ @@ -402,7 +385,7 @@ export class ScaleTimeline extends TranslateTimeline { } } else { let bx = 0, by = 0; - if (direction == MixDirection.out) { + if (direction == MixDirection.mixOut) { switch (blend) { case MixBlend.setup: bx = bone.data.scaleX; @@ -718,7 +701,7 @@ export class AttachmentTimeline implements Timeline { apply (skeleton: Skeleton, lastTime: number, time: number, events: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let slot = skeleton.slots[this.slotIndex]; - if (direction == MixDirection.out && blend == MixBlend.setup) { + if (direction == MixDirection.mixOut && blend == MixBlend.setup) { let attachmentName = slot.data.attachmentName; slot.setAttachment(attachmentName == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName)); return; @@ -1035,7 +1018,7 @@ export class DrawOrderTimeline implements Timeline { apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array, alpha: number, blend: MixBlend, direction: MixDirection) { let drawOrder: Array = skeleton.drawOrder; let slots: Array = skeleton.slots; - if (direction == MixDirection.out && blend == MixBlend.setup) { + if (direction == MixDirection.mixOut && blend == MixBlend.setup) { Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); return; } @@ -1115,7 +1098,7 @@ export class IkConstraintTimeline extends CurveTimeline { if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) { // Time is after last frame. if (blend == MixBlend.setup) { constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha; - if (direction == MixDirection.out) { + if (direction == MixDirection.mixOut) { constraint.bendDirection = constraint.data.bendDirection; constraint.compress = constraint.data.compress; constraint.stretch = constraint.data.stretch; @@ -1126,7 +1109,7 @@ export class IkConstraintTimeline extends CurveTimeline { } } else { constraint.mix += (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.mix) * alpha; - if (direction == MixDirection.in) { + if (direction == MixDirection.mixIn) { constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION]; constraint.compress = frames[frames.length + IkConstraintTimeline.PREV_COMPRESS] != 0; constraint.stretch = frames[frames.length + IkConstraintTimeline.PREV_STRETCH] != 0; @@ -1144,7 +1127,7 @@ export class IkConstraintTimeline extends CurveTimeline { if (blend == MixBlend.setup) { constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha; - if (direction == MixDirection.out) { + if (direction == MixDirection.mixOut) { constraint.bendDirection = constraint.data.bendDirection; constraint.compress = constraint.data.compress; constraint.stretch = constraint.data.stretch; @@ -1155,7 +1138,7 @@ export class IkConstraintTimeline extends CurveTimeline { } } else { constraint.mix += (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.mix) * alpha; - if (direction == MixDirection.in) { + if (direction == MixDirection.mixIn) { constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; constraint.compress = frames[frame + IkConstraintTimeline.PREV_COMPRESS] != 0; constraint.stretch = frames[frame + IkConstraintTimeline.PREV_STRETCH] != 0; diff --git a/packages/runtime-3.7/src/core/AnimationState.ts b/packages/runtime-3.7/src/core/AnimationState.ts index c079f0b0..1dc59695 100644 --- a/packages/runtime-3.7/src/core/AnimationState.ts +++ b/packages/runtime-3.7/src/core/AnimationState.ts @@ -3,6 +3,8 @@ import { IAnimationStateListener, ITrackEntry, MathUtils, + MixBlend, + MixDirection, Pool, IntSet, Utils @@ -11,8 +13,6 @@ import { Animation, AttachmentTimeline, DrawOrderTimeline, - MixBlend, - MixDirection, RotateTimeline, Timeline } from './Animation'; import {AnimationStateData} from "./AnimationStateData"; @@ -22,7 +22,7 @@ import type {Skeleton} from "./Skeleton"; /** * @public */ -export class AnimationState implements IAnimationState { +export class AnimationState implements IAnimationState { static emptyAnimation = new Animation("", [], 0); static SUBSEQUENT = 0; static FIRST = 1; @@ -158,7 +158,7 @@ export class AnimationState implements IAnimationState { // to sometimes stop rendering when using color correction, as their RGBA values become NaN. // (https://github.com/pixijs/pixi-spine/issues/302) Utils.webkit602BugfixHelper(mix, blend); - timelines[ii].apply(skeleton, animationLast, animationTime, events, mix, blend, MixDirection.in); + timelines[ii].apply(skeleton, animationLast, animationTime, events, mix, blend, MixDirection.mixIn); } } else { let timelineMode = current.timelineMode; @@ -175,7 +175,7 @@ export class AnimationState implements IAnimationState { } else { // This fixes the WebKit 602 specific issue described at http://esotericsoftware.com/forum/iOS-10-disappearing-graphics-10109 Utils.webkit602BugfixHelper(mix, blend); - timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineBlend, MixDirection.in); + timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineBlend, MixDirection.mixIn); } } } @@ -211,7 +211,7 @@ export class AnimationState implements IAnimationState { let alphaHold = from.alpha * to.interruptAlpha, alphaMix = alphaHold * (1 - mix); if (blend == MixBlend.add) { for (let i = 0; i < timelineCount; i++) - timelines[i].apply(skeleton, animationLast, animationTime, events, alphaMix, blend, MixDirection.out); + timelines[i].apply(skeleton, animationLast, animationTime, events, alphaMix, blend, MixDirection.mixOut); } else { let timelineMode = from.timelineMode; let timelineHoldMix = from.timelineHoldMix; @@ -223,7 +223,7 @@ export class AnimationState implements IAnimationState { from.totalAlpha = 0; for (let i = 0; i < timelineCount; i++) { let timeline = timelines[i]; - let direction = MixDirection.out; + let direction = MixDirection.mixOut; let timelineBlend: MixBlend; let alpha = 0; switch (timelineMode[i]) { @@ -255,9 +255,9 @@ export class AnimationState implements IAnimationState { Utils.webkit602BugfixHelper(alpha, blend); if (timelineBlend == MixBlend.setup) { if (timeline instanceof AttachmentTimeline) { - if (attachments) direction = MixDirection.out; + if (attachments) direction = MixDirection.mixOut; } else if (timeline instanceof DrawOrderTimeline) { - if (drawOrder) direction = MixDirection.out; + if (drawOrder) direction = MixDirection.mixOut; } } timeline.apply(skeleton, animationLast, animationTime, events, alpha, timelineBlend, direction); @@ -279,7 +279,7 @@ export class AnimationState implements IAnimationState { if (firstFrame) timelinesRotation[i] = 0; if (alpha == 1) { - timeline.apply(skeleton, 0, time, null, 1, blend, MixDirection.in); + timeline.apply(skeleton, 0, time, null, 1, blend, MixDirection.mixIn); return; } diff --git a/packages/runtime-3.7/src/core/AnimationStateData.ts b/packages/runtime-3.7/src/core/AnimationStateData.ts index 6b44bb73..1750d2e5 100644 --- a/packages/runtime-3.7/src/core/AnimationStateData.ts +++ b/packages/runtime-3.7/src/core/AnimationStateData.ts @@ -5,7 +5,7 @@ import type {Animation} from './Animation'; /** * @public */ -export class AnimationStateData implements IAnimationStateData { +export class AnimationStateData implements IAnimationStateData { skeletonData: SkeletonData; animationToMixTime: Map = {}; defaultMix = 0; diff --git a/packages/runtime-3.7/src/core/Bone.ts b/packages/runtime-3.7/src/core/Bone.ts index 628b5e16..a1f74eeb 100644 --- a/packages/runtime-3.7/src/core/Bone.ts +++ b/packages/runtime-3.7/src/core/Bone.ts @@ -1,8 +1,8 @@ import {Matrix} from '@pixi/math'; import {Updatable} from "./Updatable"; -import {BoneData, TransformMode} from "./BoneData"; +import {BoneData} from "./BoneData"; import {Skeleton} from "./Skeleton"; -import {IBone, MathUtils, settings, Vector2} from "@pixi-spine/base"; +import {IBone, MathUtils, settings, TransformMode, Vector2} from "@pixi-spine/base"; /** * @public diff --git a/packages/runtime-3.7/src/core/BoneData.ts b/packages/runtime-3.7/src/core/BoneData.ts index c483a95c..982f423d 100644 --- a/packages/runtime-3.7/src/core/BoneData.ts +++ b/packages/runtime-3.7/src/core/BoneData.ts @@ -1,3 +1,5 @@ +import { TransformMode } from "@pixi-spine/base"; + /** * @public */ @@ -23,10 +25,3 @@ export class BoneData { this.parent = parent; } } - -/** - * @public - */ -export enum TransformMode { - Normal, OnlyTranslation, NoRotationOrReflection, NoScale, NoScaleOrReflection -} diff --git a/packages/runtime-3.7/src/core/PathConstraint.ts b/packages/runtime-3.7/src/core/PathConstraint.ts index f55cba1b..16fbf982 100644 --- a/packages/runtime-3.7/src/core/PathConstraint.ts +++ b/packages/runtime-3.7/src/core/PathConstraint.ts @@ -1,10 +1,10 @@ import {PathAttachment} from "./attachments"; import {Constraint} from "./Constraint"; -import {PathConstraintData, PositionMode, RotateMode, SpacingMode} from "./PathConstraintData"; +import {PathConstraintData, SpacingMode} from "./PathConstraintData"; import {Bone} from "./Bone"; import {Slot} from "./Slot"; import {Skeleton} from "./Skeleton"; -import {MathUtils, Utils} from "@pixi-spine/base"; +import {MathUtils, PositionMode, RotateMode, Utils} from "@pixi-spine/base"; /** * @public diff --git a/packages/runtime-3.7/src/core/PathConstraintData.ts b/packages/runtime-3.7/src/core/PathConstraintData.ts index f0998363..0f1ef4ae 100644 --- a/packages/runtime-3.7/src/core/PathConstraintData.ts +++ b/packages/runtime-3.7/src/core/PathConstraintData.ts @@ -1,10 +1,11 @@ import type {SlotData} from "./SlotData"; import type {BoneData} from "./BoneData"; +import { RotateMode, PositionMode, IPathConstraintData } from "@pixi-spine/base"; /** * @public */ -export class PathConstraintData { +export class PathConstraintData implements IPathConstraintData { name: string; order = 0; bones = new Array(); @@ -23,23 +24,9 @@ export class PathConstraintData { } } -/** - * @public - */ -export enum PositionMode { - Fixed, Percent -} - /** * @public */ export enum SpacingMode { Length, Fixed, Percent } - -/** - * @public - */ -export enum RotateMode { - Tangent, Chain, ChainScale -} diff --git a/packages/runtime-3.7/src/core/Skeleton.ts b/packages/runtime-3.7/src/core/Skeleton.ts index 400cf478..f51435fb 100644 --- a/packages/runtime-3.7/src/core/Skeleton.ts +++ b/packages/runtime-3.7/src/core/Skeleton.ts @@ -12,7 +12,7 @@ import {Color, Utils, Vector2, ISkeleton} from "@pixi-spine/base"; /** * @public */ -export class Skeleton implements ISkeleton { +export class Skeleton implements ISkeleton { data: SkeletonData; bones: Array; slots: Array; diff --git a/packages/runtime-3.7/src/core/SkeletonData.ts b/packages/runtime-3.7/src/core/SkeletonData.ts index 73dd2746..956c05f7 100644 --- a/packages/runtime-3.7/src/core/SkeletonData.ts +++ b/packages/runtime-3.7/src/core/SkeletonData.ts @@ -1,16 +1,17 @@ +import type {ISkeletonData} from "@pixi-spine/base"; import type {Animation} from "./Animation"; import {BoneData} from "./BoneData"; import {SlotData} from "./SlotData"; import {Skin} from "./Skin"; -import {IkConstraintData} from "./IkConstraintData"; import {EventData} from "./EventData"; +import {IkConstraintData} from "./IkConstraintData"; import {TransformConstraintData} from "./TransformConstraintData"; import {PathConstraintData} from "./PathConstraintData"; /** * @public */ -export class SkeletonData { +export class SkeletonData implements ISkeletonData { name: string; bones = new Array(); // Ordered parents first. slots = new Array(); // Setup pose draw order. diff --git a/packages/runtime-3.7/src/core/SkeletonJson.ts b/packages/runtime-3.7/src/core/SkeletonJson.ts index 4f59ddd6..9e298d4e 100644 --- a/packages/runtime-3.7/src/core/SkeletonJson.ts +++ b/packages/runtime-3.7/src/core/SkeletonJson.ts @@ -3,10 +3,10 @@ import {Animation} from './Animation'; import {Event} from './Event'; import {SkeletonData} from './SkeletonData'; import {SlotData} from './SlotData'; -import {BoneData, TransformMode} from './BoneData'; +import {BoneData} from './BoneData'; import {IkConstraintData} from './IkConstraintData'; import {TransformConstraintData} from './TransformConstraintData'; -import {PathConstraintData, PositionMode, RotateMode, SpacingMode} from './PathConstraintData'; +import {PathConstraintData, SpacingMode} from './PathConstraintData'; import {Skin} from './Skin'; import {EventData} from './EventData'; import { @@ -24,7 +24,7 @@ import { TranslateTimeline, TwoColorTimeline } from './Animation'; -import {ArrayLike, Color, Utils, settings} from '@pixi-spine/base'; +import {ArrayLike, Color, Utils, PositionMode, RotateMode, TransformMode, settings} from '@pixi-spine/base'; import {BLEND_MODES} from '@pixi/constants'; /** diff --git a/packages/runtime-3.7/src/core/Skin.ts b/packages/runtime-3.7/src/core/Skin.ts index e26ccc95..76f1dff2 100644 --- a/packages/runtime-3.7/src/core/Skin.ts +++ b/packages/runtime-3.7/src/core/Skin.ts @@ -1,12 +1,12 @@ import {Attachment} from './attachments'; import {Skeleton} from "./Skeleton"; -import type {Map} from '@pixi-spine/base'; +import type {Map, ISkin} from '@pixi-spine/base'; /** * @public */ -export class Skin { +export class Skin implements ISkin { name: string; attachments = new Array>(); diff --git a/packages/runtime-3.8/src/core/Animation.ts b/packages/runtime-3.8/src/core/Animation.ts index 3bc49c3a..cddda4cc 100644 --- a/packages/runtime-3.8/src/core/Animation.ts +++ b/packages/runtime-3.8/src/core/Animation.ts @@ -1,7 +1,7 @@ import {Event} from './Event'; import type {Skeleton} from "./Skeleton"; import {Attachment, VertexAttachment} from "./attachments"; -import {ArrayLike, MathUtils, Utils} from '@pixi-spine/base'; +import {ArrayLike, MathUtils, Utils, MixBlend, MixDirection} from '@pixi-spine/base'; import {Slot} from "./Slot"; import {IkConstraint} from "./IkConstraint"; import {TransformConstraint} from "./TransformConstraint"; @@ -104,48 +104,6 @@ export interface Timeline { getPropertyId (): number; } -/** Controls how a timeline value is mixed with the setup pose value or current pose value when a timeline's `alpha` - * < 1. - * - * See Timeline {@link Timeline#apply(Skeleton, float, float, Array, float, MixBlend, MixDirection)}. */ -/** - * @public - */ -export enum MixBlend { - /** Transitions from the setup value to the timeline value (the current value is not used). Before the first key, the setup - * value is set. */ - setup, - /** Transitions from the current value to the timeline value. Before the first key, transitions from the current value to - * the setup value. Timelines which perform instant transitions, such as {@link DrawOrderTimeline} or - * {@link AttachmentTimeline}, use the setup value before the first key. - * - * `first` is intended for the first animations applied, not for animations layered on top of those. */ - first, - /** Transitions from the current value to the timeline value. No change is made before the first key (the current value is - * kept until the first key). - * - * `replace` is intended for animations layered on top of others, not for the first animations applied. */ - replace, - /** Transitions from the current value to the current value plus the timeline value. No change is made before the first key - * (the current value is kept until the first key). - * - * `add` is intended for animations layered on top of others, not for the first animations applied. Properties - * keyed by additive animations must be set manually or by another animation before applying the additive animations, else - * the property values will increase continually. */ - add -} - -/** Indicates whether a timeline's `alpha` is mixing out over time toward 0 (the setup or current pose value) or - * mixing in toward 1 (the timeline's value). - * - * See Timeline {@link Timeline#apply(Skeleton, float, float, Array, float, MixBlend, MixDirection)}. */ -/** - * @public - */ -export enum MixDirection { - mixIn, mixOut -} - /** * @public */ diff --git a/packages/runtime-3.8/src/core/AnimationState.ts b/packages/runtime-3.8/src/core/AnimationState.ts index cc3a003d..af2a518e 100644 --- a/packages/runtime-3.8/src/core/AnimationState.ts +++ b/packages/runtime-3.8/src/core/AnimationState.ts @@ -2,6 +2,8 @@ import { IAnimationState, IAnimationStateListener, ITrackEntry, + MixBlend, + MixDirection, MathUtils, Pool, IntSet, @@ -12,8 +14,6 @@ import { AttachmentTimeline, DrawOrderTimeline, EventTimeline, - MixBlend, - MixDirection, RotateTimeline, Timeline } from './Animation'; import {AnimationStateData} from "./AnimationStateData"; @@ -28,7 +28,7 @@ import type {Slot} from "./Slot"; /** * @public */ -export class AnimationState implements IAnimationState { +export class AnimationState implements IAnimationState { static emptyAnimation = new Animation("", [], 0); /** 1. A previously applied timeline has set this property. diff --git a/packages/runtime-3.8/src/core/AnimationStateData.ts b/packages/runtime-3.8/src/core/AnimationStateData.ts index 6b44bb73..52ca5ab0 100644 --- a/packages/runtime-3.8/src/core/AnimationStateData.ts +++ b/packages/runtime-3.8/src/core/AnimationStateData.ts @@ -1,11 +1,11 @@ import {SkeletonData} from "./SkeletonData"; -import {IAnimationStateData, Map} from '@pixi-spine/base'; -import type {Animation} from './Animation'; +import {IAnimation, IAnimationStateData, Map} from '@pixi-spine/base'; +import type { Animation } from "./Animation"; /** * @public */ -export class AnimationStateData implements IAnimationStateData { +export class AnimationStateData implements IAnimationStateData { skeletonData: SkeletonData; animationToMixTime: Map = {}; defaultMix = 0; @@ -33,14 +33,14 @@ export class AnimationStateData implements IAnimationStateData { this.setMix(fromName, toName, duration); } - setMixWith(from: Animation, to: Animation, duration: number) { + setMixWith(from: IAnimation, to: IAnimation, duration: number) { if (from == null) throw new Error("from cannot be null."); if (to == null) throw new Error("to cannot be null."); let key = from.name + "." + to.name; this.animationToMixTime[key] = duration; } - getMix(from: Animation, to: Animation) { + getMix(from: IAnimation, to: IAnimation) { let key = from.name + "." + to.name; let value = this.animationToMixTime[key]; return value === undefined ? this.defaultMix : value; diff --git a/packages/runtime-3.8/src/core/Bone.ts b/packages/runtime-3.8/src/core/Bone.ts index 838759c1..cf23f0e7 100644 --- a/packages/runtime-3.8/src/core/Bone.ts +++ b/packages/runtime-3.8/src/core/Bone.ts @@ -1,8 +1,8 @@ import {Matrix} from '@pixi/math'; import {Updatable} from "./Updatable"; -import {BoneData, TransformMode} from "./BoneData"; +import {BoneData} from "./BoneData"; import {Skeleton} from "./Skeleton"; -import {IBone, MathUtils, settings, Vector2} from "@pixi-spine/base"; +import {IBone, MathUtils, settings, TransformMode, Vector2} from "@pixi-spine/base"; /** * @public diff --git a/packages/runtime-3.8/src/core/BoneData.ts b/packages/runtime-3.8/src/core/BoneData.ts index cb71a0b1..abdc33a0 100644 --- a/packages/runtime-3.8/src/core/BoneData.ts +++ b/packages/runtime-3.8/src/core/BoneData.ts @@ -1,4 +1,4 @@ -import {Color} from '@pixi-spine/base'; +import {Color, TransformMode} from '@pixi-spine/base'; /** * @public @@ -28,10 +28,3 @@ export class BoneData { this.parent = parent; } } - -/** - * @public - */ -export enum TransformMode { - Normal, OnlyTranslation, NoRotationOrReflection, NoScale, NoScaleOrReflection -} diff --git a/packages/runtime-3.8/src/core/IkConstraint.ts b/packages/runtime-3.8/src/core/IkConstraint.ts index 4c175d78..80c0eb20 100644 --- a/packages/runtime-3.8/src/core/IkConstraint.ts +++ b/packages/runtime-3.8/src/core/IkConstraint.ts @@ -2,13 +2,12 @@ import {Updatable} from "./Updatable"; import {IkConstraintData} from "./IkConstraintData"; import {Bone} from "./Bone"; import {Skeleton} from "./Skeleton"; -import {TransformMode} from "./BoneData"; -import {MathUtils} from "@pixi-spine/base"; +import {IIkConstraint, MathUtils, TransformMode} from "@pixi-spine/base"; /** * @public */ -export class IkConstraint implements Updatable { +export class IkConstraint implements IIkConstraint, Updatable { data: IkConstraintData; bones: Array; target: Bone; diff --git a/packages/runtime-3.8/src/core/IkConstraintData.ts b/packages/runtime-3.8/src/core/IkConstraintData.ts index 387442f4..258917f8 100644 --- a/packages/runtime-3.8/src/core/IkConstraintData.ts +++ b/packages/runtime-3.8/src/core/IkConstraintData.ts @@ -1,10 +1,11 @@ import {ConstraintData} from "./Constraint"; import {BoneData} from "./BoneData"; +import {IIkConstraintData} from "@pixi-spine/base"; /** * @public */ -export class IkConstraintData extends ConstraintData { +export class IkConstraintData extends ConstraintData implements IIkConstraintData { bones = new Array(); target: BoneData; bendDirection = 1; diff --git a/packages/runtime-3.8/src/core/PathConstraint.ts b/packages/runtime-3.8/src/core/PathConstraint.ts index 6fbccf7d..945227e4 100644 --- a/packages/runtime-3.8/src/core/PathConstraint.ts +++ b/packages/runtime-3.8/src/core/PathConstraint.ts @@ -1,10 +1,10 @@ import {PathAttachment} from "./attachments"; import {Updatable} from "./Updatable"; -import {PathConstraintData, PositionMode, RotateMode, SpacingMode} from "./PathConstraintData"; +import {PathConstraintData, SpacingMode} from "./PathConstraintData"; import {Bone} from "./Bone"; import {Slot} from "./Slot"; import {Skeleton} from "./Skeleton"; -import {MathUtils, Utils} from "@pixi-spine/base"; +import {MathUtils, PositionMode, RotateMode, Utils} from "@pixi-spine/base"; /** * @public */ diff --git a/packages/runtime-3.8/src/core/PathConstraintData.ts b/packages/runtime-3.8/src/core/PathConstraintData.ts index 27025629..6de037df 100644 --- a/packages/runtime-3.8/src/core/PathConstraintData.ts +++ b/packages/runtime-3.8/src/core/PathConstraintData.ts @@ -1,6 +1,7 @@ import {ConstraintData} from "./Constraint"; import type {SlotData} from "./SlotData"; import type {BoneData} from "./BoneData"; +import { RotateMode, PositionMode } from "@pixi-spine/base"; /** * @public @@ -18,21 +19,9 @@ export class PathConstraintData extends ConstraintData { super(name, 0, false); } } -/** - * @public - */ -export enum PositionMode { - Fixed, Percent -} /** * @public */ export enum SpacingMode { Length, Fixed, Percent } -/** - * @public - */ -export enum RotateMode { - Tangent, Chain, ChainScale -} diff --git a/packages/runtime-3.8/src/core/Skeleton.ts b/packages/runtime-3.8/src/core/Skeleton.ts index 91935393..2bfe0806 100644 --- a/packages/runtime-3.8/src/core/Skeleton.ts +++ b/packages/runtime-3.8/src/core/Skeleton.ts @@ -12,7 +12,7 @@ import {Color, Utils, Vector2, ISkeleton} from "@pixi-spine/base"; /** * @public */ -export class Skeleton implements ISkeleton { +export class Skeleton implements ISkeleton { data: SkeletonData; bones: Array; slots: Array; diff --git a/packages/runtime-3.8/src/core/SkeletonBinary.ts b/packages/runtime-3.8/src/core/SkeletonBinary.ts index 415dbb91..ff36923d 100644 --- a/packages/runtime-3.8/src/core/SkeletonBinary.ts +++ b/packages/runtime-3.8/src/core/SkeletonBinary.ts @@ -3,10 +3,10 @@ import {Animation} from './Animation'; import {Event} from './Event'; import {SkeletonData} from './SkeletonData'; import {SlotData} from './SlotData'; -import {BoneData, TransformMode} from './BoneData'; +import {BoneData} from './BoneData'; import {IkConstraintData} from './IkConstraintData'; import {TransformConstraintData} from './TransformConstraintData'; -import {PathConstraintData, PositionMode, RotateMode, SpacingMode} from './PathConstraintData'; +import {PathConstraintData, SpacingMode} from './PathConstraintData'; import {Skin} from './Skin'; import {EventData} from './EventData'; import { @@ -24,7 +24,7 @@ import { TranslateTimeline, TwoColorTimeline } from './Animation'; -import {AttachmentType, BinaryInput, Color, Utils} from '@pixi-spine/base'; +import {AttachmentType, BinaryInput, Color, PositionMode, RotateMode, TransformMode, Utils} from '@pixi-spine/base'; import {BLEND_MODES} from '@pixi/constants'; /** diff --git a/packages/runtime-3.8/src/core/SkeletonData.ts b/packages/runtime-3.8/src/core/SkeletonData.ts index 10cbfcd0..308eba74 100644 --- a/packages/runtime-3.8/src/core/SkeletonData.ts +++ b/packages/runtime-3.8/src/core/SkeletonData.ts @@ -1,16 +1,17 @@ +import type {ISkeletonData} from '@pixi-spine/base'; import type {Animation} from "./Animation"; import {BoneData} from "./BoneData"; import {SlotData} from "./SlotData"; import {Skin} from "./Skin"; -import {IkConstraintData} from "./IkConstraintData"; import {EventData} from "./EventData"; +import {IkConstraintData} from "./IkConstraintData"; import {TransformConstraintData} from "./TransformConstraintData"; import {PathConstraintData} from "./PathConstraintData"; /** * @public */ -export class SkeletonData { +export class SkeletonData implements ISkeletonData { name: string; bones = new Array(); // Ordered parents first. slots = new Array(); // Setup pose draw order. diff --git a/packages/runtime-3.8/src/core/SkeletonJson.ts b/packages/runtime-3.8/src/core/SkeletonJson.ts index 83fcb8f8..1145d88c 100644 --- a/packages/runtime-3.8/src/core/SkeletonJson.ts +++ b/packages/runtime-3.8/src/core/SkeletonJson.ts @@ -3,10 +3,10 @@ import {Animation} from './Animation'; import {Event} from './Event'; import {SkeletonData} from './SkeletonData'; import {SlotData} from './SlotData'; -import {BoneData, TransformMode} from './BoneData'; +import {BoneData} from './BoneData'; import {IkConstraintData} from './IkConstraintData'; import {TransformConstraintData} from './TransformConstraintData'; -import {PathConstraintData, PositionMode, RotateMode, SpacingMode} from './PathConstraintData'; +import {PathConstraintData, SpacingMode} from './PathConstraintData'; import {Skin} from './Skin'; import {EventData} from './EventData'; import { @@ -24,7 +24,7 @@ import { TranslateTimeline, TwoColorTimeline } from './Animation'; -import {ArrayLike, Color, Utils, settings} from '@pixi-spine/base'; +import {ArrayLike, Color, PositionMode, RotateMode, TransformMode, Utils, settings} from '@pixi-spine/base'; import {BLEND_MODES} from '@pixi/constants'; /** diff --git a/packages/runtime-3.8/src/core/Skin.ts b/packages/runtime-3.8/src/core/Skin.ts index feb3fe45..a7be47d5 100644 --- a/packages/runtime-3.8/src/core/Skin.ts +++ b/packages/runtime-3.8/src/core/Skin.ts @@ -3,7 +3,7 @@ import {BoneData} from "./BoneData"; import {ConstraintData} from "./Constraint"; import {Skeleton} from "./Skeleton"; -import type {Map} from '@pixi-spine/base'; +import type {Map, ISkin} from '@pixi-spine/base'; /** * @public @@ -15,7 +15,7 @@ export class SkinEntry { /** * @public */ -export class Skin { +export class Skin implements ISkin { name: string; attachments = new Array>(); bones = Array(); diff --git a/packages/runtime-4.0/src/core/Animation.ts b/packages/runtime-4.0/src/core/Animation.ts index 174ca2e8..aab495cc 100644 --- a/packages/runtime-4.0/src/core/Animation.ts +++ b/packages/runtime-4.0/src/core/Animation.ts @@ -1,7 +1,7 @@ import {Event} from './Event'; import type {Skeleton} from "./Skeleton"; import {Attachment, VertexAttachment} from "./attachments"; -import {ArrayLike, MathUtils, StringSet, Utils} from '@pixi-spine/base'; +import {ArrayLike, IAnimation, ITimeline, MathUtils, MixBlend, StringSet, Utils, MixDirection} from '@pixi-spine/base'; import {Slot} from "./Slot"; import {IkConstraint} from "./IkConstraint"; import {TransformConstraint} from "./TransformConstraint"; @@ -10,7 +10,7 @@ import {PathConstraint} from "./PathConstraint"; * A simple container for a list of timelines and a name. * @public * */ -export class Animation { +export class Animation implements IAnimation { /** The animation's name, which is unique across all animations in the skeleton. */ name: string; timelines: Array; @@ -59,46 +59,6 @@ export class Animation { } } -/** Controls how a timeline value is mixed with the setup pose value or current pose value when a timeline's `alpha` - * < 1. - * - * See Timeline {@link Timeline#apply(Skeleton, float, float, Array, float, MixBlend, MixDirection)}. - * @public - * */ -export enum MixBlend { - /** Transitions from the setup value to the timeline value (the current value is not used). Before the first key, the setup - * value is set. */ - setup, - /** Transitions from the current value to the timeline value. Before the first key, transitions from the current value to - * the setup value. Timelines which perform instant transitions, such as {@link DrawOrderTimeline} or - * {@link AttachmentTimeline}, use the setup value before the first key. - * - * `first` is intended for the first animations applied, not for animations layered on top of those. */ - first, - /** Transitions from the current value to the timeline value. No change is made before the first key (the current value is - * kept until the first key). - * - * `replace` is intended for animations layered on top of others, not for the first animations applied. */ - replace, - /** Transitions from the current value to the current value plus the timeline value. No change is made before the first key - * (the current value is kept until the first key). - * - * `add` is intended for animations layered on top of others, not for the first animations applied. Properties - * keyed by additive animations must be set manually or by another animation before applying the additive animations, else - * the property values will increase continually. */ - add -} - -/** Indicates whether a timeline's `alpha` is mixing out over time toward 0 (the setup or current pose value) or - * mixing in toward 1 (the timeline's value). - * - * See Timeline {@link Timeline#apply(Skeleton, float, float, Array, float, MixBlend, MixDirection)}. - * @public - * */ -export enum MixDirection { - mixIn, mixOut -} - const Property = { rotate: 0, x: 1, @@ -129,7 +89,7 @@ const Property = { /** The interface for all timelines. * @public * */ -export abstract class Timeline { +export abstract class Timeline implements ITimeline { propertyIds: string[]; frames: ArrayLike; diff --git a/packages/runtime-4.0/src/core/AnimationState.ts b/packages/runtime-4.0/src/core/AnimationState.ts index 7abb4d21..a0ca1293 100644 --- a/packages/runtime-4.0/src/core/AnimationState.ts +++ b/packages/runtime-4.0/src/core/AnimationState.ts @@ -3,6 +3,8 @@ import { IAnimationStateListener, ITrackEntry, MathUtils, + MixBlend, + MixDirection, Pool, StringSet, Utils @@ -12,8 +14,6 @@ import { AttachmentTimeline, DrawOrderTimeline, EventTimeline, - MixBlend, - MixDirection, RotateTimeline, Timeline } from './Animation'; import {AnimationStateData} from "./AnimationStateData"; @@ -27,7 +27,7 @@ import type {Slot} from "./Slot"; * See [Applying Animations](http://esotericsoftware.com/spine-applying-animations/) in the Spine Runtimes Guide. * @public * */ -export class AnimationState implements IAnimationState { +export class AnimationState implements IAnimationState { private static emptyAnimation (): Animation { if (!_emptyAnimation) _emptyAnimation = new Animation("", [], 0); return _emptyAnimation; diff --git a/packages/runtime-4.0/src/core/AnimationStateData.ts b/packages/runtime-4.0/src/core/AnimationStateData.ts index 9d3e75c2..6a5fd25d 100644 --- a/packages/runtime-4.0/src/core/AnimationStateData.ts +++ b/packages/runtime-4.0/src/core/AnimationStateData.ts @@ -5,7 +5,7 @@ import type {Animation} from './Animation'; /** Stores mix (crossfade) durations to be applied when {@link AnimationState} animations are changed. * @public * */ -export class AnimationStateData implements IAnimationStateData { +export class AnimationStateData implements IAnimationStateData { /** The SkeletonData to look up animations when they are specified by name. */ skeletonData: SkeletonData; diff --git a/packages/runtime-4.0/src/core/Bone.ts b/packages/runtime-4.0/src/core/Bone.ts index 371595cd..4c8d2fee 100644 --- a/packages/runtime-4.0/src/core/Bone.ts +++ b/packages/runtime-4.0/src/core/Bone.ts @@ -1,8 +1,8 @@ import {Matrix} from '@pixi/math'; import {Updatable} from "./Updatable"; -import {BoneData, TransformMode} from "./BoneData"; +import {BoneData} from "./BoneData"; import {Skeleton} from "./Skeleton"; -import {IBone, MathUtils, settings, Vector2} from "@pixi-spine/base"; +import {IBone, MathUtils, settings, TransformMode, Vector2} from "@pixi-spine/base"; /** Stores a bone's current pose. * diff --git a/packages/runtime-4.0/src/core/BoneData.ts b/packages/runtime-4.0/src/core/BoneData.ts index f42f155b..eaf9fbd3 100644 --- a/packages/runtime-4.0/src/core/BoneData.ts +++ b/packages/runtime-4.0/src/core/BoneData.ts @@ -1,4 +1,4 @@ -import {Color} from '@pixi-spine/base'; +import {Color, TransformMode} from '@pixi-spine/base'; /** Stores the setup pose for a {@link Bone}. * @public @@ -57,10 +57,3 @@ export class BoneData { this.parent = parent; } } - -/** Determines how a bone inherits world transforms from parent bones. - * @public - * */ -export enum TransformMode { - Normal, OnlyTranslation, NoRotationOrReflection, NoScale, NoScaleOrReflection -} diff --git a/packages/runtime-4.0/src/core/IkConstraint.ts b/packages/runtime-4.0/src/core/IkConstraint.ts index c5613dd0..58238b03 100644 --- a/packages/runtime-4.0/src/core/IkConstraint.ts +++ b/packages/runtime-4.0/src/core/IkConstraint.ts @@ -2,8 +2,7 @@ import {Updatable} from "./Updatable"; import {IkConstraintData} from "./IkConstraintData"; import {Bone} from "./Bone"; import {Skeleton} from "./Skeleton"; -import {TransformMode} from "./BoneData"; -import {MathUtils} from "@pixi-spine/base"; +import {MathUtils, TransformMode} from "@pixi-spine/base"; /** Stores the current pose for an IK constraint. An IK constraint adjusts the rotation of 1 or 2 constrained bones so the tip of * the last bone is as close to the target bone as possible. diff --git a/packages/runtime-4.0/src/core/PathConstraint.ts b/packages/runtime-4.0/src/core/PathConstraint.ts index 86e72789..551b5a6d 100644 --- a/packages/runtime-4.0/src/core/PathConstraint.ts +++ b/packages/runtime-4.0/src/core/PathConstraint.ts @@ -1,10 +1,10 @@ import {PathAttachment} from "./attachments"; import {Updatable} from "./Updatable"; -import {PathConstraintData, PositionMode, RotateMode, SpacingMode} from "./PathConstraintData"; +import {PathConstraintData, SpacingMode} from "./PathConstraintData"; import {Bone} from "./Bone"; import {Slot} from "./Slot"; import {Skeleton} from "./Skeleton"; -import {MathUtils, Utils} from "@pixi-spine/base"; +import {MathUtils, PositionMode, RotateMode, Utils} from "@pixi-spine/base"; /** Stores the current pose for a path constraint. A path constraint adjusts the rotation, translation, and scale of the * constrained bones so they follow a {@link PathAttachment}. * diff --git a/packages/runtime-4.0/src/core/PathConstraintData.ts b/packages/runtime-4.0/src/core/PathConstraintData.ts index 26d6d80d..00e282ee 100644 --- a/packages/runtime-4.0/src/core/PathConstraintData.ts +++ b/packages/runtime-4.0/src/core/PathConstraintData.ts @@ -1,6 +1,7 @@ import {ConstraintData} from "./ConstraintData"; import type {SlotData} from "./SlotData"; import type {BoneData} from "./BoneData"; +import { PositionMode, RotateMode } from "@pixi-spine/base"; /** Stores the setup pose for a {@link PathConstraint}. * @@ -42,15 +43,6 @@ export class PathConstraintData extends ConstraintData { } } -/** Controls how the first bone is positioned along the path. - * - * See [Position mode](http://esotericsoftware.com/spine-path-constraints#Position-mode) in the Spine User Guide. - * @public - * */ -export enum PositionMode { - Fixed, Percent -} - /** Controls how bones after the first bone are positioned along the path. * * [Spacing mode](http://esotericsoftware.com/spine-path-constraints#Spacing-mode) in the Spine User Guide. @@ -59,12 +51,3 @@ export enum PositionMode { export enum SpacingMode { Length, Fixed, Percent, Proportional } - -/** Controls how bones are rotated, translated, and scaled to match the path. - * - * [Rotate mode](http://esotericsoftware.com/spine-path-constraints#Rotate-mod) in the Spine User Guide. - * @public - * */ -export enum RotateMode { - Tangent, Chain, ChainScale -} diff --git a/packages/runtime-4.0/src/core/Skeleton.ts b/packages/runtime-4.0/src/core/Skeleton.ts index f5640c92..a1d2de06 100644 --- a/packages/runtime-4.0/src/core/Skeleton.ts +++ b/packages/runtime-4.0/src/core/Skeleton.ts @@ -14,7 +14,7 @@ import {Color, MathUtils, settings, Utils, Vector2, ISkeleton} from "@pixi-spine * See [Instance objects](http://esotericsoftware.com/spine-runtime-architecture#Instance-objects) in the Spine Runtimes Guide. * @public * */ -export class Skeleton implements ISkeleton { +export class Skeleton implements ISkeleton { /** The skeleton's setup pose data. */ data: SkeletonData; diff --git a/packages/runtime-4.0/src/core/SkeletonBinary.ts b/packages/runtime-4.0/src/core/SkeletonBinary.ts index 0369b9e1..7f5095d3 100644 --- a/packages/runtime-4.0/src/core/SkeletonBinary.ts +++ b/packages/runtime-4.0/src/core/SkeletonBinary.ts @@ -19,10 +19,10 @@ import {SlotData} from './SlotData'; import {BoneData} from './BoneData'; import {IkConstraintData} from './IkConstraintData'; import {TransformConstraintData} from './TransformConstraintData'; -import {PathConstraintData, PositionMode, SpacingMode} from './PathConstraintData'; +import {PathConstraintData, SpacingMode} from './PathConstraintData'; import {Skin} from './Skin'; import {EventData} from './EventData'; -import {AttachmentType, BinaryInput, Color, Utils} from '@pixi-spine/base'; +import {AttachmentType, BinaryInput, Color, PositionMode, Utils} from '@pixi-spine/base'; import {BLEND_MODES} from '@pixi/constants'; /** Loads skeleton data in the Spine binary format. diff --git a/packages/runtime-4.0/src/core/SkeletonData.ts b/packages/runtime-4.0/src/core/SkeletonData.ts index d3a3b4e5..7fa55cf6 100644 --- a/packages/runtime-4.0/src/core/SkeletonData.ts +++ b/packages/runtime-4.0/src/core/SkeletonData.ts @@ -1,9 +1,10 @@ +import type {ISkeletonData} from "@pixi-spine/base"; import type {Animation} from "./Animation"; import {BoneData} from "./BoneData"; import {SlotData} from "./SlotData"; import {Skin} from "./Skin"; -import {IkConstraintData} from "./IkConstraintData"; import {EventData} from "./EventData"; +import {IkConstraintData} from "./IkConstraintData"; import {TransformConstraintData} from "./TransformConstraintData"; import {PathConstraintData} from "./PathConstraintData"; @@ -13,7 +14,7 @@ import {PathConstraintData} from "./PathConstraintData"; * Guide. * @public * */ -export class SkeletonData { +export class SkeletonData implements ISkeletonData { /** The skeleton's name, which by default is the name of the skeleton data file, if possible. May be null. */ name: string; diff --git a/packages/runtime-4.0/src/core/SkeletonJson.ts b/packages/runtime-4.0/src/core/SkeletonJson.ts index 3bdcc8a0..2f9d2979 100644 --- a/packages/runtime-4.0/src/core/SkeletonJson.ts +++ b/packages/runtime-4.0/src/core/SkeletonJson.ts @@ -16,13 +16,13 @@ import { import {Event} from './Event'; import {SkeletonData} from './SkeletonData'; import {SlotData} from './SlotData'; -import {BoneData, TransformMode} from './BoneData'; +import {BoneData} from './BoneData'; import {IkConstraintData} from './IkConstraintData'; import {TransformConstraintData} from './TransformConstraintData'; -import {PathConstraintData, PositionMode, RotateMode, SpacingMode} from './PathConstraintData'; +import {PathConstraintData, SpacingMode} from './PathConstraintData'; import {Skin} from './Skin'; import {EventData} from './EventData'; -import {ArrayLike, Color, Utils, settings} from '@pixi-spine/base'; +import {ArrayLike, Color, PositionMode, RotateMode, TransformMode, Utils, settings} from '@pixi-spine/base'; import {BLEND_MODES} from '@pixi/constants'; /** Loads skeleton data in the Spine JSON format. diff --git a/packages/runtime-4.0/src/core/Skin.ts b/packages/runtime-4.0/src/core/Skin.ts index 8fbd921c..2a2f797b 100644 --- a/packages/runtime-4.0/src/core/Skin.ts +++ b/packages/runtime-4.0/src/core/Skin.ts @@ -3,7 +3,7 @@ import {BoneData} from "./BoneData"; import {ConstraintData} from "./ConstraintData"; import {Skeleton} from "./Skeleton"; -import type {Map} from '@pixi-spine/base'; +import type {Map, ISkin} from '@pixi-spine/base'; /** Stores an entry in the skin consisting of the slot index, name, and attachment * @public @@ -18,7 +18,7 @@ export class SkinEntry { * [Runtime skins](http://esotericsoftware.com/spine-runtime-skins) in the Spine Runtimes Guide. * @public * */ -export class Skin { +export class Skin implements ISkin { /** The skin's name, which is unique across all skins in the skeleton. */ name: string;