-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #407 from liamf1986/wip-interfaces-
Interface integration
- Loading branch information
Showing
44 changed files
with
376 additions
and
381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Timeline extends ITimeline = ITimeline> { | ||
name: string; | ||
timelines: Timeline[]; | ||
duration: number; | ||
} | ||
|
||
/** | ||
* @public | ||
*/ | ||
export interface IAnimationState<AnimationStateData extends IAnimationStateData = IAnimationStateData> { | ||
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 extends ISkeletonData = ISkeletonData, Animation extends IAnimation = IAnimation> { | ||
skeletonData: SkeletonData; | ||
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; | ||
} | ||
|
||
/** | ||
* @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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
Oops, something went wrong.