mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
ab81890aa8
Binary file not shown.
@ -307,7 +307,7 @@ public class Bone implements Updatable {
|
|||||||
* the applied transform after the world transform has been modified directly (eg, by a constraint).
|
* the applied transform after the world transform has been modified directly (eg, by a constraint).
|
||||||
* <p>
|
* <p>
|
||||||
* Some information is ambiguous in the world transform, such as -1,-1 scale versus 180 rotation. */
|
* Some information is ambiguous in the world transform, such as -1,-1 scale versus 180 rotation. */
|
||||||
function updateAppliedTransform () : void {
|
internal function updateAppliedTransform () : void {
|
||||||
appliedValid = true;
|
appliedValid = true;
|
||||||
var parent:Bone = this.parent;
|
var parent:Bone = this.parent;
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
|
|||||||
@ -59,14 +59,20 @@ public class AttachmentTimeline implements Timeline {
|
|||||||
|
|
||||||
public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||||
var attachmentName:String;
|
var attachmentName:String;
|
||||||
if (mixingOut && setupPose) {
|
var slot:Slot = skeleton.slots[slotIndex];
|
||||||
var slot:Slot = skeleton.slots[slotIndex];
|
if (mixingOut && setupPose) {
|
||||||
attachmentName = slot.data.attachmentName;
|
attachmentName = slot.data.attachmentName;
|
||||||
slot.attachment = attachmentName == null ? null : skeleton.getAttachmentForSlotIndex(slotIndex, attachmentName);
|
slot.attachment = attachmentName == null ? null : skeleton.getAttachmentForSlotIndex(slotIndex, attachmentName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var frames:Vector.<Number> = this.frames;
|
var frames:Vector.<Number> = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
attachmentName = slot.data.attachmentName;
|
||||||
|
slot.attachment = attachmentName == null ? null : skeleton.getAttachmentForSlotIndex(slotIndex, attachmentName);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var frameIndex:int;
|
var frameIndex:int;
|
||||||
if (time >= frames[frames.length - 1]) // Time is after last frame.
|
if (time >= frames[frames.length - 1]) // Time is after last frame.
|
||||||
|
|||||||
@ -62,7 +62,17 @@ public class ColorTimeline extends CurveTimeline {
|
|||||||
|
|
||||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||||
var frames:Vector.<Number> = this.frames;
|
var frames:Vector.<Number> = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
var slot:Slot = skeleton.slots[slotIndex];
|
||||||
|
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
slot.r = slot.data.r;
|
||||||
|
slot.g = slot.data.g;
|
||||||
|
slot.b = slot.data.b;
|
||||||
|
slot.a = slot.data.a;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var r:Number, g:Number, b:Number, a:Number;
|
var r:Number, g:Number, b:Number, a:Number;
|
||||||
if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
|
||||||
@ -86,8 +96,7 @@ public class ColorTimeline extends CurveTimeline {
|
|||||||
g += (frames[frame + G] - g) * percent;
|
g += (frames[frame + G] - g) * percent;
|
||||||
b += (frames[frame + B] - b) * percent;
|
b += (frames[frame + B] - b) * percent;
|
||||||
a += (frames[frame + A] - a) * percent;
|
a += (frames[frame + A] - a) * percent;
|
||||||
}
|
}
|
||||||
var slot:Slot = skeleton.slots[slotIndex];
|
|
||||||
if (alpha == 1) {
|
if (alpha == 1) {
|
||||||
slot.r = r;
|
slot.r = r;
|
||||||
slot.g = g;
|
slot.g = g;
|
||||||
|
|||||||
@ -63,12 +63,15 @@ public class DeformTimeline extends CurveTimeline {
|
|||||||
if (!(slotAttachment is VertexAttachment) || !(VertexAttachment(slotAttachment)).applyDeform(attachment)) return;
|
if (!(slotAttachment is VertexAttachment) || !(VertexAttachment(slotAttachment)).applyDeform(attachment)) return;
|
||||||
|
|
||||||
var frames:Vector.<Number> = this.frames;
|
var frames:Vector.<Number> = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
var verticesArray:Vector.<Number> = slot.attachmentVertices;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) verticesArray.length = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var frameVertices:Vector.<Vector.<Number>> = this.frameVertices;
|
var frameVertices:Vector.<Vector.<Number>> = this.frameVertices;
|
||||||
var vertexCount:int = frameVertices[0].length;
|
var vertexCount:int = frameVertices[0].length;
|
||||||
|
|
||||||
var verticesArray:Vector.<Number> = slot.attachmentVertices;
|
|
||||||
if (verticesArray.length != vertexCount) alpha = 1; // Don't mix from uninitialized slot vertices.
|
if (verticesArray.length != vertexCount) alpha = 1; // Don't mix from uninitialized slot vertices.
|
||||||
verticesArray.length = vertexCount;
|
verticesArray.length = vertexCount;
|
||||||
var vertices:Vector.<Number> = verticesArray;
|
var vertices:Vector.<Number> = verticesArray;
|
||||||
|
|||||||
@ -62,9 +62,17 @@ public class DrawOrderTimeline implements Timeline {
|
|||||||
skeleton.drawOrder[ii] = skeleton.slots[ii];
|
skeleton.drawOrder[ii] = skeleton.slots[ii];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (time < frames[0])
|
var drawOrder:Vector.<Slot> = skeleton.drawOrder;
|
||||||
return; // Time is before first frame.
|
var slots:Vector.<Slot> = skeleton.slots;
|
||||||
|
var slot:Slot;
|
||||||
|
var i:int = 0;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
for each (slot in slots)
|
||||||
|
drawOrder[i++] = slot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var frameIndex:int;
|
var frameIndex:int;
|
||||||
if (time >= frames[int(frames.length - 1)]) // Time is after last frame.
|
if (time >= frames[int(frames.length - 1)]) // Time is after last frame.
|
||||||
@ -72,12 +80,10 @@ public class DrawOrderTimeline implements Timeline {
|
|||||||
else
|
else
|
||||||
frameIndex = Animation.binarySearch1(frames, time) - 1;
|
frameIndex = Animation.binarySearch1(frames, time) - 1;
|
||||||
|
|
||||||
var drawOrder:Vector.<Slot> = skeleton.drawOrder;
|
|
||||||
var slots:Vector.<Slot> = skeleton.slots;
|
|
||||||
var drawOrderToSetupIndex:Vector.<int> = drawOrders[frameIndex];
|
var drawOrderToSetupIndex:Vector.<int> = drawOrders[frameIndex];
|
||||||
var i:int = 0;
|
i = 0;
|
||||||
if (!drawOrderToSetupIndex) {
|
if (!drawOrderToSetupIndex) {
|
||||||
for each (var slot:Slot in slots)
|
for each (slot in slots)
|
||||||
drawOrder[i++] = slot;
|
drawOrder[i++] = slot;
|
||||||
} else {
|
} else {
|
||||||
for each (var setupIndex:int in drawOrderToSetupIndex)
|
for each (var setupIndex:int in drawOrderToSetupIndex)
|
||||||
|
|||||||
@ -59,9 +59,14 @@ public class IkConstraintTimeline extends CurveTimeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
var constraint:IkConstraint = skeleton.ikConstraints[ikConstraintIndex];
|
var constraint:IkConstraint = skeleton.ikConstraints[ikConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint.mix = constraint.data.mix;
|
||||||
|
constraint.bendDirection = constraint.data.bendDirection;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (time >= frames[int(frames.length - ENTRIES)]) { // Time is after last frame.
|
if (time >= frames[int(frames.length - ENTRIES)]) { // Time is after last frame.
|
||||||
if (setupPose) {
|
if (setupPose) {
|
||||||
|
|||||||
@ -59,10 +59,15 @@ public class PathConstraintMixTimeline extends CurveTimeline {
|
|||||||
frames[frameIndex + TRANSLATE] = translateMix;
|
frames[frameIndex + TRANSLATE] = translateMix;
|
||||||
}
|
}
|
||||||
|
|
||||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
var constraint:PathConstraint = skeleton.pathConstraints[pathConstraintIndex];
|
var constraint:PathConstraint = skeleton.pathConstraints[pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint.rotateMix = constraint.data.rotateMix;
|
||||||
|
constraint.translateMix = constraint.data.translateMix;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var rotate:Number, translate:Number;
|
var rotate:Number, translate:Number;
|
||||||
if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
|
||||||
|
|||||||
@ -58,10 +58,12 @@ public class PathConstraintPositionTimeline extends CurveTimeline {
|
|||||||
frames[frameIndex + VALUE] = value;
|
frames[frameIndex + VALUE] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
var constraint:PathConstraint = skeleton.pathConstraints[pathConstraintIndex];
|
var constraint:PathConstraint = skeleton.pathConstraints[pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) constraint.position = constraint.data.position;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var position:Number;
|
var position:Number;
|
||||||
if (time >= frames[frames.length - ENTRIES]) // Time is after last frame.
|
if (time >= frames[frames.length - ENTRIES]) // Time is after last frame.
|
||||||
|
|||||||
@ -43,9 +43,11 @@ public class PathConstraintSpacingTimeline extends PathConstraintPositionTimelin
|
|||||||
}
|
}
|
||||||
|
|
||||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
var constraint:PathConstraint = skeleton.pathConstraints[pathConstraintIndex];
|
var constraint:PathConstraint = skeleton.pathConstraints[pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) constraint.spacing = constraint.data.spacing;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var spacing:Number;
|
var spacing:Number;
|
||||||
if (time >= frames[frames.length - ENTRIES]) // Time is after last frame.
|
if (time >= frames[frames.length - ENTRIES]) // Time is after last frame.
|
||||||
|
|||||||
@ -58,11 +58,14 @@ public class RotateTimeline extends CurveTimeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||||
var frames:Vector.<Number> = this.frames;
|
var frames:Vector.<Number> = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
var bone:Bone = skeleton.bones[boneIndex];
|
var bone:Bone = skeleton.bones[boneIndex];
|
||||||
var r:Number;
|
var r:Number;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) bone.rotation = bone.data.rotation;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
|
||||||
if (setupPose)
|
if (setupPose)
|
||||||
|
|||||||
@ -45,9 +45,15 @@ public class ScaleTimeline extends TranslateTimeline {
|
|||||||
|
|
||||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||||
var frames:Vector.<Number> = this.frames;
|
var frames:Vector.<Number> = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
var bone:Bone = skeleton.bones[boneIndex];
|
var bone:Bone = skeleton.bones[boneIndex];
|
||||||
|
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.scaleX = bone.data.scaleX;
|
||||||
|
bone.scaleY = bone.data.scaleY;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var x:Number, y:Number;
|
var x:Number, y:Number;
|
||||||
if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
|
||||||
|
|||||||
@ -43,10 +43,16 @@ public class ShearTimeline extends TranslateTimeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||||
var frames:Vector.<Number> = this.frames;
|
var frames:Vector.<Number> = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
var bone:Bone = skeleton.bones[boneIndex];
|
var bone:Bone = skeleton.bones[boneIndex];
|
||||||
|
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.shearX = bone.data.shearX;
|
||||||
|
bone.shearY = bone.data.shearY;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var x:Number, y:Number;
|
var x:Number, y:Number;
|
||||||
if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
|
||||||
|
|||||||
@ -49,6 +49,9 @@ public class TrackEntry implements Poolable {
|
|||||||
public var timelinesFirst:Vector.<Boolean> = new Vector.<Boolean>();
|
public var timelinesFirst:Vector.<Boolean> = new Vector.<Boolean>();
|
||||||
public var timelinesRotation:Vector.<Number> = new Vector.<Number>();
|
public var timelinesRotation:Vector.<Number> = new Vector.<Number>();
|
||||||
|
|
||||||
|
public function TrackEntry () {
|
||||||
|
}
|
||||||
|
|
||||||
public function getAnimationTime():Number {
|
public function getAnimationTime():Number {
|
||||||
if (loop) {
|
if (loop) {
|
||||||
var duration:Number = animationEnd - animationStart;
|
var duration:Number = animationEnd - animationStart;
|
||||||
|
|||||||
@ -62,10 +62,20 @@ public class TransformConstraintTimeline extends CurveTimeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||||
var frames:Vector.<Number> = this.frames;
|
var frames:Vector.<Number> = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
var constraint:TransformConstraint = skeleton.transformConstraints[transformConstraintIndex];
|
var constraint:TransformConstraint = skeleton.transformConstraints[transformConstraintIndex];
|
||||||
|
var data:TransformConstraintData;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
data = constraint.data;
|
||||||
|
constraint.rotateMix = constraint.data.rotateMix;
|
||||||
|
constraint.translateMix = constraint.data.translateMix;
|
||||||
|
constraint.scaleMix = constraint.data.scaleMix;
|
||||||
|
constraint.shearMix = constraint.data.shearMix;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var rotate:Number, translate:Number, scale:Number, shear:Number;
|
var rotate:Number, translate:Number, scale:Number, shear:Number;
|
||||||
if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
|
||||||
@ -91,7 +101,7 @@ public class TransformConstraintTimeline extends CurveTimeline {
|
|||||||
shear += (frames[frame + SHEAR] - shear) * percent;
|
shear += (frames[frame + SHEAR] - shear) * percent;
|
||||||
}
|
}
|
||||||
if (setupPose) {
|
if (setupPose) {
|
||||||
var data:TransformConstraintData = constraint.data;
|
data = constraint.data;
|
||||||
constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha;
|
constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha;
|
||||||
constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha;
|
constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha;
|
||||||
constraint.scaleMix = data.scaleMix + (scale - data.scaleMix) * alpha;
|
constraint.scaleMix = data.scaleMix + (scale - data.scaleMix) * alpha;
|
||||||
|
|||||||
@ -59,10 +59,16 @@ public class TranslateTimeline extends CurveTimeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
override public function apply (skeleton:Skeleton, lastTime:Number, time:Number, firedEvents:Vector.<Event>, alpha:Number, setupPose:Boolean, mixingOut:Boolean) : void {
|
||||||
var frames:Vector.<Number> = this.frames;
|
var frames:Vector.<Number> = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
var bone:Bone = skeleton.bones[boneIndex];
|
var bone:Bone = skeleton.bones[boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.x = bone.data.x;
|
||||||
|
bone.y = bone.data.y;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var x:Number, y:Number;
|
var x:Number, y:Number;
|
||||||
if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.length - ENTRIES]) { // Time is after last frame.
|
||||||
|
|||||||
@ -44,56 +44,62 @@ typedef enum {
|
|||||||
} spEventType;
|
} spEventType;
|
||||||
|
|
||||||
typedef struct spAnimationState spAnimationState;
|
typedef struct spAnimationState spAnimationState;
|
||||||
|
|
||||||
typedef void (*spAnimationStateListener) (spAnimationState* state, int trackIndex, spEventType type, spEvent* event,
|
|
||||||
int loopCount);
|
|
||||||
|
|
||||||
typedef struct spTrackEntry spTrackEntry;
|
typedef struct spTrackEntry spTrackEntry;
|
||||||
struct spTrackEntry {
|
|
||||||
spAnimationState* const state;
|
|
||||||
spTrackEntry* next;
|
|
||||||
spTrackEntry* previous;
|
|
||||||
spAnimation* animation;
|
|
||||||
int/*bool*/loop;
|
|
||||||
float delay, time, lastTime, endTime, timeScale;
|
|
||||||
spAnimationStateListener listener;
|
|
||||||
float mixTime, mixDuration, mix;
|
|
||||||
|
|
||||||
void* rendererObject;
|
typedef void (*spAnimationStateListener) (spAnimationState* state, spEventType type, spTrackEntry* entry, spEvent* event);
|
||||||
|
|
||||||
|
struct spTrackEntry {
|
||||||
|
spAnimation* animation;
|
||||||
|
spTrackEntry* next;
|
||||||
|
spTrackEntry* mixingFrom;
|
||||||
|
spAnimationStateListener listener;
|
||||||
|
int trackIndex;
|
||||||
|
int /*boolean*/ loop;
|
||||||
|
float eventThreshold, attachmentThreshold, drawOrderThreshold;
|
||||||
|
float animationStart, animationEnd, animationLast, nextAnimationLast;
|
||||||
|
float delay, trackTime, trackLast, nextTrackLast, trackEnd, timeScale;
|
||||||
|
float alpha, mixTime, mixDuration, mixAlpha;
|
||||||
|
int* /*boolean*/ timelinesFirst;
|
||||||
|
int timelinesFirstCount;
|
||||||
|
float* timelinesRotation;
|
||||||
|
int timelinesRotationCount;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
spTrackEntry() :
|
spTrackEntry() :
|
||||||
state(0),
|
|
||||||
next(0),
|
|
||||||
previous(0),
|
|
||||||
animation(0),
|
animation(0),
|
||||||
loop(0),
|
next(0), mixingFrom(0),
|
||||||
delay(0), time(0), lastTime(0), endTime(0), timeScale(0),
|
|
||||||
listener(0),
|
listener(0),
|
||||||
mixTime(0), mixDuration(0), mix(0),
|
trackIndex(0),
|
||||||
rendererObject(0) {
|
loop(0),
|
||||||
|
eventThreshold(0), attachmentThreshold(0), drawOrderThreshold(0),
|
||||||
|
animationStart(0), animationEnd(0), animationLast(0), nextAnimationLast(0),
|
||||||
|
delay(0), trackTime(0), trackLast(0), nextTrackLast(0), trackEnd(0), timeScale(0),
|
||||||
|
alpha(0), mixTime(0), mixDuration(0), mixAlpha(0),
|
||||||
|
timelinesFirst(0),
|
||||||
|
timelinesFirstCount(0),
|
||||||
|
timelinesRotation(0),
|
||||||
|
timelinesRotationCount(0) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct spAnimationState {
|
struct spAnimationState {
|
||||||
spAnimationStateData* const data;
|
spAnimationStateData* const data;
|
||||||
float timeScale;
|
|
||||||
spAnimationStateListener listener;
|
|
||||||
|
|
||||||
int tracksCount;
|
int tracksCount;
|
||||||
spTrackEntry** tracks;
|
spTrackEntry** tracks;
|
||||||
|
|
||||||
void* rendererObject;
|
spAnimationStateListener listener;
|
||||||
|
|
||||||
|
float timeScale;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
spAnimationState() :
|
spAnimationState() :
|
||||||
data(0),
|
data(0),
|
||||||
timeScale(0),
|
|
||||||
listener(0),
|
|
||||||
tracksCount(0),
|
|
||||||
tracks(0),
|
tracks(0),
|
||||||
rendererObject(0) {
|
tracksCount(0),
|
||||||
|
listener(0),
|
||||||
|
timeScale(0) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@ -119,14 +125,21 @@ spTrackEntry* spAnimationState_addAnimationByName (spAnimationState* self, int t
|
|||||||
int/*bool*/loop, float delay);
|
int/*bool*/loop, float delay);
|
||||||
spTrackEntry* spAnimationState_addAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop,
|
spTrackEntry* spAnimationState_addAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop,
|
||||||
float delay);
|
float delay);
|
||||||
|
spTrackEntry* spAnimationState_setEmptyAnimation(spAnimationState* self, int trackIndex, float mixDuration);
|
||||||
|
spTrackEntry* spAnimationState_addEmptyAnimation(spAnimationState* self, int trackIndex, float mixDuration, float delay);
|
||||||
|
spTrackEntry* spAnimationState_setEmptyAnimations(spAnimationState* self, float mixDuration);
|
||||||
|
|
||||||
spTrackEntry* spAnimationState_getCurrent (spAnimationState* self, int trackIndex);
|
spTrackEntry* spAnimationState_getCurrent (spAnimationState* self, int trackIndex);
|
||||||
|
|
||||||
|
spTrackEntry* spAnimationState_clearListenerNotifications(spAnimationState* self);
|
||||||
|
|
||||||
#ifdef SPINE_SHORT_NAMES
|
#ifdef SPINE_SHORT_NAMES
|
||||||
typedef spEventType EventType;
|
typedef spEventType EventType;
|
||||||
#define ANIMATION_START SP_ANIMATION_START
|
#define ANIMATION_START SP_ANIMATION_START
|
||||||
|
#define ANIMATION_INTERRUPT SP_ANIMATION_INTERRUPT
|
||||||
#define ANIMATION_END SP_ANIMATION_END
|
#define ANIMATION_END SP_ANIMATION_END
|
||||||
#define ANIMATION_COMPLETE SP_ANIMATION_COMPLETE
|
#define ANIMATION_COMPLETE SP_ANIMATION_COMPLETE
|
||||||
|
#define ANIMATION_DISPOSE SP_ANIMATION_DISPOSE
|
||||||
#define ANIMATION_EVENT SP_ANIMATION_EVENT
|
#define ANIMATION_EVENT SP_ANIMATION_EVENT
|
||||||
typedef spAnimationStateListener AnimationStateListener;
|
typedef spAnimationStateListener AnimationStateListener;
|
||||||
typedef spTrackEntry TrackEntry;
|
typedef spTrackEntry TrackEntry;
|
||||||
@ -141,7 +154,11 @@ typedef spAnimationState AnimationState;
|
|||||||
#define AnimationState_setAnimation(...) spAnimationState_setAnimation(__VA_ARGS__)
|
#define AnimationState_setAnimation(...) spAnimationState_setAnimation(__VA_ARGS__)
|
||||||
#define AnimationState_addAnimationByName(...) spAnimationState_addAnimationByName(__VA_ARGS__)
|
#define AnimationState_addAnimationByName(...) spAnimationState_addAnimationByName(__VA_ARGS__)
|
||||||
#define AnimationState_addAnimation(...) spAnimationState_addAnimation(__VA_ARGS__)
|
#define AnimationState_addAnimation(...) spAnimationState_addAnimation(__VA_ARGS__)
|
||||||
|
#define AnimationState_setEmptyAnimation(...) spAnimatinState_setEmptyAnimation(__VA_ARGS__)
|
||||||
|
#define AnimationState_addEmptyAnimation(...) spAnimatinState_addEmptyAnimation(__VA_ARGS__)
|
||||||
|
#define AnimationState_setEmptyAnimations(...) spAnimatinState_setEmptyAnimations(__VA_ARGS__)
|
||||||
#define AnimationState_getCurrent(...) spAnimationState_getCurrent(__VA_ARGS__)
|
#define AnimationState_getCurrent(...) spAnimationState_getCurrent(__VA_ARGS__)
|
||||||
|
#define AnimationState_clearListenerNotifications(...) spAnimatinState_clearListenerNotifications(__VA_ARGS__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@ -171,25 +171,53 @@ char* _readFile (const char* path, int* length);
|
|||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
|
typedef union _spEventQueueItem {
|
||||||
|
int type;
|
||||||
|
spTrackEntry* entry;
|
||||||
|
spEvent* event;
|
||||||
|
} _spEventQueueItem;
|
||||||
|
|
||||||
|
typedef struct _spEventQueue {
|
||||||
|
spAnimationState* state;
|
||||||
|
_spEventQueueItem* objects;
|
||||||
|
int objectsCount;
|
||||||
|
int objectsCapacity;
|
||||||
|
int /*boolean*/ drainDisabled;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
_spEventQueue() :
|
||||||
|
state(0),
|
||||||
|
objects(0),
|
||||||
|
objectsCount(0),
|
||||||
|
drainDisabled(0) {
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
} _spEventQueue;
|
||||||
|
|
||||||
typedef struct _spAnimationState {
|
typedef struct _spAnimationState {
|
||||||
spAnimationState super;
|
spAnimationState super;
|
||||||
|
|
||||||
|
int eventsCount;
|
||||||
spEvent** events;
|
spEvent** events;
|
||||||
|
|
||||||
spTrackEntry* (*createTrackEntry) (spAnimationState* self);
|
_spEventQueue* queue;
|
||||||
void (*disposeTrackEntry) (spTrackEntry* entry);
|
|
||||||
|
void* propertyIDs;
|
||||||
|
|
||||||
|
int /*boolean*/ animationsChanged;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
_spAnimationState() :
|
_spAnimationState() :
|
||||||
super(),
|
super(),
|
||||||
|
eventsCount(0),
|
||||||
events(0),
|
events(0),
|
||||||
createTrackEntry(0),
|
queue(0),
|
||||||
disposeTrackEntry(0) {
|
propertyIDs(0),
|
||||||
|
animationsChanged(0) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} _spAnimationState;
|
} _spAnimationState;
|
||||||
|
|
||||||
spTrackEntry* _spTrackEntry_create (spAnimationState* self);
|
|
||||||
void _spTrackEntry_dispose (spTrackEntry* self);
|
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
|
|||||||
@ -245,7 +245,10 @@ void _spRotateTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton,
|
|||||||
|
|
||||||
spRotateTimeline* self = SUB_CAST(spRotateTimeline, timeline);
|
spRotateTimeline* self = SUB_CAST(spRotateTimeline, timeline);
|
||||||
|
|
||||||
if (time < self->frames[0]) return; /* Time is before first frame. */
|
if (time < self->frames[0]) {
|
||||||
|
if (setupPose) bone->rotation = bone->data->rotation;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bone = skeleton->bones[self->boneIndex];
|
bone = skeleton->bones[self->boneIndex];
|
||||||
|
|
||||||
@ -313,9 +316,14 @@ void _spTranslateTimeline_apply (const spTimeline* timeline, spSkeleton* skeleto
|
|||||||
|
|
||||||
spTranslateTimeline* self = SUB_CAST(spTranslateTimeline, timeline);
|
spTranslateTimeline* self = SUB_CAST(spTranslateTimeline, timeline);
|
||||||
|
|
||||||
if (time < self->frames[0]) return; /* Time is before first frame. */
|
|
||||||
|
|
||||||
bone = skeleton->bones[self->boneIndex];
|
bone = skeleton->bones[self->boneIndex];
|
||||||
|
if (time < self->frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone->x = bone->data->x;
|
||||||
|
bone->y = bone->data->y;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
frames = self->frames;
|
frames = self->frames;
|
||||||
framesCount = self->framesCount;
|
framesCount = self->framesCount;
|
||||||
@ -374,9 +382,14 @@ void _spScaleTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, f
|
|||||||
|
|
||||||
spScaleTimeline* self = SUB_CAST(spScaleTimeline, timeline);
|
spScaleTimeline* self = SUB_CAST(spScaleTimeline, timeline);
|
||||||
|
|
||||||
if (time < self->frames[0]) return; /* Time is before first frame. */
|
|
||||||
|
|
||||||
bone = skeleton->bones[self->boneIndex];
|
bone = skeleton->bones[self->boneIndex];
|
||||||
|
if (time < self->frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone->scaleX = bone->data->scaleX;
|
||||||
|
bone->scaleY = bone->data->scaleY;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
frames = self->frames;
|
frames = self->frames;
|
||||||
framesCount = self->framesCount;
|
framesCount = self->framesCount;
|
||||||
@ -448,11 +461,16 @@ void _spShearTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, f
|
|||||||
|
|
||||||
spShearTimeline* self = SUB_CAST(spShearTimeline, timeline);
|
spShearTimeline* self = SUB_CAST(spShearTimeline, timeline);
|
||||||
|
|
||||||
if (time < self->frames[0]) return; /* Time is before first frame. */
|
|
||||||
|
|
||||||
bone = skeleton->bones[self->boneIndex];
|
bone = skeleton->bones[self->boneIndex];
|
||||||
frames = self->frames;
|
frames = self->frames;
|
||||||
framesCount = self->framesCount;
|
framesCount = self->framesCount;
|
||||||
|
if (time < self->frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone->shearX = bone->data->shearX;
|
||||||
|
bone->shearY = bone->data->shearY;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (time >= frames[framesCount - TRANSLATE_ENTRIES]) { /* Time is after last frame. */
|
if (time >= frames[framesCount - TRANSLATE_ENTRIES]) { /* Time is after last frame. */
|
||||||
x = frames[framesCount + TRANSLATE_PREV_X];
|
x = frames[framesCount + TRANSLATE_PREV_X];
|
||||||
@ -506,8 +524,17 @@ void _spColorTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, f
|
|||||||
float percent, frameTime;
|
float percent, frameTime;
|
||||||
float r, g, b, a;
|
float r, g, b, a;
|
||||||
spColorTimeline* self = (spColorTimeline*)timeline;
|
spColorTimeline* self = (spColorTimeline*)timeline;
|
||||||
|
slot = skeleton->slots[self->slotIndex];
|
||||||
|
|
||||||
if (time < self->frames[0]) return; /* Time is before first frame. */
|
if (time < self->frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
slot->r = slot->data->r;
|
||||||
|
slot->g = slot->data->g;
|
||||||
|
slot->b = slot->data->b;
|
||||||
|
slot->a = slot->data->a;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (time >= self->frames[self->framesCount - 5]) { /* Time is after last frame */
|
if (time >= self->frames[self->framesCount - 5]) { /* Time is after last frame */
|
||||||
int i = self->framesCount;
|
int i = self->framesCount;
|
||||||
@ -533,7 +560,6 @@ void _spColorTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, f
|
|||||||
b += (self->frames[frame + COLOR_B] - b) * percent;
|
b += (self->frames[frame + COLOR_B] - b) * percent;
|
||||||
a += (self->frames[frame + COLOR_A] - a) * percent;
|
a += (self->frames[frame + COLOR_A] - a) * percent;
|
||||||
}
|
}
|
||||||
slot = skeleton->slots[self->slotIndex];
|
|
||||||
if (alpha == 1) {
|
if (alpha == 1) {
|
||||||
slot->r = r;
|
slot->r = r;
|
||||||
slot->g = g;
|
slot->g = g;
|
||||||
@ -581,15 +607,22 @@ void _spAttachmentTimeline_apply (const spTimeline* timeline, spSkeleton* skelet
|
|||||||
const char* attachmentName;
|
const char* attachmentName;
|
||||||
spAttachmentTimeline* self = (spAttachmentTimeline*)timeline;
|
spAttachmentTimeline* self = (spAttachmentTimeline*)timeline;
|
||||||
int frameIndex;
|
int frameIndex;
|
||||||
|
spSlot* slot = skeleton->slots[self->slotIndex];
|
||||||
|
|
||||||
if (mixingOut && setupPose) {
|
if (mixingOut && setupPose) {
|
||||||
spSlot* slot = skeleton->slots[self->slotIndex];
|
|
||||||
const char* attachmentName = slot->data->attachmentName;
|
const char* attachmentName = slot->data->attachmentName;
|
||||||
spSlot_setAttachment(slot, attachmentName ? 0 : spSkeleton_getAttachmentForSlotIndex(skeleton, self->slotIndex, attachmentName));
|
spSlot_setAttachment(slot, attachmentName ? 0 : spSkeleton_getAttachmentForSlotIndex(skeleton, self->slotIndex, attachmentName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (time < self->frames[0]) return;
|
if (time < self->frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
attachmentName = slot->data->attachmentName;
|
||||||
|
spSlot_setAttachment(skeleton->slots[self->slotIndex],
|
||||||
|
attachmentName ? spSkeleton_getAttachmentForSlotIndex(skeleton, self->slotIndex, attachmentName) : 0);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (time >= self->frames[self->framesCount - 1])
|
if (time >= self->frames[self->framesCount - 1])
|
||||||
frameIndex = self->framesCount - 1;
|
frameIndex = self->framesCount - 1;
|
||||||
@ -646,152 +679,8 @@ void spAttachmentTimeline_setFrame (spAttachmentTimeline* self, int frameIndex,
|
|||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
/** Fires events for frames > lastTime and <= time. */
|
|
||||||
void _spEventTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
|
||||||
int* eventsCount, float alpha, int setupPose, int mixingOut) {
|
|
||||||
spEventTimeline* self = (spEventTimeline*)timeline;
|
|
||||||
int frame;
|
|
||||||
if (!firedEvents) return;
|
|
||||||
|
|
||||||
if (lastTime > time) { /* Fire events after last time for looped animations. */
|
|
||||||
_spEventTimeline_apply(timeline, skeleton, lastTime, (float)INT_MAX, firedEvents, eventsCount, alpha, setupPose, mixingOut);
|
|
||||||
lastTime = -1;
|
|
||||||
} else if (lastTime >= self->frames[self->framesCount - 1]) /* Last time is after last frame. */
|
|
||||||
return;
|
|
||||||
if (time < self->frames[0]) return; /* Time is before first frame. */
|
|
||||||
|
|
||||||
if (lastTime < self->frames[0])
|
|
||||||
frame = 0;
|
|
||||||
else {
|
|
||||||
float frameTime;
|
|
||||||
frame = binarySearch1(self->frames, self->framesCount, lastTime);
|
|
||||||
frameTime = self->frames[frame];
|
|
||||||
while (frame > 0) { /* Fire multiple events with the same frame. */
|
|
||||||
if (self->frames[frame - 1] != frameTime) break;
|
|
||||||
frame--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (; frame < self->framesCount && time >= self->frames[frame]; ++frame) {
|
|
||||||
firedEvents[*eventsCount] = self->events[frame];
|
|
||||||
(*eventsCount)++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int _spEventTimeline_getPropertyId (const spTimeline* timeline) {
|
|
||||||
return SP_TIMELINE_EVENT << 24;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _spEventTimeline_dispose (spTimeline* timeline) {
|
|
||||||
spEventTimeline* self = SUB_CAST(spEventTimeline, timeline);
|
|
||||||
int i;
|
|
||||||
|
|
||||||
_spTimeline_deinit(timeline);
|
|
||||||
|
|
||||||
for (i = 0; i < self->framesCount; ++i)
|
|
||||||
spEvent_dispose(self->events[i]);
|
|
||||||
FREE(self->events);
|
|
||||||
FREE(self->frames);
|
|
||||||
FREE(self);
|
|
||||||
}
|
|
||||||
|
|
||||||
spEventTimeline* spEventTimeline_create (int framesCount) {
|
|
||||||
spEventTimeline* self = NEW(spEventTimeline);
|
|
||||||
_spTimeline_init(SUPER(self), SP_TIMELINE_EVENT, _spEventTimeline_dispose, _spEventTimeline_apply, _spEventTimeline_getPropertyId);
|
|
||||||
|
|
||||||
CONST_CAST(int, self->framesCount) = framesCount;
|
|
||||||
CONST_CAST(float*, self->frames) = CALLOC(float, framesCount);
|
|
||||||
CONST_CAST(spEvent**, self->events) = CALLOC(spEvent*, framesCount);
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
void spEventTimeline_setFrame (spEventTimeline* self, int frameIndex, spEvent* event) {
|
|
||||||
self->frames[frameIndex] = event->time;
|
|
||||||
|
|
||||||
FREE(self->events[frameIndex]);
|
|
||||||
self->events[frameIndex] = event;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**/
|
|
||||||
|
|
||||||
void _spDrawOrderTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time,
|
|
||||||
spEvent** firedEvents, int* eventsCount, float alpha, int setupPose, int mixingOut) {
|
|
||||||
int i;
|
|
||||||
int frame;
|
|
||||||
const int* drawOrderToSetupIndex;
|
|
||||||
spDrawOrderTimeline* self = (spDrawOrderTimeline*)timeline;
|
|
||||||
|
|
||||||
if (mixingOut && setupPose) {
|
|
||||||
memcpy(skeleton->drawOrder, skeleton->slots, self->slotsCount * sizeof(spSlot*));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (time < self->frames[0]) return; /* Time is before first frame. */
|
|
||||||
|
|
||||||
if (time >= self->frames[self->framesCount - 1]) /* Time is after last frame. */
|
|
||||||
frame = self->framesCount - 1;
|
|
||||||
else
|
|
||||||
frame = binarySearch1(self->frames, self->framesCount, time) - 1;
|
|
||||||
|
|
||||||
drawOrderToSetupIndex = self->drawOrders[frame];
|
|
||||||
if (!drawOrderToSetupIndex)
|
|
||||||
memcpy(skeleton->drawOrder, skeleton->slots, self->slotsCount * sizeof(spSlot*));
|
|
||||||
else {
|
|
||||||
for (i = 0; i < self->slotsCount; ++i)
|
|
||||||
skeleton->drawOrder[i] = skeleton->slots[drawOrderToSetupIndex[i]];
|
|
||||||
}
|
|
||||||
|
|
||||||
UNUSED(lastTime);
|
|
||||||
UNUSED(firedEvents);
|
|
||||||
UNUSED(eventsCount);
|
|
||||||
UNUSED(alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
int _spDrawOrderTimeline_getPropertyId (const spTimeline* timeline) {
|
|
||||||
return SP_TIMELINE_DRAWORDER << 24;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _spDrawOrderTimeline_dispose (spTimeline* timeline) {
|
|
||||||
spDrawOrderTimeline* self = SUB_CAST(spDrawOrderTimeline, timeline);
|
|
||||||
int i;
|
|
||||||
|
|
||||||
_spTimeline_deinit(timeline);
|
|
||||||
|
|
||||||
for (i = 0; i < self->framesCount; ++i)
|
|
||||||
FREE(self->drawOrders[i]);
|
|
||||||
FREE(self->drawOrders);
|
|
||||||
FREE(self->frames);
|
|
||||||
FREE(self);
|
|
||||||
}
|
|
||||||
|
|
||||||
spDrawOrderTimeline* spDrawOrderTimeline_create (int framesCount, int slotsCount) {
|
|
||||||
spDrawOrderTimeline* self = NEW(spDrawOrderTimeline);
|
|
||||||
_spTimeline_init(SUPER(self), SP_TIMELINE_DRAWORDER, _spDrawOrderTimeline_dispose, _spDrawOrderTimeline_apply, _spDrawOrderTimeline_getPropertyId);
|
|
||||||
|
|
||||||
CONST_CAST(int, self->framesCount) = framesCount;
|
|
||||||
CONST_CAST(float*, self->frames) = CALLOC(float, framesCount);
|
|
||||||
CONST_CAST(int**, self->drawOrders) = CALLOC(int*, framesCount);
|
|
||||||
CONST_CAST(int, self->slotsCount) = slotsCount;
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
void spDrawOrderTimeline_setFrame (spDrawOrderTimeline* self, int frameIndex, float time, const int* drawOrder) {
|
|
||||||
self->frames[frameIndex] = time;
|
|
||||||
|
|
||||||
FREE(self->drawOrders[frameIndex]);
|
|
||||||
if (!drawOrder)
|
|
||||||
self->drawOrders[frameIndex] = 0;
|
|
||||||
else {
|
|
||||||
self->drawOrders[frameIndex] = MALLOC(int, self->slotsCount);
|
|
||||||
memcpy(CONST_CAST(int*, self->drawOrders[frameIndex]), drawOrder, self->slotsCount * sizeof(int));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**/
|
|
||||||
|
|
||||||
void _spDeformTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
void _spDeformTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
int* eventsCount, float alpha, int setupPose, int mixingOut) {
|
int* eventsCount, float alpha, int setupPose, int mixingOut) {
|
||||||
int frame, i, vertexCount;
|
int frame, i, vertexCount;
|
||||||
float percent, frameTime;
|
float percent, frameTime;
|
||||||
const float* prevVertices;
|
const float* prevVertices;
|
||||||
@ -947,6 +836,153 @@ void spDeformTimeline_setFrame (spDeformTimeline* self, int frameIndex, float ti
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**/
|
||||||
|
|
||||||
|
/** Fires events for frames > lastTime and <= time. */
|
||||||
|
void _spEventTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
|
int* eventsCount, float alpha, int setupPose, int mixingOut) {
|
||||||
|
spEventTimeline* self = (spEventTimeline*)timeline;
|
||||||
|
int frame;
|
||||||
|
if (!firedEvents) return;
|
||||||
|
|
||||||
|
if (lastTime > time) { /* Fire events after last time for looped animations. */
|
||||||
|
_spEventTimeline_apply(timeline, skeleton, lastTime, (float)INT_MAX, firedEvents, eventsCount, alpha, setupPose, mixingOut);
|
||||||
|
lastTime = -1;
|
||||||
|
} else if (lastTime >= self->frames[self->framesCount - 1]) /* Last time is after last frame. */
|
||||||
|
return;
|
||||||
|
if (time < self->frames[0]) return; /* Time is before first frame. */
|
||||||
|
|
||||||
|
if (lastTime < self->frames[0])
|
||||||
|
frame = 0;
|
||||||
|
else {
|
||||||
|
float frameTime;
|
||||||
|
frame = binarySearch1(self->frames, self->framesCount, lastTime);
|
||||||
|
frameTime = self->frames[frame];
|
||||||
|
while (frame > 0) { /* Fire multiple events with the same frame. */
|
||||||
|
if (self->frames[frame - 1] != frameTime) break;
|
||||||
|
frame--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (; frame < self->framesCount && time >= self->frames[frame]; ++frame) {
|
||||||
|
firedEvents[*eventsCount] = self->events[frame];
|
||||||
|
(*eventsCount)++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int _spEventTimeline_getPropertyId (const spTimeline* timeline) {
|
||||||
|
return SP_TIMELINE_EVENT << 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _spEventTimeline_dispose (spTimeline* timeline) {
|
||||||
|
spEventTimeline* self = SUB_CAST(spEventTimeline, timeline);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
_spTimeline_deinit(timeline);
|
||||||
|
|
||||||
|
for (i = 0; i < self->framesCount; ++i)
|
||||||
|
spEvent_dispose(self->events[i]);
|
||||||
|
FREE(self->events);
|
||||||
|
FREE(self->frames);
|
||||||
|
FREE(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
spEventTimeline* spEventTimeline_create (int framesCount) {
|
||||||
|
spEventTimeline* self = NEW(spEventTimeline);
|
||||||
|
_spTimeline_init(SUPER(self), SP_TIMELINE_EVENT, _spEventTimeline_dispose, _spEventTimeline_apply, _spEventTimeline_getPropertyId);
|
||||||
|
|
||||||
|
CONST_CAST(int, self->framesCount) = framesCount;
|
||||||
|
CONST_CAST(float*, self->frames) = CALLOC(float, framesCount);
|
||||||
|
CONST_CAST(spEvent**, self->events) = CALLOC(spEvent*, framesCount);
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
void spEventTimeline_setFrame (spEventTimeline* self, int frameIndex, spEvent* event) {
|
||||||
|
self->frames[frameIndex] = event->time;
|
||||||
|
|
||||||
|
FREE(self->events[frameIndex]);
|
||||||
|
self->events[frameIndex] = event;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
|
||||||
|
void _spDrawOrderTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time,
|
||||||
|
spEvent** firedEvents, int* eventsCount, float alpha, int setupPose, int mixingOut) {
|
||||||
|
int i;
|
||||||
|
int frame;
|
||||||
|
const int* drawOrderToSetupIndex;
|
||||||
|
spDrawOrderTimeline* self = (spDrawOrderTimeline*)timeline;
|
||||||
|
|
||||||
|
if (mixingOut && setupPose) {
|
||||||
|
memcpy(skeleton->drawOrder, skeleton->slots, self->slotsCount * sizeof(spSlot*));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (time < self->frames[0]) {
|
||||||
|
if (setupPose) memcpy(skeleton->drawOrder, skeleton->slots, self->slotsCount * sizeof(spSlot*));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (time >= self->frames[self->framesCount - 1]) /* Time is after last frame. */
|
||||||
|
frame = self->framesCount - 1;
|
||||||
|
else
|
||||||
|
frame = binarySearch1(self->frames, self->framesCount, time) - 1;
|
||||||
|
|
||||||
|
drawOrderToSetupIndex = self->drawOrders[frame];
|
||||||
|
if (!drawOrderToSetupIndex)
|
||||||
|
memcpy(skeleton->drawOrder, skeleton->slots, self->slotsCount * sizeof(spSlot*));
|
||||||
|
else {
|
||||||
|
for (i = 0; i < self->slotsCount; ++i)
|
||||||
|
skeleton->drawOrder[i] = skeleton->slots[drawOrderToSetupIndex[i]];
|
||||||
|
}
|
||||||
|
|
||||||
|
UNUSED(lastTime);
|
||||||
|
UNUSED(firedEvents);
|
||||||
|
UNUSED(eventsCount);
|
||||||
|
UNUSED(alpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
int _spDrawOrderTimeline_getPropertyId (const spTimeline* timeline) {
|
||||||
|
return SP_TIMELINE_DRAWORDER << 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _spDrawOrderTimeline_dispose (spTimeline* timeline) {
|
||||||
|
spDrawOrderTimeline* self = SUB_CAST(spDrawOrderTimeline, timeline);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
_spTimeline_deinit(timeline);
|
||||||
|
|
||||||
|
for (i = 0; i < self->framesCount; ++i)
|
||||||
|
FREE(self->drawOrders[i]);
|
||||||
|
FREE(self->drawOrders);
|
||||||
|
FREE(self->frames);
|
||||||
|
FREE(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
spDrawOrderTimeline* spDrawOrderTimeline_create (int framesCount, int slotsCount) {
|
||||||
|
spDrawOrderTimeline* self = NEW(spDrawOrderTimeline);
|
||||||
|
_spTimeline_init(SUPER(self), SP_TIMELINE_DRAWORDER, _spDrawOrderTimeline_dispose, _spDrawOrderTimeline_apply, _spDrawOrderTimeline_getPropertyId);
|
||||||
|
|
||||||
|
CONST_CAST(int, self->framesCount) = framesCount;
|
||||||
|
CONST_CAST(float*, self->frames) = CALLOC(float, framesCount);
|
||||||
|
CONST_CAST(int**, self->drawOrders) = CALLOC(int*, framesCount);
|
||||||
|
CONST_CAST(int, self->slotsCount) = slotsCount;
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
void spDrawOrderTimeline_setFrame (spDrawOrderTimeline* self, int frameIndex, float time, const int* drawOrder) {
|
||||||
|
self->frames[frameIndex] = time;
|
||||||
|
|
||||||
|
FREE(self->drawOrders[frameIndex]);
|
||||||
|
if (!drawOrder)
|
||||||
|
self->drawOrders[frameIndex] = 0;
|
||||||
|
else {
|
||||||
|
self->drawOrders[frameIndex] = MALLOC(int, self->slotsCount);
|
||||||
|
memcpy(CONST_CAST(int*, self->drawOrders[frameIndex]), drawOrder, self->slotsCount * sizeof(int));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
static const int IKCONSTRAINT_PREV_TIME = -3, IKCONSTRAINT_PREV_MIX = -2, IKCONSTRAINT_PREV_BEND_DIRECTION = -1;
|
static const int IKCONSTRAINT_PREV_TIME = -3, IKCONSTRAINT_PREV_MIX = -2, IKCONSTRAINT_PREV_BEND_DIRECTION = -1;
|
||||||
@ -961,10 +997,16 @@ void _spIkConstraintTimeline_apply (const spTimeline* timeline, spSkeleton* skel
|
|||||||
spIkConstraint* constraint;
|
spIkConstraint* constraint;
|
||||||
spIkConstraintTimeline* self = (spIkConstraintTimeline*)timeline;
|
spIkConstraintTimeline* self = (spIkConstraintTimeline*)timeline;
|
||||||
|
|
||||||
if (time < self->frames[0]) return; /* Time is before first frame. */
|
|
||||||
|
|
||||||
constraint = skeleton->ikConstraints[self->ikConstraintIndex];
|
constraint = skeleton->ikConstraints[self->ikConstraintIndex];
|
||||||
|
|
||||||
|
if (time < self->frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint->mix = constraint->data->mix;
|
||||||
|
constraint->bendDirection = constraint->data->bendDirection;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
frames = self->frames;
|
frames = self->frames;
|
||||||
framesCount = self->framesCount;
|
framesCount = self->framesCount;
|
||||||
if (time >= frames[framesCount - IKCONSTRAINT_ENTRIES]) { /* Time is after last frame. */
|
if (time >= frames[framesCount - IKCONSTRAINT_ENTRIES]) { /* Time is after last frame. */
|
||||||
@ -1033,9 +1075,17 @@ void _spTransformConstraintTimeline_apply (const spTimeline* timeline, spSkeleto
|
|||||||
float *frames;
|
float *frames;
|
||||||
int framesCount;
|
int framesCount;
|
||||||
|
|
||||||
if (time < self->frames[0]) return; /* Time is before first frame. */
|
|
||||||
|
|
||||||
constraint = skeleton->transformConstraints[self->transformConstraintIndex];
|
constraint = skeleton->transformConstraints[self->transformConstraintIndex];
|
||||||
|
if (time < self->frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
spTransformConstraintData* data = constraint->data;
|
||||||
|
constraint->rotateMix = data->rotateMix;
|
||||||
|
constraint->translateMix = data->translateMix;
|
||||||
|
constraint->scaleMix = data->scaleMix;
|
||||||
|
constraint->shearMix = data->shearMix;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
frames = self->frames;
|
frames = self->frames;
|
||||||
framesCount = self->framesCount;
|
framesCount = self->framesCount;
|
||||||
@ -1111,9 +1161,13 @@ void _spPathConstraintPositionTimeline_apply(const spTimeline* timeline, spSkele
|
|||||||
float* frames;
|
float* frames;
|
||||||
int framesCount;
|
int framesCount;
|
||||||
|
|
||||||
if (time < self->frames[0]) return; /* Time is before first frame. */
|
|
||||||
|
|
||||||
constraint = skeleton->pathConstraints[self->pathConstraintIndex];
|
constraint = skeleton->pathConstraints[self->pathConstraintIndex];
|
||||||
|
if (time < self->frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint->position = constraint->data->position;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
frames = self->frames;
|
frames = self->frames;
|
||||||
framesCount = self->framesCount;
|
framesCount = self->framesCount;
|
||||||
@ -1167,9 +1221,13 @@ void _spPathConstraintSpacingTimeline_apply(const spTimeline* timeline, spSkelet
|
|||||||
float* frames;
|
float* frames;
|
||||||
int framesCount;
|
int framesCount;
|
||||||
|
|
||||||
if (time < self->frames[0]) return; /* Time is before first frame. */
|
|
||||||
|
|
||||||
constraint = skeleton->pathConstraints[self->pathConstraintIndex];
|
constraint = skeleton->pathConstraints[self->pathConstraintIndex];
|
||||||
|
if (time < self->frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint->spacing = constraint->data->spacing;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
frames = self->frames;
|
frames = self->frames;
|
||||||
framesCount = self->framesCount;
|
framesCount = self->framesCount;
|
||||||
@ -1227,9 +1285,14 @@ void _spPathConstraintMixTimeline_apply(const spTimeline* timeline, spSkeleton*
|
|||||||
float* frames;
|
float* frames;
|
||||||
int framesCount;
|
int framesCount;
|
||||||
|
|
||||||
if (time < self->frames[0]) return; /* Time is before first frame. */
|
|
||||||
|
|
||||||
constraint = skeleton->pathConstraints[self->pathConstraintIndex];
|
constraint = skeleton->pathConstraints[self->pathConstraintIndex];
|
||||||
|
if (time < self->frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint->rotateMix = constraint->data->rotateMix;
|
||||||
|
constraint->translateMix = constraint->data->translateMix;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
frames = self->frames;
|
frames = self->frames;
|
||||||
framesCount = self->framesCount;
|
framesCount = self->framesCount;
|
||||||
|
|||||||
@ -32,291 +32,104 @@
|
|||||||
#include <spine/extension.h>
|
#include <spine/extension.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
spTrackEntry* _spTrackEntry_create (spAnimationState* state) {
|
_spEventQueue* _spEventQueue_create (spAnimationState* state) {
|
||||||
spTrackEntry* self = NEW(spTrackEntry);
|
_spEventQueue *self = MALLOC(_spEventQueue, 1);
|
||||||
CONST_CAST(spAnimationState*, self->state) = state;
|
self->state = state;
|
||||||
self->timeScale = 1;
|
self->objectsCount = 0;
|
||||||
self->lastTime = -1;
|
self->objectsCapacity = 16;
|
||||||
self->mix = 1;
|
self->objects = MALLOC(_spEventQueueItem, self->objectsCapacity * sizeof(_spEventQueueItem));
|
||||||
|
self->drainDisabled = 0;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _spTrackEntry_dispose (spTrackEntry* self) {
|
void _spEventQueue_free (_spEventQueue* self) {
|
||||||
if (self->previous) SUB_CAST(_spAnimationState, self->state)->disposeTrackEntry(self->previous);
|
if (!self) return;
|
||||||
FREE(self);
|
if (self->objects) FREE(self->objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
void _spEventQueue_ensureCapacity (_spEventQueue* self, int newElements) {
|
||||||
|
if (self->objectsCount + newElements > self->objectsCapacity) {
|
||||||
spTrackEntry* _spAnimationState_createTrackEntry (spAnimationState* self) {
|
_spEventQueueItem* newObjects;
|
||||||
return _spTrackEntry_create(self);
|
self->objectsCapacity <<= 1;
|
||||||
}
|
newObjects = MALLOC(_spEventQueueItem, self->objectsCapacity);
|
||||||
|
memcpy(newObjects, self->objects, self->objectsCount * sizeof(_spEventQueueItem));
|
||||||
void _spAnimationState_disposeTrackEntry (spTrackEntry* entry) {
|
FREE(self->objects);
|
||||||
_spTrackEntry_dispose(entry);
|
self->objects = newObjects;
|
||||||
}
|
|
||||||
|
|
||||||
spAnimationState* spAnimationState_create (spAnimationStateData* data) {
|
|
||||||
_spAnimationState* internal = NEW(_spAnimationState);
|
|
||||||
spAnimationState* self = SUPER(internal);
|
|
||||||
internal->events = MALLOC(spEvent*, 64);
|
|
||||||
self->timeScale = 1;
|
|
||||||
CONST_CAST(spAnimationStateData*, self->data) = data;
|
|
||||||
internal->createTrackEntry = _spAnimationState_createTrackEntry;
|
|
||||||
internal->disposeTrackEntry = _spAnimationState_disposeTrackEntry;
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _spAnimationState_disposeAllEntries (spAnimationState* self, spTrackEntry* entry) {
|
|
||||||
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
|
|
||||||
while (entry) {
|
|
||||||
spTrackEntry* next = entry->next;
|
|
||||||
internal->disposeTrackEntry(entry);
|
|
||||||
entry = next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void spAnimationState_dispose (spAnimationState* self) {
|
void _spEventQueue_addType (_spEventQueue* self, spEventType type) {
|
||||||
int i;
|
_spEventQueue_ensureCapacity(self, 1);
|
||||||
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
|
self->objects[self->objectsCount++].type = type;
|
||||||
FREE(internal->events);
|
|
||||||
for (i = 0; i < self->tracksCount; ++i)
|
|
||||||
_spAnimationState_disposeAllEntries(self, self->tracks[i]);
|
|
||||||
FREE(self->tracks);
|
|
||||||
FREE(self);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _spAnimationState_setCurrent (spAnimationState* self, int index, spTrackEntry* entry);
|
void _spEventQueue_addEntry (_spEventQueue* self, spTrackEntry* entry) {
|
||||||
|
_spEventQueue_ensureCapacity(self, 1);
|
||||||
|
self->objects[self->objectsCount++].entry = entry;
|
||||||
|
}
|
||||||
|
|
||||||
void spAnimationState_update (spAnimationState* self, float delta) {
|
void _spEventQueue_addEvent (_spEventQueue* self, spEvent* event) {
|
||||||
|
_spEventQueue_ensureCapacity(self, 1);
|
||||||
|
self->objects[self->objectsCount++].event = event;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _spEventQueue_start (_spEventQueue* self, spTrackEntry* entry) {
|
||||||
|
_spAnimationState* internalState = (_spAnimationState*)self->state;
|
||||||
|
_spEventQueue_addType(self, SP_ANIMATION_START);
|
||||||
|
_spEventQueue_addEntry(self, entry);
|
||||||
|
internalState->animationsChanged = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _spEventQueue_interrupt (_spEventQueue* self, spTrackEntry* entry) {
|
||||||
|
_spEventQueue_addType(self, SP_ANIMATION_INTERRUPT);
|
||||||
|
_spEventQueue_addEntry(self, entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _spEventQueue_end (_spEventQueue* self, spTrackEntry* entry) {
|
||||||
|
_spAnimationState* internalState = (_spAnimationState*)self->state;
|
||||||
|
_spEventQueue_addType(self, SP_ANIMATION_END);
|
||||||
|
_spEventQueue_addEntry(self, entry);
|
||||||
|
internalState->animationsChanged = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _spEventQueue_dispose (_spEventQueue* self, spTrackEntry* entry) {
|
||||||
|
_spEventQueue_addType(self, SP_ANIMATION_DISPOSE);
|
||||||
|
_spEventQueue_addEntry(self, entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _spEventQueue_complete (_spEventQueue* self, spTrackEntry* entry) {
|
||||||
|
_spEventQueue_addType(self, SP_ANIMATION_COMPLETE);
|
||||||
|
_spEventQueue_addEntry(self, entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _spEventQueue_event (_spEventQueue* self, spTrackEntry* entry, spEvent* event) {
|
||||||
|
_spEventQueue_addType(self, SP_ANIMATION_EVENT);
|
||||||
|
_spEventQueue_addEntry(self, entry);
|
||||||
|
_spEventQueue_addEvent(self, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _spEventQueue_clear (_spEventQueue* self) {
|
||||||
|
self->objectsCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _spEventQueue_drain (_spEventQueue* self) {
|
||||||
int i;
|
int i;
|
||||||
float previousDelta;
|
if (self->drainDisabled) return;
|
||||||
delta *= self->timeScale;
|
self->drainDisabled = 1;
|
||||||
for (i = 0; i < self->tracksCount; ++i) {
|
for (i = 0; i < self->objectsCount; i += 2) {
|
||||||
spTrackEntry* current = self->tracks[i];
|
spEventType type = self->objects[i].type;
|
||||||
if (!current) continue;
|
spTrackEntry* entry = self->objects[i+1].entry;
|
||||||
|
if (type != SP_ANIMATION_EVENT) {
|
||||||
current->time += delta * current->timeScale;
|
if (entry->listener) entry->listener(self->state, type, entry, 0);
|
||||||
if (current->previous) {
|
if (self->state->listener) self->state->listener(self->state, type, entry, 0);
|
||||||
previousDelta = delta * current->previous->timeScale;
|
|
||||||
current->previous->time += previousDelta;
|
|
||||||
current->mixTime += previousDelta;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (current->next) {
|
|
||||||
current->next->time = current->lastTime - current->next->delay;
|
|
||||||
if (current->next->time >= 0) _spAnimationState_setCurrent(self, i, current->next);
|
|
||||||
} else {
|
} else {
|
||||||
/* End non-looping animation when it reaches its end time and there is no next entry. */
|
spEvent* event = self->objects[i+2].event;
|
||||||
if (!current->loop && current->lastTime >= current->endTime) spAnimationState_clearTrack(self, i);
|
if (entry->listener) entry->listener(self->state, type, entry, event);
|
||||||
|
if (self->state->listener) self->state->listener(self->state, type, entry, event);
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
_spEventQueue_clear(self);
|
||||||
void spAnimationState_apply (spAnimationState* self, spSkeleton* skeleton) {
|
self->drainDisabled = 0;
|
||||||
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
|
|
||||||
|
|
||||||
int i, ii;
|
|
||||||
int eventsCount;
|
|
||||||
int entryChanged;
|
|
||||||
float time;
|
|
||||||
spTrackEntry* previous;
|
|
||||||
for (i = 0; i < self->tracksCount; ++i) {
|
|
||||||
spTrackEntry* current = self->tracks[i];
|
|
||||||
if (!current) continue;
|
|
||||||
|
|
||||||
eventsCount = 0;
|
|
||||||
|
|
||||||
time = current->time;
|
|
||||||
if (!current->loop && time > current->endTime) time = current->endTime;
|
|
||||||
|
|
||||||
previous = current->previous;
|
|
||||||
if (!previous) {
|
|
||||||
if (current->mix == 1) {
|
|
||||||
spAnimation_apply(current->animation, skeleton, current->lastTime, time,
|
|
||||||
current->loop, internal->events, &eventsCount);
|
|
||||||
} else {
|
|
||||||
spAnimation_mix(current->animation, skeleton, current->lastTime, time,
|
|
||||||
current->loop, internal->events, &eventsCount, current->mix);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
float alpha = current->mixTime / current->mixDuration * current->mix;
|
|
||||||
|
|
||||||
float previousTime = previous->time;
|
|
||||||
if (!previous->loop && previousTime > previous->endTime) previousTime = previous->endTime;
|
|
||||||
spAnimation_apply(previous->animation, skeleton, previousTime, previousTime, previous->loop, 0, 0);
|
|
||||||
|
|
||||||
if (alpha >= 1) {
|
|
||||||
alpha = 1;
|
|
||||||
internal->disposeTrackEntry(current->previous);
|
|
||||||
current->previous = 0;
|
|
||||||
}
|
|
||||||
spAnimation_mix(current->animation, skeleton, current->lastTime, time,
|
|
||||||
current->loop, internal->events, &eventsCount, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
entryChanged = 0;
|
|
||||||
for (ii = 0; ii < eventsCount; ++ii) {
|
|
||||||
spEvent* event = internal->events[ii];
|
|
||||||
if (current->listener) {
|
|
||||||
current->listener(self, i, SP_ANIMATION_EVENT, event, 0);
|
|
||||||
if (self->tracks[i] != current) {
|
|
||||||
entryChanged = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (self->listener) {
|
|
||||||
self->listener(self, i, SP_ANIMATION_EVENT, event, 0);
|
|
||||||
if (self->tracks[i] != current) {
|
|
||||||
entryChanged = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (entryChanged) continue;
|
|
||||||
|
|
||||||
/* Check if completed the animation or a loop iteration. */
|
|
||||||
if (current->loop ? (FMOD(current->lastTime, current->endTime) > FMOD(time, current->endTime))
|
|
||||||
: (current->lastTime < current->endTime && time >= current->endTime)) {
|
|
||||||
int count = (int)(time / current->endTime);
|
|
||||||
if (current->listener) {
|
|
||||||
current->listener(self, i, SP_ANIMATION_COMPLETE, 0, count);
|
|
||||||
if (self->tracks[i] != current) continue;
|
|
||||||
}
|
|
||||||
if (self->listener) {
|
|
||||||
self->listener(self, i, SP_ANIMATION_COMPLETE, 0, count);
|
|
||||||
if (self->tracks[i] != current) continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
current->lastTime = current->time;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void spAnimationState_clearTracks (spAnimationState* self) {
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < self->tracksCount; ++i)
|
|
||||||
spAnimationState_clearTrack(self, i);
|
|
||||||
self->tracksCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void spAnimationState_clearTrack (spAnimationState* self, int trackIndex) {
|
|
||||||
spTrackEntry* current;
|
|
||||||
if (trackIndex >= self->tracksCount) return;
|
|
||||||
current = self->tracks[trackIndex];
|
|
||||||
if (!current) return;
|
|
||||||
|
|
||||||
if (current->listener) current->listener(self, trackIndex, SP_ANIMATION_END, 0, 0);
|
|
||||||
if (self->listener) self->listener(self, trackIndex, SP_ANIMATION_END, 0, 0);
|
|
||||||
|
|
||||||
self->tracks[trackIndex] = 0;
|
|
||||||
|
|
||||||
_spAnimationState_disposeAllEntries(self, current);
|
|
||||||
}
|
|
||||||
|
|
||||||
spTrackEntry* _spAnimationState_expandToIndex (spAnimationState* self, int index) {
|
|
||||||
spTrackEntry** newTracks;
|
|
||||||
if (index < self->tracksCount) return self->tracks[index];
|
|
||||||
newTracks = CALLOC(spTrackEntry*, index + 1);
|
|
||||||
memcpy(newTracks, self->tracks, self->tracksCount * sizeof(spTrackEntry*));
|
|
||||||
FREE(self->tracks);
|
|
||||||
self->tracks = newTracks;
|
|
||||||
self->tracksCount = index + 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _spAnimationState_setCurrent (spAnimationState* self, int index, spTrackEntry* entry) {
|
|
||||||
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
|
|
||||||
|
|
||||||
spTrackEntry* current = _spAnimationState_expandToIndex(self, index);
|
|
||||||
if (current) {
|
|
||||||
spTrackEntry* previous = current->previous;
|
|
||||||
current->previous = 0;
|
|
||||||
|
|
||||||
if (current->listener) current->listener(self, index, SP_ANIMATION_END, 0, 0);
|
|
||||||
if (self->listener) self->listener(self, index, SP_ANIMATION_END, 0, 0);
|
|
||||||
|
|
||||||
entry->mixDuration = spAnimationStateData_getMix(self->data, current->animation, entry->animation);
|
|
||||||
if (entry->mixDuration > 0) {
|
|
||||||
entry->mixTime = 0;
|
|
||||||
/* If a mix is in progress, mix from the closest animation. */
|
|
||||||
if (previous && current->mixTime / current->mixDuration < 0.5f) {
|
|
||||||
entry->previous = previous;
|
|
||||||
previous = current;
|
|
||||||
} else
|
|
||||||
entry->previous = current;
|
|
||||||
} else
|
|
||||||
internal->disposeTrackEntry(current);
|
|
||||||
|
|
||||||
if (previous) internal->disposeTrackEntry(previous);
|
|
||||||
}
|
|
||||||
|
|
||||||
self->tracks[index] = entry;
|
|
||||||
|
|
||||||
if (entry->listener) {
|
|
||||||
entry->listener(self, index, SP_ANIMATION_START, 0, 0);
|
|
||||||
if (self->tracks[index] != entry) return;
|
|
||||||
}
|
|
||||||
if (self->listener) self->listener(self, index, SP_ANIMATION_START, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
spTrackEntry* spAnimationState_setAnimationByName (spAnimationState* self, int trackIndex, const char* animationName,
|
|
||||||
int/*bool*/loop) {
|
|
||||||
spAnimation* animation = spSkeletonData_findAnimation(self->data->skeletonData, animationName);
|
|
||||||
return spAnimationState_setAnimation(self, trackIndex, animation, loop);
|
|
||||||
}
|
|
||||||
|
|
||||||
spTrackEntry* spAnimationState_setAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop) {
|
|
||||||
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
|
|
||||||
|
|
||||||
spTrackEntry* entry;
|
|
||||||
spTrackEntry* current = _spAnimationState_expandToIndex(self, trackIndex);
|
|
||||||
if (current) _spAnimationState_disposeAllEntries(self, current->next);
|
|
||||||
|
|
||||||
entry = internal->createTrackEntry(self);
|
|
||||||
entry->animation = animation;
|
|
||||||
entry->loop = loop;
|
|
||||||
entry->endTime = animation->duration;
|
|
||||||
_spAnimationState_setCurrent(self, trackIndex, entry);
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
spTrackEntry* spAnimationState_addAnimationByName (spAnimationState* self, int trackIndex, const char* animationName,
|
|
||||||
int/*bool*/loop, float delay) {
|
|
||||||
spAnimation* animation = spSkeletonData_findAnimation(self->data->skeletonData, animationName);
|
|
||||||
return spAnimationState_addAnimation(self, trackIndex, animation, loop, delay);
|
|
||||||
}
|
|
||||||
|
|
||||||
spTrackEntry* spAnimationState_addAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop,
|
|
||||||
float delay) {
|
|
||||||
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
|
|
||||||
spTrackEntry* last;
|
|
||||||
|
|
||||||
spTrackEntry* entry = internal->createTrackEntry(self);
|
|
||||||
entry->animation = animation;
|
|
||||||
entry->loop = loop;
|
|
||||||
entry->endTime = animation->duration;
|
|
||||||
|
|
||||||
last = _spAnimationState_expandToIndex(self, trackIndex);
|
|
||||||
if (last) {
|
|
||||||
while (last->next)
|
|
||||||
last = last->next;
|
|
||||||
last->next = entry;
|
|
||||||
} else
|
|
||||||
self->tracks[trackIndex] = entry;
|
|
||||||
|
|
||||||
if (delay <= 0) {
|
|
||||||
if (last)
|
|
||||||
delay += last->endTime - spAnimationStateData_getMix(self->data, last->animation, animation);
|
|
||||||
else
|
|
||||||
delay = 0;
|
|
||||||
}
|
|
||||||
entry->delay = delay;
|
|
||||||
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
spTrackEntry* spAnimationState_getCurrent (spAnimationState* self, int trackIndex) {
|
|
||||||
if (trackIndex >= self->tracksCount) return 0;
|
|
||||||
return self->tracks[trackIndex];
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -239,20 +239,21 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
||||||
float[] frames = this.frames;
|
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
Bone bone = skeleton.bones.Items[boneIndex];
|
Bone bone = skeleton.bones.Items[boneIndex];
|
||||||
|
|
||||||
float r;
|
float[] frames = this.frames;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) bone.rotation = bone.data.rotation;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (time >= frames[frames.Length - ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.Length - ENTRIES]) { // Time is after last frame.
|
||||||
if (setupPose) {
|
if (setupPose) {
|
||||||
bone.rotation = bone.data.rotation + frames[frames.Length + PREV_ROTATION] * alpha;
|
bone.rotation = bone.data.rotation + frames[frames.Length + PREV_ROTATION] * alpha;
|
||||||
} else {
|
} else {
|
||||||
r = bone.data.rotation + frames[frames.Length + PREV_ROTATION] - bone.rotation;
|
float rr = bone.data.rotation + frames[frames.Length + PREV_ROTATION] - bone.rotation;
|
||||||
r -= (16384 - (int)(16384.499999999996 - r / 360)) * 360; // Wrap within -180 and 180.
|
rr -= (16384 - (int)(16384.499999999996 - rr / 360)) * 360; // Wrap within -180 and 180.
|
||||||
bone.rotation += r * alpha;
|
bone.rotation += rr * alpha;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -263,7 +264,7 @@ namespace Spine {
|
|||||||
float frameTime = frames[frame];
|
float frameTime = frames[frame];
|
||||||
float percent = GetCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + PREV_TIME] - frameTime));
|
float percent = GetCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + PREV_TIME] - frameTime));
|
||||||
|
|
||||||
r = frames[frame + ROTATION] - prevRotation;
|
float r = frames[frame + ROTATION] - prevRotation;
|
||||||
r -= (16384 - (int)(16384.499999999996 - r / 360)) * 360;
|
r -= (16384 - (int)(16384.499999999996 - r / 360)) * 360;
|
||||||
r = prevRotation + r * percent;
|
r = prevRotation + r * percent;
|
||||||
if (setupPose) {
|
if (setupPose) {
|
||||||
@ -306,11 +307,17 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
||||||
float[] frames = this.frames;
|
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
Bone bone = skeleton.bones.Items[boneIndex];
|
Bone bone = skeleton.bones.Items[boneIndex];
|
||||||
|
|
||||||
|
float[] frames = this.frames;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.x = bone.data.x;
|
||||||
|
bone.y = bone.data.y;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
float x, y;
|
float x, y;
|
||||||
if (time >= frames[frames.Length - ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.Length - ENTRIES]) { // Time is after last frame.
|
||||||
x = frames[frames.Length + PREV_X];
|
x = frames[frames.Length + PREV_X];
|
||||||
@ -347,11 +354,17 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
||||||
float[] frames = this.frames;
|
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
Bone bone = skeleton.bones.Items[boneIndex];
|
Bone bone = skeleton.bones.Items[boneIndex];
|
||||||
|
|
||||||
|
float[] frames = this.frames;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.scaleX = bone.data.scaleX;
|
||||||
|
bone.scaleY = bone.data.scaleY;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
float x, y;
|
float x, y;
|
||||||
if (time >= frames[frames.Length - ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.Length - ENTRIES]) { // Time is after last frame.
|
||||||
x = frames[frames.Length + PREV_X] * bone.data.scaleX;
|
x = frames[frames.Length + PREV_X] * bone.data.scaleX;
|
||||||
@ -404,10 +417,16 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
||||||
float[] frames = this.frames;
|
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
Bone bone = skeleton.bones.Items[boneIndex];
|
Bone bone = skeleton.bones.Items[boneIndex];
|
||||||
|
float[] frames = this.frames;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.shearX = bone.data.shearX;
|
||||||
|
bone.shearY = bone.data.shearY;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
float x, y;
|
float x, y;
|
||||||
if (time >= frames[frames.Length - ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.Length - ENTRIES]) { // Time is after last frame.
|
||||||
x = frames[frames.Length + PREV_X];
|
x = frames[frames.Length + PREV_X];
|
||||||
@ -465,8 +484,18 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
||||||
|
Slot slot = skeleton.slots.Items[slotIndex];
|
||||||
float[] frames = this.frames;
|
float[] frames = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
var slotData = slot.data;
|
||||||
|
slot.r = slotData.r;
|
||||||
|
slot.g = slotData.g;
|
||||||
|
slot.b = slotData.b;
|
||||||
|
slot.a = slotData.a;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
float r, g, b, a;
|
float r, g, b, a;
|
||||||
if (time >= frames[frames.Length - ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.Length - ENTRIES]) { // Time is after last frame.
|
||||||
@ -491,7 +520,6 @@ namespace Spine {
|
|||||||
b += (frames[frame + B] - b) * percent;
|
b += (frames[frame + B] - b) * percent;
|
||||||
a += (frames[frame + A] - a) * percent;
|
a += (frames[frame + A] - a) * percent;
|
||||||
}
|
}
|
||||||
Slot slot = skeleton.slots.Items[slotIndex];
|
|
||||||
if (alpha == 1) {
|
if (alpha == 1) {
|
||||||
slot.r = r;
|
slot.r = r;
|
||||||
slot.g = g;
|
slot.g = g;
|
||||||
@ -545,15 +573,21 @@ namespace Spine {
|
|||||||
|
|
||||||
public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
||||||
string attachmentName;
|
string attachmentName;
|
||||||
|
Slot slot = skeleton.slots.Items[slotIndex];
|
||||||
if (mixingOut && setupPose) {
|
if (mixingOut && setupPose) {
|
||||||
Slot slot = skeleton.slots.Items[slotIndex];
|
|
||||||
attachmentName = slot.data.attachmentName;
|
attachmentName = slot.data.attachmentName;
|
||||||
slot.Attachment = attachmentName == null ? null : skeleton.GetAttachment(slotIndex, attachmentName);
|
slot.Attachment = attachmentName == null ? null : skeleton.GetAttachment(slotIndex, attachmentName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float[] frames = this.frames;
|
float[] frames = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
attachmentName = slot.data.attachmentName;
|
||||||
|
slot.Attachment = attachmentName == null ? null : skeleton.GetAttachment(slotIndex, attachmentName);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int frameIndex;
|
int frameIndex;
|
||||||
if (time >= frames[frames.Length - 1]) // Time is after last frame.
|
if (time >= frames[frames.Length - 1]) // Time is after last frame.
|
||||||
@ -562,8 +596,7 @@ namespace Spine {
|
|||||||
frameIndex = Animation.BinarySearch(frames, time, 1) - 1;
|
frameIndex = Animation.BinarySearch(frames, time, 1) - 1;
|
||||||
|
|
||||||
attachmentName = attachmentNames[frameIndex];
|
attachmentName = attachmentNames[frameIndex];
|
||||||
skeleton.slots.Items[slotIndex]
|
slot.Attachment = attachmentName == null ? null : skeleton.GetAttachment(slotIndex, attachmentName);
|
||||||
.Attachment = attachmentName == null ? null : skeleton.GetAttachment(slotIndex, attachmentName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -599,13 +632,16 @@ namespace Spine {
|
|||||||
VertexAttachment slotAttachment = slot.attachment as VertexAttachment;
|
VertexAttachment slotAttachment = slot.attachment as VertexAttachment;
|
||||||
if (slotAttachment == null || !slotAttachment.ApplyDeform(attachment)) return;
|
if (slotAttachment == null || !slotAttachment.ApplyDeform(attachment)) return;
|
||||||
|
|
||||||
|
var verticesArray = slot.attachmentVertices;
|
||||||
float[] frames = this.frames;
|
float[] frames = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) verticesArray.Clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
float[][] frameVertices = this.frameVertices;
|
float[][] frameVertices = this.frameVertices;
|
||||||
int vertexCount = frameVertices[0].Length;
|
int vertexCount = frameVertices[0].Length;
|
||||||
|
|
||||||
var verticesArray = slot.attachmentVertices;
|
|
||||||
if (verticesArray.Count != vertexCount) alpha = 1; // Don't mix from uninitialized slot vertices.
|
if (verticesArray.Count != vertexCount) alpha = 1; // Don't mix from uninitialized slot vertices.
|
||||||
// verticesArray.SetSize(vertexCount) // Ensure size and preemptively set count.
|
// verticesArray.SetSize(vertexCount) // Ensure size and preemptively set count.
|
||||||
if (verticesArray.Capacity < vertexCount) verticesArray.Capacity = vertexCount;
|
if (verticesArray.Capacity < vertexCount) verticesArray.Capacity = vertexCount;
|
||||||
@ -755,22 +791,25 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
||||||
|
ExposedList<Slot> drawOrder = skeleton.drawOrder;
|
||||||
|
ExposedList<Slot> slots = skeleton.slots;
|
||||||
if (mixingOut && setupPose) {
|
if (mixingOut && setupPose) {
|
||||||
Array.Copy(skeleton.slots.Items, 0, skeleton.drawOrder.Items, 0, skeleton.slots.Count);
|
Array.Copy(slots.Items, 0, drawOrder.Items, 0, slots.Count);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float[] frames = this.frames;
|
float[] frames = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) Array.Copy(slots.Items, 0, drawOrder.Items, 0, slots.Count);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int frame;
|
int frame;
|
||||||
if (time >= frames[frames.Length - 1]) // Time is after last frame.
|
if (time >= frames[frames.Length - 1]) // Time is after last frame.
|
||||||
frame = frames.Length - 1;
|
frame = frames.Length - 1;
|
||||||
else
|
else
|
||||||
frame = Animation.BinarySearch(frames, time) - 1;
|
frame = Animation.BinarySearch(frames, time) - 1;
|
||||||
|
|
||||||
ExposedList<Slot> drawOrder = skeleton.drawOrder;
|
|
||||||
ExposedList<Slot> slots = skeleton.slots;
|
|
||||||
int[] drawOrderToSetupIndex = drawOrders[frame];
|
int[] drawOrderToSetupIndex = drawOrders[frame];
|
||||||
if (drawOrderToSetupIndex == null) {
|
if (drawOrderToSetupIndex == null) {
|
||||||
drawOrder.Clear();
|
drawOrder.Clear();
|
||||||
@ -814,10 +853,15 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
||||||
float[] frames = this.frames;
|
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
IkConstraint constraint = skeleton.ikConstraints.Items[ikConstraintIndex];
|
IkConstraint constraint = skeleton.ikConstraints.Items[ikConstraintIndex];
|
||||||
|
float[] frames = this.frames;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint.mix = constraint.data.mix;
|
||||||
|
constraint.bendDirection = constraint.data.bendDirection;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (time >= frames[frames.Length - ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.Length - ENTRIES]) { // Time is after last frame.
|
||||||
if (setupPose) {
|
if (setupPose) {
|
||||||
@ -877,10 +921,18 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
||||||
float[] frames = this.frames;
|
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
TransformConstraint constraint = skeleton.transformConstraints.Items[transformConstraintIndex];
|
TransformConstraint constraint = skeleton.transformConstraints.Items[transformConstraintIndex];
|
||||||
|
float[] frames = this.frames;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
var data = constraint.data;
|
||||||
|
constraint.rotateMix = data.rotateMix;
|
||||||
|
constraint.translateMix = data.translateMix;
|
||||||
|
constraint.scaleMix = data.scaleMix;
|
||||||
|
constraint.shearMix = data.shearMix;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
float rotate, translate, scale, shear;
|
float rotate, translate, scale, shear;
|
||||||
if (time >= frames[frames.Length - ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.Length - ENTRIES]) { // Time is after last frame.
|
||||||
@ -948,10 +1000,12 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
||||||
float[] frames = this.frames;
|
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
PathConstraint constraint = skeleton.pathConstraints.Items[pathConstraintIndex];
|
PathConstraint constraint = skeleton.pathConstraints.Items[pathConstraintIndex];
|
||||||
|
float[] frames = this.frames;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) constraint.position = constraint.data.position;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
float position;
|
float position;
|
||||||
if (time >= frames[frames.Length - ENTRIES]) // Time is after last frame.
|
if (time >= frames[frames.Length - ENTRIES]) // Time is after last frame.
|
||||||
@ -983,10 +1037,12 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
||||||
float[] frames = this.frames;
|
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
PathConstraint constraint = skeleton.pathConstraints.Items[pathConstraintIndex];
|
PathConstraint constraint = skeleton.pathConstraints.Items[pathConstraintIndex];
|
||||||
|
float[] frames = this.frames;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) constraint.spacing = constraint.data.spacing;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
float spacing;
|
float spacing;
|
||||||
if (time >= frames[frames.Length - ENTRIES]) // Time is after last frame.
|
if (time >= frames[frames.Length - ENTRIES]) // Time is after last frame.
|
||||||
@ -1038,10 +1094,15 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
override public void Apply (Skeleton skeleton, float lastTime, float time, ExposedList<Event> firedEvents, float alpha, bool setupPose, bool mixingOut) {
|
||||||
float[] frames = this.frames;
|
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
PathConstraint constraint = skeleton.pathConstraints.Items[pathConstraintIndex];
|
PathConstraint constraint = skeleton.pathConstraints.Items[pathConstraintIndex];
|
||||||
|
float[] frames = this.frames;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint.rotateMix = constraint.data.rotateMix;
|
||||||
|
constraint.translateMix = constraint.data.translateMix;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
float rotate, translate;
|
float rotate, translate;
|
||||||
if (time >= frames[frames.Length - ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.Length - ENTRIES]) { // Time is after last frame.
|
||||||
|
|||||||
@ -243,9 +243,14 @@ function Animation.RotateTimeline.new (frameCount)
|
|||||||
|
|
||||||
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
||||||
local frames = self.frames
|
local frames = self.frames
|
||||||
if time < frames[0] then return end -- Time is before first frame.
|
|
||||||
|
|
||||||
local bone = skeleton.bones[self.boneIndex]
|
local bone = skeleton.bones[self.boneIndex]
|
||||||
|
if time < frames[0] then
|
||||||
|
if setupPose then
|
||||||
|
bone.rotation = bone.data.rotation
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if time >= frames[zlen(frames) - ENTRIES] then -- Time is after last frame.
|
if time >= frames[zlen(frames) - ENTRIES] then -- Time is after last frame.
|
||||||
if setupPose then
|
if setupPose then
|
||||||
@ -308,9 +313,15 @@ function Animation.TranslateTimeline.new (frameCount)
|
|||||||
|
|
||||||
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
||||||
local frames = self.frames
|
local frames = self.frames
|
||||||
if time < frames[0] then return end -- Time is before first frame.
|
|
||||||
|
|
||||||
local bone = skeleton.bones[self.boneIndex]
|
local bone = skeleton.bones[self.boneIndex]
|
||||||
|
if time < frames[0] then
|
||||||
|
if (setupPose) then
|
||||||
|
bone.x = bone.data.x
|
||||||
|
bone.y = bone.data.y
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local x = 0
|
local x = 0
|
||||||
local y = 0
|
local y = 0
|
||||||
@ -360,9 +371,15 @@ function Animation.ScaleTimeline.new (frameCount)
|
|||||||
|
|
||||||
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
||||||
local frames = self.frames
|
local frames = self.frames
|
||||||
if time < frames[0] then return end -- Time is before first frame.
|
|
||||||
|
|
||||||
local bone = skeleton.bones[self.boneIndex]
|
local bone = skeleton.bones[self.boneIndex]
|
||||||
|
if time < frames[0] then
|
||||||
|
if setupPose then
|
||||||
|
bone.scaleX = bone.data.scaleX
|
||||||
|
bone.scaleY = bone.data.scaleY
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local x = 0
|
local x = 0
|
||||||
local y = 0
|
local y = 0
|
||||||
@ -429,9 +446,15 @@ function Animation.ShearTimeline.new (frameCount)
|
|||||||
|
|
||||||
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
||||||
local frames = self.frames
|
local frames = self.frames
|
||||||
if time < frames[0] then return end -- Time is before first frame.
|
|
||||||
|
|
||||||
local bone = skeleton.bones[self.boneIndex]
|
local bone = skeleton.bones[self.boneIndex]
|
||||||
|
if time < frames[0] then
|
||||||
|
if setupPose then
|
||||||
|
bone.shearX = bone.data.shearX
|
||||||
|
bone.shearY = bone.data.shearY
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local x = 0
|
local x = 0
|
||||||
local y = 0
|
local y = 0
|
||||||
@ -496,7 +519,13 @@ function Animation.ColorTimeline.new (frameCount)
|
|||||||
|
|
||||||
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
||||||
local frames = self.frames
|
local frames = self.frames
|
||||||
if time < frames[0] then return end -- Time is before first frame.
|
local slot = skeleton.slots[self.slotIndex]
|
||||||
|
if time < frames[0] then
|
||||||
|
if setupPose then
|
||||||
|
slot.color:setFrom(slot.data.color)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local r, g, b, a
|
local r, g, b, a
|
||||||
if time >= frames[zlen(frames) - ENTRIES] then -- Time is after last frame.
|
if time >= frames[zlen(frames) - ENTRIES] then -- Time is after last frame.
|
||||||
@ -521,7 +550,6 @@ function Animation.ColorTimeline.new (frameCount)
|
|||||||
b = b + (frames[frame + B] - b) * percent
|
b = b + (frames[frame + B] - b) * percent
|
||||||
a = a + (frames[frame + A] - a) * percent
|
a = a + (frames[frame + A] - a) * percent
|
||||||
end
|
end
|
||||||
local slot = skeleton.slots[self.slotIndex]
|
|
||||||
if alpha == 1 then
|
if alpha == 1 then
|
||||||
slot.color:set(r, g, b, a)
|
slot.color:set(r, g, b, a)
|
||||||
else
|
else
|
||||||
@ -557,10 +585,9 @@ function Animation.AttachmentTimeline.new (frameCount)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
||||||
local slot
|
local slot = skeleton.slots[self.slotIndex]
|
||||||
local attachmentName
|
local attachmentName
|
||||||
if mixingOut and setupPose then
|
if mixingOut and setupPose then
|
||||||
slot = skeleton.slots[self.slotIndex]
|
|
||||||
attachmentName = slot.data.attachmentName
|
attachmentName = slot.data.attachmentName
|
||||||
if not attachmentName then
|
if not attachmentName then
|
||||||
slot:setAttachment(nil)
|
slot:setAttachment(nil)
|
||||||
@ -571,7 +598,17 @@ function Animation.AttachmentTimeline.new (frameCount)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local frames = self.frames
|
local frames = self.frames
|
||||||
if time < frames[0] then return end
|
if time < frames[0] then
|
||||||
|
if setupPose then
|
||||||
|
attachmentName = slot.data.attachmentName
|
||||||
|
if not attachmentName then
|
||||||
|
slot:setAttachment(nil)
|
||||||
|
else
|
||||||
|
skeleton:setAttachment(skeleton:getAttachmentByIndex(self.slotIndex, attachmentName))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local frameIndex = 0
|
local frameIndex = 0
|
||||||
if time >= frames[zlen(frames) - 1] then
|
if time >= frames[zlen(frames) - 1] then
|
||||||
@ -617,12 +654,18 @@ function Animation.DeformTimeline.new (frameCount)
|
|||||||
if not slotAttachment:applyDeform(self.attachment) then return end
|
if not slotAttachment:applyDeform(self.attachment) then return end
|
||||||
|
|
||||||
local frames = self.frames
|
local frames = self.frames
|
||||||
if time < frames[0] then return end -- Time is before first frame.
|
local verticesArray = slot.attachmentVertices
|
||||||
|
if time < frames[0] then
|
||||||
|
if setupPose then
|
||||||
|
verticesArray = {}
|
||||||
|
slot.attachmentVertices = verticesArray
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local frameVertices = self.frameVertices
|
local frameVertices = self.frameVertices
|
||||||
local vertexCount = #(frameVertices[0])
|
local vertexCount = #(frameVertices[0])
|
||||||
|
|
||||||
local verticesArray = slot.attachmentVertices
|
|
||||||
if (#verticesArray ~= vertexCount) then alpha = 1 end -- Don't mix from uninitialized slot vertices.
|
if (#verticesArray ~= vertexCount) then alpha = 1 end -- Don't mix from uninitialized slot vertices.
|
||||||
local vertices = utils.setArraySize(verticesArray, vertexCount)
|
local vertices = utils.setArraySize(verticesArray, vertexCount)
|
||||||
|
|
||||||
@ -803,7 +846,14 @@ function Animation.DrawOrderTimeline.new (frameCount)
|
|||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
local frames = self.frames
|
local frames = self.frames
|
||||||
if time < frames[0] then return end -- Time is before first frame.
|
if time < frames[0] then
|
||||||
|
if setupPose then
|
||||||
|
for i,slot in ipairs(slots) do
|
||||||
|
drawOrder[i] = slots[i]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local frame
|
local frame
|
||||||
if time >= frames[zlen(frames) - 1] then -- Time is after last frame.
|
if time >= frames[zlen(frames) - 1] then -- Time is after last frame.
|
||||||
@ -855,9 +905,15 @@ function Animation.IkConstraintTimeline.new (frameCount)
|
|||||||
|
|
||||||
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
||||||
local frames = self.frames
|
local frames = self.frames
|
||||||
if time < frames[0] then return end -- Time is before first frame.
|
|
||||||
|
|
||||||
local constraint = skeleton.ikConstraints[self.ikConstraintIndex]
|
local constraint = skeleton.ikConstraints[self.ikConstraintIndex]
|
||||||
|
if time < frames[0] then
|
||||||
|
if setupPose then
|
||||||
|
constraint.mix = constraint.data.mix
|
||||||
|
constraint.bendDirection = constraint.data.bendDirection
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if time >= frames[zlen(frames) - ENTRIES] then -- Time is after last frame.
|
if time >= frames[zlen(frames) - ENTRIES] then -- Time is after last frame.
|
||||||
if setupPose then
|
if setupPose then
|
||||||
@ -931,9 +987,18 @@ function Animation.TransformConstraintTimeline.new (frameCount)
|
|||||||
|
|
||||||
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
||||||
local frames = self.frames
|
local frames = self.frames
|
||||||
if time < frames[0] then return end -- Time is before first frame.
|
|
||||||
|
|
||||||
local constraint = skeleton.transformConstraints[self.transformConstraintIndex]
|
local constraint = skeleton.transformConstraints[self.transformConstraintIndex]
|
||||||
|
if time < frames[0] then
|
||||||
|
if setupPose then
|
||||||
|
local data = constraint.data
|
||||||
|
constraint.rotateMix = data.rotateMix
|
||||||
|
constraint.translateMix = data.translateMix
|
||||||
|
constraint.scaleMix = data.scaleMix
|
||||||
|
constraint.shearMix = data.shearMix
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local rotate = 0
|
local rotate = 0
|
||||||
local translate = 0
|
local translate = 0
|
||||||
@ -1003,9 +1068,14 @@ function Animation.PathConstraintPositionTimeline.new (frameCount)
|
|||||||
|
|
||||||
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
||||||
local frames = self.frames
|
local frames = self.frames
|
||||||
if (time < frames[0]) then return end -- Time is before first frame.
|
|
||||||
|
|
||||||
local constraint = skeleton.pathConstraints[self.pathConstraintIndex]
|
local constraint = skeleton.pathConstraints[self.pathConstraintIndex]
|
||||||
|
if (time < frames[0]) then
|
||||||
|
if setupPose then
|
||||||
|
constraint.position = constraint.data.position
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local position = 0
|
local position = 0
|
||||||
if time >= frames[zlen(frames) - ENTRIES] then -- Time is after last frame.
|
if time >= frames[zlen(frames) - ENTRIES] then -- Time is after last frame.
|
||||||
@ -1055,9 +1125,14 @@ function Animation.PathConstraintSpacingTimeline.new (frameCount)
|
|||||||
|
|
||||||
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
||||||
local frames = self.frames
|
local frames = self.frames
|
||||||
if (time < frames[0]) then return end -- Time is before first frame.
|
|
||||||
|
|
||||||
local constraint = skeleton.pathConstraints[self.pathConstraintIndex]
|
local constraint = skeleton.pathConstraints[self.pathConstraintIndex]
|
||||||
|
if (time < frames[0]) then
|
||||||
|
if setupPose then
|
||||||
|
constraint.spacing = constraint.data.spacing
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local spacing = 0
|
local spacing = 0
|
||||||
if time >= frames[zlen(frames) - ENTRIES] then -- Time is after last frame.
|
if time >= frames[zlen(frames) - ENTRIES] then -- Time is after last frame.
|
||||||
@ -1111,9 +1186,15 @@ function Animation.PathConstraintMixTimeline.new (frameCount)
|
|||||||
|
|
||||||
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
function self:apply (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut)
|
||||||
local frames = self.frames
|
local frames = self.frames
|
||||||
if (time < frames[0]) then return end -- Time is before first frame.
|
|
||||||
|
|
||||||
local constraint = skeleton.pathConstraints[self.pathConstraintIndex]
|
local constraint = skeleton.pathConstraints[self.pathConstraintIndex]
|
||||||
|
if (time < frames[0]) then
|
||||||
|
if setupPose then
|
||||||
|
constraint.rotateMix = constraint.data.rotateMix
|
||||||
|
constraint.translateMix = constraint.data.translateMix
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local rotate = 0
|
local rotate = 0
|
||||||
local translate = 0
|
local translate = 0
|
||||||
|
|||||||
@ -45,7 +45,7 @@ end
|
|||||||
|
|
||||||
function Color.newWith (r, g, b, a)
|
function Color.newWith (r, g, b, a)
|
||||||
local self = {
|
local self = {
|
||||||
r = a, g = g, b = b, a = a
|
r = r, g = g, b = b, a = a
|
||||||
}
|
}
|
||||||
setmetatable(self, Color)
|
setmetatable(self, Color)
|
||||||
|
|
||||||
|
|||||||
@ -39,22 +39,25 @@ using namespace spine;
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
void callback (AnimationState* state, int trackIndex, EventType type, Event* event, int loopCount) {
|
void callback (AnimationState* state, EventType type, TrackEntry* entry, Event* event) {
|
||||||
TrackEntry* entry = AnimationState_getCurrent(state, trackIndex);
|
|
||||||
const char* animationName = (entry && entry->animation) ? entry->animation->name : 0;
|
const char* animationName = (entry && entry->animation) ? entry->animation->name : 0;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ANIMATION_START:
|
case ANIMATION_START:
|
||||||
printf("%d start: %s\n", trackIndex, animationName);
|
printf("%d start: %s\n", entry->trackIndex, animationName);
|
||||||
break;
|
break;
|
||||||
|
case ANIMATION_INTERRUPT:
|
||||||
|
printf("%d interrupt: %s\n", entry->trackIndex, animationName);
|
||||||
case ANIMATION_END:
|
case ANIMATION_END:
|
||||||
printf("%d end: %s\n", trackIndex, animationName);
|
printf("%d end: %s\n", entry->trackIndex, animationName);
|
||||||
break;
|
break;
|
||||||
case ANIMATION_COMPLETE:
|
case ANIMATION_COMPLETE:
|
||||||
printf("%d complete: %s, %d\n", trackIndex, animationName, loopCount);
|
printf("%d complete: %s\n", entry->trackIndex, animationName);
|
||||||
break;
|
break;
|
||||||
|
case ANIMATION_DISPOSE:
|
||||||
|
printf("%d dispose: %s\n", entry->trackIndex, animationName);
|
||||||
case ANIMATION_EVENT:
|
case ANIMATION_EVENT:
|
||||||
printf("%d event: %s, %s: %d, %f, %s\n", trackIndex, animationName, event->data->name, event->intValue, event->floatValue,
|
printf("%d event: %s, %s: %d, %f, %s\n", entry->trackIndex, animationName, event->data->name, event->intValue, event->floatValue,
|
||||||
event->stringValue);
|
event->stringValue);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@ -40,12 +40,12 @@ public class Main extends Sprite {
|
|||||||
|
|
||||||
public function Main () {
|
public function Main () {
|
||||||
var example:Class;
|
var example:Class;
|
||||||
// example = SpineboyExample;
|
example = SpineboyExample;
|
||||||
// example = GoblinsExample;
|
// example = GoblinsExample;
|
||||||
// example = RaptorExample;
|
// example = RaptorExample;
|
||||||
// example = TankExample;
|
// example = TankExample;
|
||||||
// example = VineExample;
|
// example = VineExample;
|
||||||
example = StretchymanExample;
|
// example = StretchymanExample;
|
||||||
|
|
||||||
_starling = new Starling(example, stage);
|
_starling = new Starling(example, stage);
|
||||||
_starling.enableErrorChecking = true;
|
_starling.enableErrorChecking = true;
|
||||||
|
|||||||
Binary file not shown.
20
spine-ts/build/spine-all.d.ts
vendored
20
spine-ts/build/spine-all.d.ts
vendored
@ -196,6 +196,16 @@ declare module spine {
|
|||||||
setFrame(frameIndex: number, time: number, attachmentName: string): void;
|
setFrame(frameIndex: number, time: number, attachmentName: string): void;
|
||||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||||
}
|
}
|
||||||
|
class DeformTimeline extends CurveTimeline {
|
||||||
|
slotIndex: number;
|
||||||
|
attachment: VertexAttachment;
|
||||||
|
frames: ArrayLike<number>;
|
||||||
|
frameVertices: Array<ArrayLike<number>>;
|
||||||
|
constructor(frameCount: number);
|
||||||
|
getPropertyId(): number;
|
||||||
|
setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
|
||||||
|
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||||
|
}
|
||||||
class EventTimeline implements Timeline {
|
class EventTimeline implements Timeline {
|
||||||
frames: ArrayLike<number>;
|
frames: ArrayLike<number>;
|
||||||
events: Array<Event>;
|
events: Array<Event>;
|
||||||
@ -214,16 +224,6 @@ declare module spine {
|
|||||||
setFrame(frameIndex: number, time: number, drawOrder: Array<number>): void;
|
setFrame(frameIndex: number, time: number, drawOrder: Array<number>): void;
|
||||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||||
}
|
}
|
||||||
class DeformTimeline extends CurveTimeline {
|
|
||||||
slotIndex: number;
|
|
||||||
attachment: VertexAttachment;
|
|
||||||
frames: ArrayLike<number>;
|
|
||||||
frameVertices: Array<ArrayLike<number>>;
|
|
||||||
constructor(frameCount: number);
|
|
||||||
getPropertyId(): number;
|
|
||||||
setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
|
|
||||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
|
||||||
}
|
|
||||||
class IkConstraintTimeline extends CurveTimeline {
|
class IkConstraintTimeline extends CurveTimeline {
|
||||||
static ENTRIES: number;
|
static ENTRIES: number;
|
||||||
static PREV_TIME: number;
|
static PREV_TIME: number;
|
||||||
|
|||||||
@ -515,9 +515,12 @@ var spine;
|
|||||||
};
|
};
|
||||||
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
bone.rotation = bone.data.rotation;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
|
||||||
if (setupPose)
|
if (setupPose)
|
||||||
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha;
|
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha;
|
||||||
@ -569,9 +572,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.x = bone.data.x;
|
||||||
|
bone.y = bone.data.y;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var x = 0, y = 0;
|
var x = 0, y = 0;
|
||||||
if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) {
|
||||||
x = frames[frames.length + TranslateTimeline.PREV_X];
|
x = frames[frames.length + TranslateTimeline.PREV_X];
|
||||||
@ -614,9 +622,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.scaleX = bone.data.scaleX;
|
||||||
|
bone.scaleY = bone.data.scaleY;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var x = 0, y = 0;
|
var x = 0, y = 0;
|
||||||
if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) {
|
||||||
x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX;
|
x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX;
|
||||||
@ -670,9 +683,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.shearX = bone.data.shearX;
|
||||||
|
bone.shearY = bone.data.shearY;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var x = 0, y = 0;
|
var x = 0, y = 0;
|
||||||
if (time >= frames[frames.length - ShearTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - ShearTimeline.ENTRIES]) {
|
||||||
x = frames[frames.length + ShearTimeline.PREV_X];
|
x = frames[frames.length + ShearTimeline.PREV_X];
|
||||||
@ -717,9 +735,13 @@ var spine;
|
|||||||
this.frames[frameIndex + ColorTimeline.A] = a;
|
this.frames[frameIndex + ColorTimeline.A] = a;
|
||||||
};
|
};
|
||||||
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
|
var slot = skeleton.slots[this.slotIndex];
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
slot.color.setFromColor(slot.data.color);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
var r = 0, g = 0, b = 0, a = 0;
|
var r = 0, g = 0, b = 0, a = 0;
|
||||||
if (time >= frames[frames.length - ColorTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - ColorTimeline.ENTRIES]) {
|
||||||
var i = frames.length;
|
var i = frames.length;
|
||||||
@ -741,7 +763,6 @@ var spine;
|
|||||||
b += (frames[frame + ColorTimeline.B] - b) * percent;
|
b += (frames[frame + ColorTimeline.B] - b) * percent;
|
||||||
a += (frames[frame + ColorTimeline.A] - a) * percent;
|
a += (frames[frame + ColorTimeline.A] - a) * percent;
|
||||||
}
|
}
|
||||||
var slot = skeleton.slots[this.slotIndex];
|
|
||||||
if (alpha == 1)
|
if (alpha == 1)
|
||||||
slot.color.set(r, g, b, a);
|
slot.color.set(r, g, b, a);
|
||||||
else {
|
else {
|
||||||
@ -780,15 +801,20 @@ var spine;
|
|||||||
this.attachmentNames[frameIndex] = attachmentName;
|
this.attachmentNames[frameIndex] = attachmentName;
|
||||||
};
|
};
|
||||||
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
|
var slot = skeleton.slots[this.slotIndex];
|
||||||
if (mixingOut && setupPose) {
|
if (mixingOut && setupPose) {
|
||||||
var slot = skeleton.slots[this.slotIndex];
|
|
||||||
var attachmentName_1 = slot.data.attachmentName;
|
var attachmentName_1 = slot.data.attachmentName;
|
||||||
slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1));
|
slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
var attachmentName_2 = slot.data.attachmentName;
|
||||||
|
slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
var frameIndex = 0;
|
var frameIndex = 0;
|
||||||
if (time >= frames[frames.length - 1])
|
if (time >= frames[frames.length - 1])
|
||||||
frameIndex = frames.length - 1;
|
frameIndex = frames.length - 1;
|
||||||
@ -801,93 +827,6 @@ var spine;
|
|||||||
return AttachmentTimeline;
|
return AttachmentTimeline;
|
||||||
}());
|
}());
|
||||||
spine.AttachmentTimeline = AttachmentTimeline;
|
spine.AttachmentTimeline = AttachmentTimeline;
|
||||||
var EventTimeline = (function () {
|
|
||||||
function EventTimeline(frameCount) {
|
|
||||||
this.frames = spine.Utils.newFloatArray(frameCount);
|
|
||||||
this.events = new Array(frameCount);
|
|
||||||
}
|
|
||||||
EventTimeline.prototype.getPropertyId = function () {
|
|
||||||
return TimelineType.event << 24;
|
|
||||||
};
|
|
||||||
EventTimeline.prototype.getFrameCount = function () {
|
|
||||||
return this.frames.length;
|
|
||||||
};
|
|
||||||
EventTimeline.prototype.setFrame = function (frameIndex, event) {
|
|
||||||
this.frames[frameIndex] = event.time;
|
|
||||||
this.events[frameIndex] = event;
|
|
||||||
};
|
|
||||||
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
|
||||||
if (firedEvents == null)
|
|
||||||
return;
|
|
||||||
var frames = this.frames;
|
|
||||||
var frameCount = this.frames.length;
|
|
||||||
if (lastTime > time) {
|
|
||||||
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, setupPose, mixingOut);
|
|
||||||
lastTime = -1;
|
|
||||||
}
|
|
||||||
else if (lastTime >= frames[frameCount - 1])
|
|
||||||
return;
|
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var frame = 0;
|
|
||||||
if (lastTime < frames[0])
|
|
||||||
frame = 0;
|
|
||||||
else {
|
|
||||||
frame = Animation.binarySearch(frames, lastTime);
|
|
||||||
var frameTime = frames[frame];
|
|
||||||
while (frame > 0) {
|
|
||||||
if (frames[frame - 1] != frameTime)
|
|
||||||
break;
|
|
||||||
frame--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (; frame < frameCount && time >= frames[frame]; frame++)
|
|
||||||
firedEvents.push(this.events[frame]);
|
|
||||||
};
|
|
||||||
return EventTimeline;
|
|
||||||
}());
|
|
||||||
spine.EventTimeline = EventTimeline;
|
|
||||||
var DrawOrderTimeline = (function () {
|
|
||||||
function DrawOrderTimeline(frameCount) {
|
|
||||||
this.frames = spine.Utils.newFloatArray(frameCount);
|
|
||||||
this.drawOrders = new Array(frameCount);
|
|
||||||
}
|
|
||||||
DrawOrderTimeline.prototype.getPropertyId = function () {
|
|
||||||
return TimelineType.drawOrder << 24;
|
|
||||||
};
|
|
||||||
DrawOrderTimeline.prototype.getFrameCount = function () {
|
|
||||||
return this.frames.length;
|
|
||||||
};
|
|
||||||
DrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) {
|
|
||||||
this.frames[frameIndex] = time;
|
|
||||||
this.drawOrders[frameIndex] = drawOrder;
|
|
||||||
};
|
|
||||||
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
|
||||||
if (mixingOut && setupPose) {
|
|
||||||
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var frames = this.frames;
|
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var frame = 0;
|
|
||||||
if (time >= frames[frames.length - 1])
|
|
||||||
frame = frames.length - 1;
|
|
||||||
else
|
|
||||||
frame = Animation.binarySearch(frames, time) - 1;
|
|
||||||
var drawOrder = skeleton.drawOrder;
|
|
||||||
var slots = skeleton.slots;
|
|
||||||
var drawOrderToSetupIndex = this.drawOrders[frame];
|
|
||||||
if (drawOrderToSetupIndex == null)
|
|
||||||
spine.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length);
|
|
||||||
else {
|
|
||||||
for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++)
|
|
||||||
drawOrder[i] = slots[drawOrderToSetupIndex[i]];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return DrawOrderTimeline;
|
|
||||||
}());
|
|
||||||
spine.DrawOrderTimeline = DrawOrderTimeline;
|
|
||||||
var DeformTimeline = (function (_super) {
|
var DeformTimeline = (function (_super) {
|
||||||
__extends(DeformTimeline, _super);
|
__extends(DeformTimeline, _super);
|
||||||
function DeformTimeline(frameCount) {
|
function DeformTimeline(frameCount) {
|
||||||
@ -908,11 +847,14 @@ var spine;
|
|||||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
||||||
return;
|
return;
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
var verticesArray = slot.attachmentVertices;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
spine.Utils.setArraySize(verticesArray, 0);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
var frameVertices = this.frameVertices;
|
var frameVertices = this.frameVertices;
|
||||||
var vertexCount = frameVertices[0].length;
|
var vertexCount = frameVertices[0].length;
|
||||||
var verticesArray = slot.attachmentVertices;
|
|
||||||
if (verticesArray.length != vertexCount)
|
if (verticesArray.length != vertexCount)
|
||||||
alpha = 1;
|
alpha = 1;
|
||||||
var vertices = spine.Utils.setArraySize(verticesArray, vertexCount);
|
var vertices = spine.Utils.setArraySize(verticesArray, vertexCount);
|
||||||
@ -978,6 +920,96 @@ var spine;
|
|||||||
return DeformTimeline;
|
return DeformTimeline;
|
||||||
}(CurveTimeline));
|
}(CurveTimeline));
|
||||||
spine.DeformTimeline = DeformTimeline;
|
spine.DeformTimeline = DeformTimeline;
|
||||||
|
var EventTimeline = (function () {
|
||||||
|
function EventTimeline(frameCount) {
|
||||||
|
this.frames = spine.Utils.newFloatArray(frameCount);
|
||||||
|
this.events = new Array(frameCount);
|
||||||
|
}
|
||||||
|
EventTimeline.prototype.getPropertyId = function () {
|
||||||
|
return TimelineType.event << 24;
|
||||||
|
};
|
||||||
|
EventTimeline.prototype.getFrameCount = function () {
|
||||||
|
return this.frames.length;
|
||||||
|
};
|
||||||
|
EventTimeline.prototype.setFrame = function (frameIndex, event) {
|
||||||
|
this.frames[frameIndex] = event.time;
|
||||||
|
this.events[frameIndex] = event;
|
||||||
|
};
|
||||||
|
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
|
if (firedEvents == null)
|
||||||
|
return;
|
||||||
|
var frames = this.frames;
|
||||||
|
var frameCount = this.frames.length;
|
||||||
|
if (lastTime > time) {
|
||||||
|
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, setupPose, mixingOut);
|
||||||
|
lastTime = -1;
|
||||||
|
}
|
||||||
|
else if (lastTime >= frames[frameCount - 1])
|
||||||
|
return;
|
||||||
|
if (time < frames[0])
|
||||||
|
return;
|
||||||
|
var frame = 0;
|
||||||
|
if (lastTime < frames[0])
|
||||||
|
frame = 0;
|
||||||
|
else {
|
||||||
|
frame = Animation.binarySearch(frames, lastTime);
|
||||||
|
var frameTime = frames[frame];
|
||||||
|
while (frame > 0) {
|
||||||
|
if (frames[frame - 1] != frameTime)
|
||||||
|
break;
|
||||||
|
frame--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (; frame < frameCount && time >= frames[frame]; frame++)
|
||||||
|
firedEvents.push(this.events[frame]);
|
||||||
|
};
|
||||||
|
return EventTimeline;
|
||||||
|
}());
|
||||||
|
spine.EventTimeline = EventTimeline;
|
||||||
|
var DrawOrderTimeline = (function () {
|
||||||
|
function DrawOrderTimeline(frameCount) {
|
||||||
|
this.frames = spine.Utils.newFloatArray(frameCount);
|
||||||
|
this.drawOrders = new Array(frameCount);
|
||||||
|
}
|
||||||
|
DrawOrderTimeline.prototype.getPropertyId = function () {
|
||||||
|
return TimelineType.drawOrder << 24;
|
||||||
|
};
|
||||||
|
DrawOrderTimeline.prototype.getFrameCount = function () {
|
||||||
|
return this.frames.length;
|
||||||
|
};
|
||||||
|
DrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) {
|
||||||
|
this.frames[frameIndex] = time;
|
||||||
|
this.drawOrders[frameIndex] = drawOrder;
|
||||||
|
};
|
||||||
|
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
|
var drawOrder = skeleton.drawOrder;
|
||||||
|
var slots = skeleton.slots;
|
||||||
|
if (mixingOut && setupPose) {
|
||||||
|
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var frames = this.frames;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var frame = 0;
|
||||||
|
if (time >= frames[frames.length - 1])
|
||||||
|
frame = frames.length - 1;
|
||||||
|
else
|
||||||
|
frame = Animation.binarySearch(frames, time) - 1;
|
||||||
|
var drawOrderToSetupIndex = this.drawOrders[frame];
|
||||||
|
if (drawOrderToSetupIndex == null)
|
||||||
|
spine.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length);
|
||||||
|
else {
|
||||||
|
for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++)
|
||||||
|
drawOrder[i] = slots[drawOrderToSetupIndex[i]];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return DrawOrderTimeline;
|
||||||
|
}());
|
||||||
|
spine.DrawOrderTimeline = DrawOrderTimeline;
|
||||||
var IkConstraintTimeline = (function (_super) {
|
var IkConstraintTimeline = (function (_super) {
|
||||||
__extends(IkConstraintTimeline, _super);
|
__extends(IkConstraintTimeline, _super);
|
||||||
function IkConstraintTimeline(frameCount) {
|
function IkConstraintTimeline(frameCount) {
|
||||||
@ -995,9 +1027,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
|
var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint.mix = constraint.data.mix;
|
||||||
|
constraint.bendDirection = constraint.data.bendDirection;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
|
||||||
if (setupPose) {
|
if (setupPose) {
|
||||||
constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
|
constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
|
||||||
@ -1053,9 +1090,17 @@ var spine;
|
|||||||
};
|
};
|
||||||
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
|
var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
var data = constraint.data;
|
||||||
|
constraint.rotateMix = data.rotateMix;
|
||||||
|
constraint.translateMix = data.rotateMix;
|
||||||
|
constraint.scaleMix = data.scaleMix;
|
||||||
|
constraint.shearMix = data.shearMix;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var rotate = 0, translate = 0, scale = 0, shear = 0;
|
var rotate = 0, translate = 0, scale = 0, shear = 0;
|
||||||
if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) {
|
||||||
var i = frames.length;
|
var i = frames.length;
|
||||||
@ -1120,9 +1165,12 @@ var spine;
|
|||||||
};
|
};
|
||||||
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
constraint.position = constraint.data.position;
|
||||||
|
return;
|
||||||
|
}
|
||||||
var position = 0;
|
var position = 0;
|
||||||
if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES])
|
if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES])
|
||||||
position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE];
|
position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE];
|
||||||
@ -1155,9 +1203,12 @@ var spine;
|
|||||||
};
|
};
|
||||||
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
constraint.spacing = constraint.data.spacing;
|
||||||
|
return;
|
||||||
|
}
|
||||||
var spacing = 0;
|
var spacing = 0;
|
||||||
if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES])
|
if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES])
|
||||||
spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE];
|
spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE];
|
||||||
@ -1193,9 +1244,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint.rotateMix = constraint.data.rotateMix;
|
||||||
|
constraint.translateMix = constraint.data.translateMix;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var rotate = 0, translate = 0;
|
var rotate = 0, translate = 0;
|
||||||
if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) {
|
||||||
rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE];
|
rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE];
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
20
spine-ts/build/spine-canvas.d.ts
vendored
20
spine-ts/build/spine-canvas.d.ts
vendored
@ -196,6 +196,16 @@ declare module spine {
|
|||||||
setFrame(frameIndex: number, time: number, attachmentName: string): void;
|
setFrame(frameIndex: number, time: number, attachmentName: string): void;
|
||||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||||
}
|
}
|
||||||
|
class DeformTimeline extends CurveTimeline {
|
||||||
|
slotIndex: number;
|
||||||
|
attachment: VertexAttachment;
|
||||||
|
frames: ArrayLike<number>;
|
||||||
|
frameVertices: Array<ArrayLike<number>>;
|
||||||
|
constructor(frameCount: number);
|
||||||
|
getPropertyId(): number;
|
||||||
|
setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
|
||||||
|
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||||
|
}
|
||||||
class EventTimeline implements Timeline {
|
class EventTimeline implements Timeline {
|
||||||
frames: ArrayLike<number>;
|
frames: ArrayLike<number>;
|
||||||
events: Array<Event>;
|
events: Array<Event>;
|
||||||
@ -214,16 +224,6 @@ declare module spine {
|
|||||||
setFrame(frameIndex: number, time: number, drawOrder: Array<number>): void;
|
setFrame(frameIndex: number, time: number, drawOrder: Array<number>): void;
|
||||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||||
}
|
}
|
||||||
class DeformTimeline extends CurveTimeline {
|
|
||||||
slotIndex: number;
|
|
||||||
attachment: VertexAttachment;
|
|
||||||
frames: ArrayLike<number>;
|
|
||||||
frameVertices: Array<ArrayLike<number>>;
|
|
||||||
constructor(frameCount: number);
|
|
||||||
getPropertyId(): number;
|
|
||||||
setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
|
|
||||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
|
||||||
}
|
|
||||||
class IkConstraintTimeline extends CurveTimeline {
|
class IkConstraintTimeline extends CurveTimeline {
|
||||||
static ENTRIES: number;
|
static ENTRIES: number;
|
||||||
static PREV_TIME: number;
|
static PREV_TIME: number;
|
||||||
|
|||||||
@ -515,9 +515,12 @@ var spine;
|
|||||||
};
|
};
|
||||||
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
bone.rotation = bone.data.rotation;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
|
||||||
if (setupPose)
|
if (setupPose)
|
||||||
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha;
|
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha;
|
||||||
@ -569,9 +572,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.x = bone.data.x;
|
||||||
|
bone.y = bone.data.y;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var x = 0, y = 0;
|
var x = 0, y = 0;
|
||||||
if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) {
|
||||||
x = frames[frames.length + TranslateTimeline.PREV_X];
|
x = frames[frames.length + TranslateTimeline.PREV_X];
|
||||||
@ -614,9 +622,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.scaleX = bone.data.scaleX;
|
||||||
|
bone.scaleY = bone.data.scaleY;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var x = 0, y = 0;
|
var x = 0, y = 0;
|
||||||
if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) {
|
||||||
x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX;
|
x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX;
|
||||||
@ -670,9 +683,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.shearX = bone.data.shearX;
|
||||||
|
bone.shearY = bone.data.shearY;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var x = 0, y = 0;
|
var x = 0, y = 0;
|
||||||
if (time >= frames[frames.length - ShearTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - ShearTimeline.ENTRIES]) {
|
||||||
x = frames[frames.length + ShearTimeline.PREV_X];
|
x = frames[frames.length + ShearTimeline.PREV_X];
|
||||||
@ -717,9 +735,13 @@ var spine;
|
|||||||
this.frames[frameIndex + ColorTimeline.A] = a;
|
this.frames[frameIndex + ColorTimeline.A] = a;
|
||||||
};
|
};
|
||||||
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
|
var slot = skeleton.slots[this.slotIndex];
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
slot.color.setFromColor(slot.data.color);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
var r = 0, g = 0, b = 0, a = 0;
|
var r = 0, g = 0, b = 0, a = 0;
|
||||||
if (time >= frames[frames.length - ColorTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - ColorTimeline.ENTRIES]) {
|
||||||
var i = frames.length;
|
var i = frames.length;
|
||||||
@ -741,7 +763,6 @@ var spine;
|
|||||||
b += (frames[frame + ColorTimeline.B] - b) * percent;
|
b += (frames[frame + ColorTimeline.B] - b) * percent;
|
||||||
a += (frames[frame + ColorTimeline.A] - a) * percent;
|
a += (frames[frame + ColorTimeline.A] - a) * percent;
|
||||||
}
|
}
|
||||||
var slot = skeleton.slots[this.slotIndex];
|
|
||||||
if (alpha == 1)
|
if (alpha == 1)
|
||||||
slot.color.set(r, g, b, a);
|
slot.color.set(r, g, b, a);
|
||||||
else {
|
else {
|
||||||
@ -780,15 +801,20 @@ var spine;
|
|||||||
this.attachmentNames[frameIndex] = attachmentName;
|
this.attachmentNames[frameIndex] = attachmentName;
|
||||||
};
|
};
|
||||||
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
|
var slot = skeleton.slots[this.slotIndex];
|
||||||
if (mixingOut && setupPose) {
|
if (mixingOut && setupPose) {
|
||||||
var slot = skeleton.slots[this.slotIndex];
|
|
||||||
var attachmentName_1 = slot.data.attachmentName;
|
var attachmentName_1 = slot.data.attachmentName;
|
||||||
slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1));
|
slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
var attachmentName_2 = slot.data.attachmentName;
|
||||||
|
slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
var frameIndex = 0;
|
var frameIndex = 0;
|
||||||
if (time >= frames[frames.length - 1])
|
if (time >= frames[frames.length - 1])
|
||||||
frameIndex = frames.length - 1;
|
frameIndex = frames.length - 1;
|
||||||
@ -801,93 +827,6 @@ var spine;
|
|||||||
return AttachmentTimeline;
|
return AttachmentTimeline;
|
||||||
}());
|
}());
|
||||||
spine.AttachmentTimeline = AttachmentTimeline;
|
spine.AttachmentTimeline = AttachmentTimeline;
|
||||||
var EventTimeline = (function () {
|
|
||||||
function EventTimeline(frameCount) {
|
|
||||||
this.frames = spine.Utils.newFloatArray(frameCount);
|
|
||||||
this.events = new Array(frameCount);
|
|
||||||
}
|
|
||||||
EventTimeline.prototype.getPropertyId = function () {
|
|
||||||
return TimelineType.event << 24;
|
|
||||||
};
|
|
||||||
EventTimeline.prototype.getFrameCount = function () {
|
|
||||||
return this.frames.length;
|
|
||||||
};
|
|
||||||
EventTimeline.prototype.setFrame = function (frameIndex, event) {
|
|
||||||
this.frames[frameIndex] = event.time;
|
|
||||||
this.events[frameIndex] = event;
|
|
||||||
};
|
|
||||||
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
|
||||||
if (firedEvents == null)
|
|
||||||
return;
|
|
||||||
var frames = this.frames;
|
|
||||||
var frameCount = this.frames.length;
|
|
||||||
if (lastTime > time) {
|
|
||||||
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, setupPose, mixingOut);
|
|
||||||
lastTime = -1;
|
|
||||||
}
|
|
||||||
else if (lastTime >= frames[frameCount - 1])
|
|
||||||
return;
|
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var frame = 0;
|
|
||||||
if (lastTime < frames[0])
|
|
||||||
frame = 0;
|
|
||||||
else {
|
|
||||||
frame = Animation.binarySearch(frames, lastTime);
|
|
||||||
var frameTime = frames[frame];
|
|
||||||
while (frame > 0) {
|
|
||||||
if (frames[frame - 1] != frameTime)
|
|
||||||
break;
|
|
||||||
frame--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (; frame < frameCount && time >= frames[frame]; frame++)
|
|
||||||
firedEvents.push(this.events[frame]);
|
|
||||||
};
|
|
||||||
return EventTimeline;
|
|
||||||
}());
|
|
||||||
spine.EventTimeline = EventTimeline;
|
|
||||||
var DrawOrderTimeline = (function () {
|
|
||||||
function DrawOrderTimeline(frameCount) {
|
|
||||||
this.frames = spine.Utils.newFloatArray(frameCount);
|
|
||||||
this.drawOrders = new Array(frameCount);
|
|
||||||
}
|
|
||||||
DrawOrderTimeline.prototype.getPropertyId = function () {
|
|
||||||
return TimelineType.drawOrder << 24;
|
|
||||||
};
|
|
||||||
DrawOrderTimeline.prototype.getFrameCount = function () {
|
|
||||||
return this.frames.length;
|
|
||||||
};
|
|
||||||
DrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) {
|
|
||||||
this.frames[frameIndex] = time;
|
|
||||||
this.drawOrders[frameIndex] = drawOrder;
|
|
||||||
};
|
|
||||||
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
|
||||||
if (mixingOut && setupPose) {
|
|
||||||
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var frames = this.frames;
|
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var frame = 0;
|
|
||||||
if (time >= frames[frames.length - 1])
|
|
||||||
frame = frames.length - 1;
|
|
||||||
else
|
|
||||||
frame = Animation.binarySearch(frames, time) - 1;
|
|
||||||
var drawOrder = skeleton.drawOrder;
|
|
||||||
var slots = skeleton.slots;
|
|
||||||
var drawOrderToSetupIndex = this.drawOrders[frame];
|
|
||||||
if (drawOrderToSetupIndex == null)
|
|
||||||
spine.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length);
|
|
||||||
else {
|
|
||||||
for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++)
|
|
||||||
drawOrder[i] = slots[drawOrderToSetupIndex[i]];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return DrawOrderTimeline;
|
|
||||||
}());
|
|
||||||
spine.DrawOrderTimeline = DrawOrderTimeline;
|
|
||||||
var DeformTimeline = (function (_super) {
|
var DeformTimeline = (function (_super) {
|
||||||
__extends(DeformTimeline, _super);
|
__extends(DeformTimeline, _super);
|
||||||
function DeformTimeline(frameCount) {
|
function DeformTimeline(frameCount) {
|
||||||
@ -908,11 +847,14 @@ var spine;
|
|||||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
||||||
return;
|
return;
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
var verticesArray = slot.attachmentVertices;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
spine.Utils.setArraySize(verticesArray, 0);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
var frameVertices = this.frameVertices;
|
var frameVertices = this.frameVertices;
|
||||||
var vertexCount = frameVertices[0].length;
|
var vertexCount = frameVertices[0].length;
|
||||||
var verticesArray = slot.attachmentVertices;
|
|
||||||
if (verticesArray.length != vertexCount)
|
if (verticesArray.length != vertexCount)
|
||||||
alpha = 1;
|
alpha = 1;
|
||||||
var vertices = spine.Utils.setArraySize(verticesArray, vertexCount);
|
var vertices = spine.Utils.setArraySize(verticesArray, vertexCount);
|
||||||
@ -978,6 +920,96 @@ var spine;
|
|||||||
return DeformTimeline;
|
return DeformTimeline;
|
||||||
}(CurveTimeline));
|
}(CurveTimeline));
|
||||||
spine.DeformTimeline = DeformTimeline;
|
spine.DeformTimeline = DeformTimeline;
|
||||||
|
var EventTimeline = (function () {
|
||||||
|
function EventTimeline(frameCount) {
|
||||||
|
this.frames = spine.Utils.newFloatArray(frameCount);
|
||||||
|
this.events = new Array(frameCount);
|
||||||
|
}
|
||||||
|
EventTimeline.prototype.getPropertyId = function () {
|
||||||
|
return TimelineType.event << 24;
|
||||||
|
};
|
||||||
|
EventTimeline.prototype.getFrameCount = function () {
|
||||||
|
return this.frames.length;
|
||||||
|
};
|
||||||
|
EventTimeline.prototype.setFrame = function (frameIndex, event) {
|
||||||
|
this.frames[frameIndex] = event.time;
|
||||||
|
this.events[frameIndex] = event;
|
||||||
|
};
|
||||||
|
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
|
if (firedEvents == null)
|
||||||
|
return;
|
||||||
|
var frames = this.frames;
|
||||||
|
var frameCount = this.frames.length;
|
||||||
|
if (lastTime > time) {
|
||||||
|
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, setupPose, mixingOut);
|
||||||
|
lastTime = -1;
|
||||||
|
}
|
||||||
|
else if (lastTime >= frames[frameCount - 1])
|
||||||
|
return;
|
||||||
|
if (time < frames[0])
|
||||||
|
return;
|
||||||
|
var frame = 0;
|
||||||
|
if (lastTime < frames[0])
|
||||||
|
frame = 0;
|
||||||
|
else {
|
||||||
|
frame = Animation.binarySearch(frames, lastTime);
|
||||||
|
var frameTime = frames[frame];
|
||||||
|
while (frame > 0) {
|
||||||
|
if (frames[frame - 1] != frameTime)
|
||||||
|
break;
|
||||||
|
frame--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (; frame < frameCount && time >= frames[frame]; frame++)
|
||||||
|
firedEvents.push(this.events[frame]);
|
||||||
|
};
|
||||||
|
return EventTimeline;
|
||||||
|
}());
|
||||||
|
spine.EventTimeline = EventTimeline;
|
||||||
|
var DrawOrderTimeline = (function () {
|
||||||
|
function DrawOrderTimeline(frameCount) {
|
||||||
|
this.frames = spine.Utils.newFloatArray(frameCount);
|
||||||
|
this.drawOrders = new Array(frameCount);
|
||||||
|
}
|
||||||
|
DrawOrderTimeline.prototype.getPropertyId = function () {
|
||||||
|
return TimelineType.drawOrder << 24;
|
||||||
|
};
|
||||||
|
DrawOrderTimeline.prototype.getFrameCount = function () {
|
||||||
|
return this.frames.length;
|
||||||
|
};
|
||||||
|
DrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) {
|
||||||
|
this.frames[frameIndex] = time;
|
||||||
|
this.drawOrders[frameIndex] = drawOrder;
|
||||||
|
};
|
||||||
|
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
|
var drawOrder = skeleton.drawOrder;
|
||||||
|
var slots = skeleton.slots;
|
||||||
|
if (mixingOut && setupPose) {
|
||||||
|
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var frames = this.frames;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var frame = 0;
|
||||||
|
if (time >= frames[frames.length - 1])
|
||||||
|
frame = frames.length - 1;
|
||||||
|
else
|
||||||
|
frame = Animation.binarySearch(frames, time) - 1;
|
||||||
|
var drawOrderToSetupIndex = this.drawOrders[frame];
|
||||||
|
if (drawOrderToSetupIndex == null)
|
||||||
|
spine.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length);
|
||||||
|
else {
|
||||||
|
for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++)
|
||||||
|
drawOrder[i] = slots[drawOrderToSetupIndex[i]];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return DrawOrderTimeline;
|
||||||
|
}());
|
||||||
|
spine.DrawOrderTimeline = DrawOrderTimeline;
|
||||||
var IkConstraintTimeline = (function (_super) {
|
var IkConstraintTimeline = (function (_super) {
|
||||||
__extends(IkConstraintTimeline, _super);
|
__extends(IkConstraintTimeline, _super);
|
||||||
function IkConstraintTimeline(frameCount) {
|
function IkConstraintTimeline(frameCount) {
|
||||||
@ -995,9 +1027,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
|
var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint.mix = constraint.data.mix;
|
||||||
|
constraint.bendDirection = constraint.data.bendDirection;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
|
||||||
if (setupPose) {
|
if (setupPose) {
|
||||||
constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
|
constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
|
||||||
@ -1053,9 +1090,17 @@ var spine;
|
|||||||
};
|
};
|
||||||
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
|
var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
var data = constraint.data;
|
||||||
|
constraint.rotateMix = data.rotateMix;
|
||||||
|
constraint.translateMix = data.rotateMix;
|
||||||
|
constraint.scaleMix = data.scaleMix;
|
||||||
|
constraint.shearMix = data.shearMix;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var rotate = 0, translate = 0, scale = 0, shear = 0;
|
var rotate = 0, translate = 0, scale = 0, shear = 0;
|
||||||
if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) {
|
||||||
var i = frames.length;
|
var i = frames.length;
|
||||||
@ -1120,9 +1165,12 @@ var spine;
|
|||||||
};
|
};
|
||||||
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
constraint.position = constraint.data.position;
|
||||||
|
return;
|
||||||
|
}
|
||||||
var position = 0;
|
var position = 0;
|
||||||
if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES])
|
if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES])
|
||||||
position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE];
|
position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE];
|
||||||
@ -1155,9 +1203,12 @@ var spine;
|
|||||||
};
|
};
|
||||||
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
constraint.spacing = constraint.data.spacing;
|
||||||
|
return;
|
||||||
|
}
|
||||||
var spacing = 0;
|
var spacing = 0;
|
||||||
if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES])
|
if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES])
|
||||||
spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE];
|
spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE];
|
||||||
@ -1193,9 +1244,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint.rotateMix = constraint.data.rotateMix;
|
||||||
|
constraint.translateMix = constraint.data.translateMix;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var rotate = 0, translate = 0;
|
var rotate = 0, translate = 0;
|
||||||
if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) {
|
||||||
rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE];
|
rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE];
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
20
spine-ts/build/spine-core.d.ts
vendored
20
spine-ts/build/spine-core.d.ts
vendored
@ -108,6 +108,16 @@ declare module spine {
|
|||||||
setFrame(frameIndex: number, time: number, attachmentName: string): void;
|
setFrame(frameIndex: number, time: number, attachmentName: string): void;
|
||||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||||
}
|
}
|
||||||
|
class DeformTimeline extends CurveTimeline {
|
||||||
|
slotIndex: number;
|
||||||
|
attachment: VertexAttachment;
|
||||||
|
frames: ArrayLike<number>;
|
||||||
|
frameVertices: Array<ArrayLike<number>>;
|
||||||
|
constructor(frameCount: number);
|
||||||
|
getPropertyId(): number;
|
||||||
|
setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
|
||||||
|
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||||
|
}
|
||||||
class EventTimeline implements Timeline {
|
class EventTimeline implements Timeline {
|
||||||
frames: ArrayLike<number>;
|
frames: ArrayLike<number>;
|
||||||
events: Array<Event>;
|
events: Array<Event>;
|
||||||
@ -126,16 +136,6 @@ declare module spine {
|
|||||||
setFrame(frameIndex: number, time: number, drawOrder: Array<number>): void;
|
setFrame(frameIndex: number, time: number, drawOrder: Array<number>): void;
|
||||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||||
}
|
}
|
||||||
class DeformTimeline extends CurveTimeline {
|
|
||||||
slotIndex: number;
|
|
||||||
attachment: VertexAttachment;
|
|
||||||
frames: ArrayLike<number>;
|
|
||||||
frameVertices: Array<ArrayLike<number>>;
|
|
||||||
constructor(frameCount: number);
|
|
||||||
getPropertyId(): number;
|
|
||||||
setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
|
|
||||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
|
||||||
}
|
|
||||||
class IkConstraintTimeline extends CurveTimeline {
|
class IkConstraintTimeline extends CurveTimeline {
|
||||||
static ENTRIES: number;
|
static ENTRIES: number;
|
||||||
static PREV_TIME: number;
|
static PREV_TIME: number;
|
||||||
|
|||||||
@ -168,9 +168,12 @@ var spine;
|
|||||||
};
|
};
|
||||||
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
bone.rotation = bone.data.rotation;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
|
||||||
if (setupPose)
|
if (setupPose)
|
||||||
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha;
|
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha;
|
||||||
@ -222,9 +225,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.x = bone.data.x;
|
||||||
|
bone.y = bone.data.y;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var x = 0, y = 0;
|
var x = 0, y = 0;
|
||||||
if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) {
|
||||||
x = frames[frames.length + TranslateTimeline.PREV_X];
|
x = frames[frames.length + TranslateTimeline.PREV_X];
|
||||||
@ -267,9 +275,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.scaleX = bone.data.scaleX;
|
||||||
|
bone.scaleY = bone.data.scaleY;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var x = 0, y = 0;
|
var x = 0, y = 0;
|
||||||
if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) {
|
||||||
x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX;
|
x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX;
|
||||||
@ -323,9 +336,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.shearX = bone.data.shearX;
|
||||||
|
bone.shearY = bone.data.shearY;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var x = 0, y = 0;
|
var x = 0, y = 0;
|
||||||
if (time >= frames[frames.length - ShearTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - ShearTimeline.ENTRIES]) {
|
||||||
x = frames[frames.length + ShearTimeline.PREV_X];
|
x = frames[frames.length + ShearTimeline.PREV_X];
|
||||||
@ -370,9 +388,13 @@ var spine;
|
|||||||
this.frames[frameIndex + ColorTimeline.A] = a;
|
this.frames[frameIndex + ColorTimeline.A] = a;
|
||||||
};
|
};
|
||||||
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
|
var slot = skeleton.slots[this.slotIndex];
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
slot.color.setFromColor(slot.data.color);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
var r = 0, g = 0, b = 0, a = 0;
|
var r = 0, g = 0, b = 0, a = 0;
|
||||||
if (time >= frames[frames.length - ColorTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - ColorTimeline.ENTRIES]) {
|
||||||
var i = frames.length;
|
var i = frames.length;
|
||||||
@ -394,7 +416,6 @@ var spine;
|
|||||||
b += (frames[frame + ColorTimeline.B] - b) * percent;
|
b += (frames[frame + ColorTimeline.B] - b) * percent;
|
||||||
a += (frames[frame + ColorTimeline.A] - a) * percent;
|
a += (frames[frame + ColorTimeline.A] - a) * percent;
|
||||||
}
|
}
|
||||||
var slot = skeleton.slots[this.slotIndex];
|
|
||||||
if (alpha == 1)
|
if (alpha == 1)
|
||||||
slot.color.set(r, g, b, a);
|
slot.color.set(r, g, b, a);
|
||||||
else {
|
else {
|
||||||
@ -433,15 +454,20 @@ var spine;
|
|||||||
this.attachmentNames[frameIndex] = attachmentName;
|
this.attachmentNames[frameIndex] = attachmentName;
|
||||||
};
|
};
|
||||||
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
|
var slot = skeleton.slots[this.slotIndex];
|
||||||
if (mixingOut && setupPose) {
|
if (mixingOut && setupPose) {
|
||||||
var slot = skeleton.slots[this.slotIndex];
|
|
||||||
var attachmentName_1 = slot.data.attachmentName;
|
var attachmentName_1 = slot.data.attachmentName;
|
||||||
slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1));
|
slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
var attachmentName_2 = slot.data.attachmentName;
|
||||||
|
slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
var frameIndex = 0;
|
var frameIndex = 0;
|
||||||
if (time >= frames[frames.length - 1])
|
if (time >= frames[frames.length - 1])
|
||||||
frameIndex = frames.length - 1;
|
frameIndex = frames.length - 1;
|
||||||
@ -454,93 +480,6 @@ var spine;
|
|||||||
return AttachmentTimeline;
|
return AttachmentTimeline;
|
||||||
}());
|
}());
|
||||||
spine.AttachmentTimeline = AttachmentTimeline;
|
spine.AttachmentTimeline = AttachmentTimeline;
|
||||||
var EventTimeline = (function () {
|
|
||||||
function EventTimeline(frameCount) {
|
|
||||||
this.frames = spine.Utils.newFloatArray(frameCount);
|
|
||||||
this.events = new Array(frameCount);
|
|
||||||
}
|
|
||||||
EventTimeline.prototype.getPropertyId = function () {
|
|
||||||
return TimelineType.event << 24;
|
|
||||||
};
|
|
||||||
EventTimeline.prototype.getFrameCount = function () {
|
|
||||||
return this.frames.length;
|
|
||||||
};
|
|
||||||
EventTimeline.prototype.setFrame = function (frameIndex, event) {
|
|
||||||
this.frames[frameIndex] = event.time;
|
|
||||||
this.events[frameIndex] = event;
|
|
||||||
};
|
|
||||||
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
|
||||||
if (firedEvents == null)
|
|
||||||
return;
|
|
||||||
var frames = this.frames;
|
|
||||||
var frameCount = this.frames.length;
|
|
||||||
if (lastTime > time) {
|
|
||||||
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, setupPose, mixingOut);
|
|
||||||
lastTime = -1;
|
|
||||||
}
|
|
||||||
else if (lastTime >= frames[frameCount - 1])
|
|
||||||
return;
|
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var frame = 0;
|
|
||||||
if (lastTime < frames[0])
|
|
||||||
frame = 0;
|
|
||||||
else {
|
|
||||||
frame = Animation.binarySearch(frames, lastTime);
|
|
||||||
var frameTime = frames[frame];
|
|
||||||
while (frame > 0) {
|
|
||||||
if (frames[frame - 1] != frameTime)
|
|
||||||
break;
|
|
||||||
frame--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (; frame < frameCount && time >= frames[frame]; frame++)
|
|
||||||
firedEvents.push(this.events[frame]);
|
|
||||||
};
|
|
||||||
return EventTimeline;
|
|
||||||
}());
|
|
||||||
spine.EventTimeline = EventTimeline;
|
|
||||||
var DrawOrderTimeline = (function () {
|
|
||||||
function DrawOrderTimeline(frameCount) {
|
|
||||||
this.frames = spine.Utils.newFloatArray(frameCount);
|
|
||||||
this.drawOrders = new Array(frameCount);
|
|
||||||
}
|
|
||||||
DrawOrderTimeline.prototype.getPropertyId = function () {
|
|
||||||
return TimelineType.drawOrder << 24;
|
|
||||||
};
|
|
||||||
DrawOrderTimeline.prototype.getFrameCount = function () {
|
|
||||||
return this.frames.length;
|
|
||||||
};
|
|
||||||
DrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) {
|
|
||||||
this.frames[frameIndex] = time;
|
|
||||||
this.drawOrders[frameIndex] = drawOrder;
|
|
||||||
};
|
|
||||||
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
|
||||||
if (mixingOut && setupPose) {
|
|
||||||
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var frames = this.frames;
|
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var frame = 0;
|
|
||||||
if (time >= frames[frames.length - 1])
|
|
||||||
frame = frames.length - 1;
|
|
||||||
else
|
|
||||||
frame = Animation.binarySearch(frames, time) - 1;
|
|
||||||
var drawOrder = skeleton.drawOrder;
|
|
||||||
var slots = skeleton.slots;
|
|
||||||
var drawOrderToSetupIndex = this.drawOrders[frame];
|
|
||||||
if (drawOrderToSetupIndex == null)
|
|
||||||
spine.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length);
|
|
||||||
else {
|
|
||||||
for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++)
|
|
||||||
drawOrder[i] = slots[drawOrderToSetupIndex[i]];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return DrawOrderTimeline;
|
|
||||||
}());
|
|
||||||
spine.DrawOrderTimeline = DrawOrderTimeline;
|
|
||||||
var DeformTimeline = (function (_super) {
|
var DeformTimeline = (function (_super) {
|
||||||
__extends(DeformTimeline, _super);
|
__extends(DeformTimeline, _super);
|
||||||
function DeformTimeline(frameCount) {
|
function DeformTimeline(frameCount) {
|
||||||
@ -561,11 +500,14 @@ var spine;
|
|||||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
||||||
return;
|
return;
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
var verticesArray = slot.attachmentVertices;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
spine.Utils.setArraySize(verticesArray, 0);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
var frameVertices = this.frameVertices;
|
var frameVertices = this.frameVertices;
|
||||||
var vertexCount = frameVertices[0].length;
|
var vertexCount = frameVertices[0].length;
|
||||||
var verticesArray = slot.attachmentVertices;
|
|
||||||
if (verticesArray.length != vertexCount)
|
if (verticesArray.length != vertexCount)
|
||||||
alpha = 1;
|
alpha = 1;
|
||||||
var vertices = spine.Utils.setArraySize(verticesArray, vertexCount);
|
var vertices = spine.Utils.setArraySize(verticesArray, vertexCount);
|
||||||
@ -631,6 +573,96 @@ var spine;
|
|||||||
return DeformTimeline;
|
return DeformTimeline;
|
||||||
}(CurveTimeline));
|
}(CurveTimeline));
|
||||||
spine.DeformTimeline = DeformTimeline;
|
spine.DeformTimeline = DeformTimeline;
|
||||||
|
var EventTimeline = (function () {
|
||||||
|
function EventTimeline(frameCount) {
|
||||||
|
this.frames = spine.Utils.newFloatArray(frameCount);
|
||||||
|
this.events = new Array(frameCount);
|
||||||
|
}
|
||||||
|
EventTimeline.prototype.getPropertyId = function () {
|
||||||
|
return TimelineType.event << 24;
|
||||||
|
};
|
||||||
|
EventTimeline.prototype.getFrameCount = function () {
|
||||||
|
return this.frames.length;
|
||||||
|
};
|
||||||
|
EventTimeline.prototype.setFrame = function (frameIndex, event) {
|
||||||
|
this.frames[frameIndex] = event.time;
|
||||||
|
this.events[frameIndex] = event;
|
||||||
|
};
|
||||||
|
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
|
if (firedEvents == null)
|
||||||
|
return;
|
||||||
|
var frames = this.frames;
|
||||||
|
var frameCount = this.frames.length;
|
||||||
|
if (lastTime > time) {
|
||||||
|
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, setupPose, mixingOut);
|
||||||
|
lastTime = -1;
|
||||||
|
}
|
||||||
|
else if (lastTime >= frames[frameCount - 1])
|
||||||
|
return;
|
||||||
|
if (time < frames[0])
|
||||||
|
return;
|
||||||
|
var frame = 0;
|
||||||
|
if (lastTime < frames[0])
|
||||||
|
frame = 0;
|
||||||
|
else {
|
||||||
|
frame = Animation.binarySearch(frames, lastTime);
|
||||||
|
var frameTime = frames[frame];
|
||||||
|
while (frame > 0) {
|
||||||
|
if (frames[frame - 1] != frameTime)
|
||||||
|
break;
|
||||||
|
frame--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (; frame < frameCount && time >= frames[frame]; frame++)
|
||||||
|
firedEvents.push(this.events[frame]);
|
||||||
|
};
|
||||||
|
return EventTimeline;
|
||||||
|
}());
|
||||||
|
spine.EventTimeline = EventTimeline;
|
||||||
|
var DrawOrderTimeline = (function () {
|
||||||
|
function DrawOrderTimeline(frameCount) {
|
||||||
|
this.frames = spine.Utils.newFloatArray(frameCount);
|
||||||
|
this.drawOrders = new Array(frameCount);
|
||||||
|
}
|
||||||
|
DrawOrderTimeline.prototype.getPropertyId = function () {
|
||||||
|
return TimelineType.drawOrder << 24;
|
||||||
|
};
|
||||||
|
DrawOrderTimeline.prototype.getFrameCount = function () {
|
||||||
|
return this.frames.length;
|
||||||
|
};
|
||||||
|
DrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) {
|
||||||
|
this.frames[frameIndex] = time;
|
||||||
|
this.drawOrders[frameIndex] = drawOrder;
|
||||||
|
};
|
||||||
|
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
|
var drawOrder = skeleton.drawOrder;
|
||||||
|
var slots = skeleton.slots;
|
||||||
|
if (mixingOut && setupPose) {
|
||||||
|
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var frames = this.frames;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var frame = 0;
|
||||||
|
if (time >= frames[frames.length - 1])
|
||||||
|
frame = frames.length - 1;
|
||||||
|
else
|
||||||
|
frame = Animation.binarySearch(frames, time) - 1;
|
||||||
|
var drawOrderToSetupIndex = this.drawOrders[frame];
|
||||||
|
if (drawOrderToSetupIndex == null)
|
||||||
|
spine.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length);
|
||||||
|
else {
|
||||||
|
for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++)
|
||||||
|
drawOrder[i] = slots[drawOrderToSetupIndex[i]];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return DrawOrderTimeline;
|
||||||
|
}());
|
||||||
|
spine.DrawOrderTimeline = DrawOrderTimeline;
|
||||||
var IkConstraintTimeline = (function (_super) {
|
var IkConstraintTimeline = (function (_super) {
|
||||||
__extends(IkConstraintTimeline, _super);
|
__extends(IkConstraintTimeline, _super);
|
||||||
function IkConstraintTimeline(frameCount) {
|
function IkConstraintTimeline(frameCount) {
|
||||||
@ -648,9 +680,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
|
var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint.mix = constraint.data.mix;
|
||||||
|
constraint.bendDirection = constraint.data.bendDirection;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
|
||||||
if (setupPose) {
|
if (setupPose) {
|
||||||
constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
|
constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
|
||||||
@ -706,9 +743,17 @@ var spine;
|
|||||||
};
|
};
|
||||||
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
|
var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
var data = constraint.data;
|
||||||
|
constraint.rotateMix = data.rotateMix;
|
||||||
|
constraint.translateMix = data.rotateMix;
|
||||||
|
constraint.scaleMix = data.scaleMix;
|
||||||
|
constraint.shearMix = data.shearMix;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var rotate = 0, translate = 0, scale = 0, shear = 0;
|
var rotate = 0, translate = 0, scale = 0, shear = 0;
|
||||||
if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) {
|
||||||
var i = frames.length;
|
var i = frames.length;
|
||||||
@ -773,9 +818,12 @@ var spine;
|
|||||||
};
|
};
|
||||||
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
constraint.position = constraint.data.position;
|
||||||
|
return;
|
||||||
|
}
|
||||||
var position = 0;
|
var position = 0;
|
||||||
if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES])
|
if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES])
|
||||||
position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE];
|
position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE];
|
||||||
@ -808,9 +856,12 @@ var spine;
|
|||||||
};
|
};
|
||||||
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
constraint.spacing = constraint.data.spacing;
|
||||||
|
return;
|
||||||
|
}
|
||||||
var spacing = 0;
|
var spacing = 0;
|
||||||
if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES])
|
if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES])
|
||||||
spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE];
|
spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE];
|
||||||
@ -846,9 +897,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint.rotateMix = constraint.data.rotateMix;
|
||||||
|
constraint.translateMix = constraint.data.translateMix;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var rotate = 0, translate = 0;
|
var rotate = 0, translate = 0;
|
||||||
if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) {
|
||||||
rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE];
|
rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE];
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
20
spine-ts/build/spine-threejs.d.ts
vendored
20
spine-ts/build/spine-threejs.d.ts
vendored
@ -108,6 +108,16 @@ declare module spine {
|
|||||||
setFrame(frameIndex: number, time: number, attachmentName: string): void;
|
setFrame(frameIndex: number, time: number, attachmentName: string): void;
|
||||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||||
}
|
}
|
||||||
|
class DeformTimeline extends CurveTimeline {
|
||||||
|
slotIndex: number;
|
||||||
|
attachment: VertexAttachment;
|
||||||
|
frames: ArrayLike<number>;
|
||||||
|
frameVertices: Array<ArrayLike<number>>;
|
||||||
|
constructor(frameCount: number);
|
||||||
|
getPropertyId(): number;
|
||||||
|
setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
|
||||||
|
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||||
|
}
|
||||||
class EventTimeline implements Timeline {
|
class EventTimeline implements Timeline {
|
||||||
frames: ArrayLike<number>;
|
frames: ArrayLike<number>;
|
||||||
events: Array<Event>;
|
events: Array<Event>;
|
||||||
@ -126,16 +136,6 @@ declare module spine {
|
|||||||
setFrame(frameIndex: number, time: number, drawOrder: Array<number>): void;
|
setFrame(frameIndex: number, time: number, drawOrder: Array<number>): void;
|
||||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||||
}
|
}
|
||||||
class DeformTimeline extends CurveTimeline {
|
|
||||||
slotIndex: number;
|
|
||||||
attachment: VertexAttachment;
|
|
||||||
frames: ArrayLike<number>;
|
|
||||||
frameVertices: Array<ArrayLike<number>>;
|
|
||||||
constructor(frameCount: number);
|
|
||||||
getPropertyId(): number;
|
|
||||||
setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
|
|
||||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
|
||||||
}
|
|
||||||
class IkConstraintTimeline extends CurveTimeline {
|
class IkConstraintTimeline extends CurveTimeline {
|
||||||
static ENTRIES: number;
|
static ENTRIES: number;
|
||||||
static PREV_TIME: number;
|
static PREV_TIME: number;
|
||||||
|
|||||||
@ -168,9 +168,12 @@ var spine;
|
|||||||
};
|
};
|
||||||
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
bone.rotation = bone.data.rotation;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
|
||||||
if (setupPose)
|
if (setupPose)
|
||||||
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha;
|
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha;
|
||||||
@ -222,9 +225,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.x = bone.data.x;
|
||||||
|
bone.y = bone.data.y;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var x = 0, y = 0;
|
var x = 0, y = 0;
|
||||||
if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) {
|
||||||
x = frames[frames.length + TranslateTimeline.PREV_X];
|
x = frames[frames.length + TranslateTimeline.PREV_X];
|
||||||
@ -267,9 +275,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.scaleX = bone.data.scaleX;
|
||||||
|
bone.scaleY = bone.data.scaleY;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var x = 0, y = 0;
|
var x = 0, y = 0;
|
||||||
if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) {
|
||||||
x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX;
|
x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX;
|
||||||
@ -323,9 +336,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.shearX = bone.data.shearX;
|
||||||
|
bone.shearY = bone.data.shearY;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var x = 0, y = 0;
|
var x = 0, y = 0;
|
||||||
if (time >= frames[frames.length - ShearTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - ShearTimeline.ENTRIES]) {
|
||||||
x = frames[frames.length + ShearTimeline.PREV_X];
|
x = frames[frames.length + ShearTimeline.PREV_X];
|
||||||
@ -370,9 +388,13 @@ var spine;
|
|||||||
this.frames[frameIndex + ColorTimeline.A] = a;
|
this.frames[frameIndex + ColorTimeline.A] = a;
|
||||||
};
|
};
|
||||||
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
|
var slot = skeleton.slots[this.slotIndex];
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
slot.color.setFromColor(slot.data.color);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
var r = 0, g = 0, b = 0, a = 0;
|
var r = 0, g = 0, b = 0, a = 0;
|
||||||
if (time >= frames[frames.length - ColorTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - ColorTimeline.ENTRIES]) {
|
||||||
var i = frames.length;
|
var i = frames.length;
|
||||||
@ -394,7 +416,6 @@ var spine;
|
|||||||
b += (frames[frame + ColorTimeline.B] - b) * percent;
|
b += (frames[frame + ColorTimeline.B] - b) * percent;
|
||||||
a += (frames[frame + ColorTimeline.A] - a) * percent;
|
a += (frames[frame + ColorTimeline.A] - a) * percent;
|
||||||
}
|
}
|
||||||
var slot = skeleton.slots[this.slotIndex];
|
|
||||||
if (alpha == 1)
|
if (alpha == 1)
|
||||||
slot.color.set(r, g, b, a);
|
slot.color.set(r, g, b, a);
|
||||||
else {
|
else {
|
||||||
@ -433,15 +454,20 @@ var spine;
|
|||||||
this.attachmentNames[frameIndex] = attachmentName;
|
this.attachmentNames[frameIndex] = attachmentName;
|
||||||
};
|
};
|
||||||
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
|
var slot = skeleton.slots[this.slotIndex];
|
||||||
if (mixingOut && setupPose) {
|
if (mixingOut && setupPose) {
|
||||||
var slot = skeleton.slots[this.slotIndex];
|
|
||||||
var attachmentName_1 = slot.data.attachmentName;
|
var attachmentName_1 = slot.data.attachmentName;
|
||||||
slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1));
|
slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
var attachmentName_2 = slot.data.attachmentName;
|
||||||
|
slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
var frameIndex = 0;
|
var frameIndex = 0;
|
||||||
if (time >= frames[frames.length - 1])
|
if (time >= frames[frames.length - 1])
|
||||||
frameIndex = frames.length - 1;
|
frameIndex = frames.length - 1;
|
||||||
@ -454,93 +480,6 @@ var spine;
|
|||||||
return AttachmentTimeline;
|
return AttachmentTimeline;
|
||||||
}());
|
}());
|
||||||
spine.AttachmentTimeline = AttachmentTimeline;
|
spine.AttachmentTimeline = AttachmentTimeline;
|
||||||
var EventTimeline = (function () {
|
|
||||||
function EventTimeline(frameCount) {
|
|
||||||
this.frames = spine.Utils.newFloatArray(frameCount);
|
|
||||||
this.events = new Array(frameCount);
|
|
||||||
}
|
|
||||||
EventTimeline.prototype.getPropertyId = function () {
|
|
||||||
return TimelineType.event << 24;
|
|
||||||
};
|
|
||||||
EventTimeline.prototype.getFrameCount = function () {
|
|
||||||
return this.frames.length;
|
|
||||||
};
|
|
||||||
EventTimeline.prototype.setFrame = function (frameIndex, event) {
|
|
||||||
this.frames[frameIndex] = event.time;
|
|
||||||
this.events[frameIndex] = event;
|
|
||||||
};
|
|
||||||
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
|
||||||
if (firedEvents == null)
|
|
||||||
return;
|
|
||||||
var frames = this.frames;
|
|
||||||
var frameCount = this.frames.length;
|
|
||||||
if (lastTime > time) {
|
|
||||||
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, setupPose, mixingOut);
|
|
||||||
lastTime = -1;
|
|
||||||
}
|
|
||||||
else if (lastTime >= frames[frameCount - 1])
|
|
||||||
return;
|
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var frame = 0;
|
|
||||||
if (lastTime < frames[0])
|
|
||||||
frame = 0;
|
|
||||||
else {
|
|
||||||
frame = Animation.binarySearch(frames, lastTime);
|
|
||||||
var frameTime = frames[frame];
|
|
||||||
while (frame > 0) {
|
|
||||||
if (frames[frame - 1] != frameTime)
|
|
||||||
break;
|
|
||||||
frame--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (; frame < frameCount && time >= frames[frame]; frame++)
|
|
||||||
firedEvents.push(this.events[frame]);
|
|
||||||
};
|
|
||||||
return EventTimeline;
|
|
||||||
}());
|
|
||||||
spine.EventTimeline = EventTimeline;
|
|
||||||
var DrawOrderTimeline = (function () {
|
|
||||||
function DrawOrderTimeline(frameCount) {
|
|
||||||
this.frames = spine.Utils.newFloatArray(frameCount);
|
|
||||||
this.drawOrders = new Array(frameCount);
|
|
||||||
}
|
|
||||||
DrawOrderTimeline.prototype.getPropertyId = function () {
|
|
||||||
return TimelineType.drawOrder << 24;
|
|
||||||
};
|
|
||||||
DrawOrderTimeline.prototype.getFrameCount = function () {
|
|
||||||
return this.frames.length;
|
|
||||||
};
|
|
||||||
DrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) {
|
|
||||||
this.frames[frameIndex] = time;
|
|
||||||
this.drawOrders[frameIndex] = drawOrder;
|
|
||||||
};
|
|
||||||
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
|
||||||
if (mixingOut && setupPose) {
|
|
||||||
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var frames = this.frames;
|
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var frame = 0;
|
|
||||||
if (time >= frames[frames.length - 1])
|
|
||||||
frame = frames.length - 1;
|
|
||||||
else
|
|
||||||
frame = Animation.binarySearch(frames, time) - 1;
|
|
||||||
var drawOrder = skeleton.drawOrder;
|
|
||||||
var slots = skeleton.slots;
|
|
||||||
var drawOrderToSetupIndex = this.drawOrders[frame];
|
|
||||||
if (drawOrderToSetupIndex == null)
|
|
||||||
spine.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length);
|
|
||||||
else {
|
|
||||||
for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++)
|
|
||||||
drawOrder[i] = slots[drawOrderToSetupIndex[i]];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return DrawOrderTimeline;
|
|
||||||
}());
|
|
||||||
spine.DrawOrderTimeline = DrawOrderTimeline;
|
|
||||||
var DeformTimeline = (function (_super) {
|
var DeformTimeline = (function (_super) {
|
||||||
__extends(DeformTimeline, _super);
|
__extends(DeformTimeline, _super);
|
||||||
function DeformTimeline(frameCount) {
|
function DeformTimeline(frameCount) {
|
||||||
@ -561,11 +500,14 @@ var spine;
|
|||||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
||||||
return;
|
return;
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
var verticesArray = slot.attachmentVertices;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
spine.Utils.setArraySize(verticesArray, 0);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
var frameVertices = this.frameVertices;
|
var frameVertices = this.frameVertices;
|
||||||
var vertexCount = frameVertices[0].length;
|
var vertexCount = frameVertices[0].length;
|
||||||
var verticesArray = slot.attachmentVertices;
|
|
||||||
if (verticesArray.length != vertexCount)
|
if (verticesArray.length != vertexCount)
|
||||||
alpha = 1;
|
alpha = 1;
|
||||||
var vertices = spine.Utils.setArraySize(verticesArray, vertexCount);
|
var vertices = spine.Utils.setArraySize(verticesArray, vertexCount);
|
||||||
@ -631,6 +573,96 @@ var spine;
|
|||||||
return DeformTimeline;
|
return DeformTimeline;
|
||||||
}(CurveTimeline));
|
}(CurveTimeline));
|
||||||
spine.DeformTimeline = DeformTimeline;
|
spine.DeformTimeline = DeformTimeline;
|
||||||
|
var EventTimeline = (function () {
|
||||||
|
function EventTimeline(frameCount) {
|
||||||
|
this.frames = spine.Utils.newFloatArray(frameCount);
|
||||||
|
this.events = new Array(frameCount);
|
||||||
|
}
|
||||||
|
EventTimeline.prototype.getPropertyId = function () {
|
||||||
|
return TimelineType.event << 24;
|
||||||
|
};
|
||||||
|
EventTimeline.prototype.getFrameCount = function () {
|
||||||
|
return this.frames.length;
|
||||||
|
};
|
||||||
|
EventTimeline.prototype.setFrame = function (frameIndex, event) {
|
||||||
|
this.frames[frameIndex] = event.time;
|
||||||
|
this.events[frameIndex] = event;
|
||||||
|
};
|
||||||
|
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
|
if (firedEvents == null)
|
||||||
|
return;
|
||||||
|
var frames = this.frames;
|
||||||
|
var frameCount = this.frames.length;
|
||||||
|
if (lastTime > time) {
|
||||||
|
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, setupPose, mixingOut);
|
||||||
|
lastTime = -1;
|
||||||
|
}
|
||||||
|
else if (lastTime >= frames[frameCount - 1])
|
||||||
|
return;
|
||||||
|
if (time < frames[0])
|
||||||
|
return;
|
||||||
|
var frame = 0;
|
||||||
|
if (lastTime < frames[0])
|
||||||
|
frame = 0;
|
||||||
|
else {
|
||||||
|
frame = Animation.binarySearch(frames, lastTime);
|
||||||
|
var frameTime = frames[frame];
|
||||||
|
while (frame > 0) {
|
||||||
|
if (frames[frame - 1] != frameTime)
|
||||||
|
break;
|
||||||
|
frame--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (; frame < frameCount && time >= frames[frame]; frame++)
|
||||||
|
firedEvents.push(this.events[frame]);
|
||||||
|
};
|
||||||
|
return EventTimeline;
|
||||||
|
}());
|
||||||
|
spine.EventTimeline = EventTimeline;
|
||||||
|
var DrawOrderTimeline = (function () {
|
||||||
|
function DrawOrderTimeline(frameCount) {
|
||||||
|
this.frames = spine.Utils.newFloatArray(frameCount);
|
||||||
|
this.drawOrders = new Array(frameCount);
|
||||||
|
}
|
||||||
|
DrawOrderTimeline.prototype.getPropertyId = function () {
|
||||||
|
return TimelineType.drawOrder << 24;
|
||||||
|
};
|
||||||
|
DrawOrderTimeline.prototype.getFrameCount = function () {
|
||||||
|
return this.frames.length;
|
||||||
|
};
|
||||||
|
DrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) {
|
||||||
|
this.frames[frameIndex] = time;
|
||||||
|
this.drawOrders[frameIndex] = drawOrder;
|
||||||
|
};
|
||||||
|
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
|
var drawOrder = skeleton.drawOrder;
|
||||||
|
var slots = skeleton.slots;
|
||||||
|
if (mixingOut && setupPose) {
|
||||||
|
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var frames = this.frames;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var frame = 0;
|
||||||
|
if (time >= frames[frames.length - 1])
|
||||||
|
frame = frames.length - 1;
|
||||||
|
else
|
||||||
|
frame = Animation.binarySearch(frames, time) - 1;
|
||||||
|
var drawOrderToSetupIndex = this.drawOrders[frame];
|
||||||
|
if (drawOrderToSetupIndex == null)
|
||||||
|
spine.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length);
|
||||||
|
else {
|
||||||
|
for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++)
|
||||||
|
drawOrder[i] = slots[drawOrderToSetupIndex[i]];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return DrawOrderTimeline;
|
||||||
|
}());
|
||||||
|
spine.DrawOrderTimeline = DrawOrderTimeline;
|
||||||
var IkConstraintTimeline = (function (_super) {
|
var IkConstraintTimeline = (function (_super) {
|
||||||
__extends(IkConstraintTimeline, _super);
|
__extends(IkConstraintTimeline, _super);
|
||||||
function IkConstraintTimeline(frameCount) {
|
function IkConstraintTimeline(frameCount) {
|
||||||
@ -648,9 +680,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
|
var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint.mix = constraint.data.mix;
|
||||||
|
constraint.bendDirection = constraint.data.bendDirection;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
|
||||||
if (setupPose) {
|
if (setupPose) {
|
||||||
constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
|
constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
|
||||||
@ -706,9 +743,17 @@ var spine;
|
|||||||
};
|
};
|
||||||
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
|
var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
var data = constraint.data;
|
||||||
|
constraint.rotateMix = data.rotateMix;
|
||||||
|
constraint.translateMix = data.rotateMix;
|
||||||
|
constraint.scaleMix = data.scaleMix;
|
||||||
|
constraint.shearMix = data.shearMix;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var rotate = 0, translate = 0, scale = 0, shear = 0;
|
var rotate = 0, translate = 0, scale = 0, shear = 0;
|
||||||
if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) {
|
||||||
var i = frames.length;
|
var i = frames.length;
|
||||||
@ -773,9 +818,12 @@ var spine;
|
|||||||
};
|
};
|
||||||
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
constraint.position = constraint.data.position;
|
||||||
|
return;
|
||||||
|
}
|
||||||
var position = 0;
|
var position = 0;
|
||||||
if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES])
|
if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES])
|
||||||
position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE];
|
position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE];
|
||||||
@ -808,9 +856,12 @@ var spine;
|
|||||||
};
|
};
|
||||||
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
constraint.spacing = constraint.data.spacing;
|
||||||
|
return;
|
||||||
|
}
|
||||||
var spacing = 0;
|
var spacing = 0;
|
||||||
if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES])
|
if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES])
|
||||||
spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE];
|
spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE];
|
||||||
@ -846,9 +897,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint.rotateMix = constraint.data.rotateMix;
|
||||||
|
constraint.translateMix = constraint.data.translateMix;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var rotate = 0, translate = 0;
|
var rotate = 0, translate = 0;
|
||||||
if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) {
|
||||||
rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE];
|
rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE];
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
20
spine-ts/build/spine-webgl.d.ts
vendored
20
spine-ts/build/spine-webgl.d.ts
vendored
@ -108,6 +108,16 @@ declare module spine {
|
|||||||
setFrame(frameIndex: number, time: number, attachmentName: string): void;
|
setFrame(frameIndex: number, time: number, attachmentName: string): void;
|
||||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||||
}
|
}
|
||||||
|
class DeformTimeline extends CurveTimeline {
|
||||||
|
slotIndex: number;
|
||||||
|
attachment: VertexAttachment;
|
||||||
|
frames: ArrayLike<number>;
|
||||||
|
frameVertices: Array<ArrayLike<number>>;
|
||||||
|
constructor(frameCount: number);
|
||||||
|
getPropertyId(): number;
|
||||||
|
setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
|
||||||
|
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||||
|
}
|
||||||
class EventTimeline implements Timeline {
|
class EventTimeline implements Timeline {
|
||||||
frames: ArrayLike<number>;
|
frames: ArrayLike<number>;
|
||||||
events: Array<Event>;
|
events: Array<Event>;
|
||||||
@ -126,16 +136,6 @@ declare module spine {
|
|||||||
setFrame(frameIndex: number, time: number, drawOrder: Array<number>): void;
|
setFrame(frameIndex: number, time: number, drawOrder: Array<number>): void;
|
||||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||||
}
|
}
|
||||||
class DeformTimeline extends CurveTimeline {
|
|
||||||
slotIndex: number;
|
|
||||||
attachment: VertexAttachment;
|
|
||||||
frames: ArrayLike<number>;
|
|
||||||
frameVertices: Array<ArrayLike<number>>;
|
|
||||||
constructor(frameCount: number);
|
|
||||||
getPropertyId(): number;
|
|
||||||
setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
|
|
||||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
|
||||||
}
|
|
||||||
class IkConstraintTimeline extends CurveTimeline {
|
class IkConstraintTimeline extends CurveTimeline {
|
||||||
static ENTRIES: number;
|
static ENTRIES: number;
|
||||||
static PREV_TIME: number;
|
static PREV_TIME: number;
|
||||||
|
|||||||
@ -168,9 +168,12 @@ var spine;
|
|||||||
};
|
};
|
||||||
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
bone.rotation = bone.data.rotation;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
|
||||||
if (setupPose)
|
if (setupPose)
|
||||||
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha;
|
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha;
|
||||||
@ -222,9 +225,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.x = bone.data.x;
|
||||||
|
bone.y = bone.data.y;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var x = 0, y = 0;
|
var x = 0, y = 0;
|
||||||
if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) {
|
||||||
x = frames[frames.length + TranslateTimeline.PREV_X];
|
x = frames[frames.length + TranslateTimeline.PREV_X];
|
||||||
@ -267,9 +275,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.scaleX = bone.data.scaleX;
|
||||||
|
bone.scaleY = bone.data.scaleY;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var x = 0, y = 0;
|
var x = 0, y = 0;
|
||||||
if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) {
|
||||||
x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX;
|
x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX;
|
||||||
@ -323,9 +336,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.shearX = bone.data.shearX;
|
||||||
|
bone.shearY = bone.data.shearY;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var x = 0, y = 0;
|
var x = 0, y = 0;
|
||||||
if (time >= frames[frames.length - ShearTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - ShearTimeline.ENTRIES]) {
|
||||||
x = frames[frames.length + ShearTimeline.PREV_X];
|
x = frames[frames.length + ShearTimeline.PREV_X];
|
||||||
@ -370,9 +388,13 @@ var spine;
|
|||||||
this.frames[frameIndex + ColorTimeline.A] = a;
|
this.frames[frameIndex + ColorTimeline.A] = a;
|
||||||
};
|
};
|
||||||
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
|
var slot = skeleton.slots[this.slotIndex];
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
slot.color.setFromColor(slot.data.color);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
var r = 0, g = 0, b = 0, a = 0;
|
var r = 0, g = 0, b = 0, a = 0;
|
||||||
if (time >= frames[frames.length - ColorTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - ColorTimeline.ENTRIES]) {
|
||||||
var i = frames.length;
|
var i = frames.length;
|
||||||
@ -394,7 +416,6 @@ var spine;
|
|||||||
b += (frames[frame + ColorTimeline.B] - b) * percent;
|
b += (frames[frame + ColorTimeline.B] - b) * percent;
|
||||||
a += (frames[frame + ColorTimeline.A] - a) * percent;
|
a += (frames[frame + ColorTimeline.A] - a) * percent;
|
||||||
}
|
}
|
||||||
var slot = skeleton.slots[this.slotIndex];
|
|
||||||
if (alpha == 1)
|
if (alpha == 1)
|
||||||
slot.color.set(r, g, b, a);
|
slot.color.set(r, g, b, a);
|
||||||
else {
|
else {
|
||||||
@ -433,15 +454,20 @@ var spine;
|
|||||||
this.attachmentNames[frameIndex] = attachmentName;
|
this.attachmentNames[frameIndex] = attachmentName;
|
||||||
};
|
};
|
||||||
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
|
var slot = skeleton.slots[this.slotIndex];
|
||||||
if (mixingOut && setupPose) {
|
if (mixingOut && setupPose) {
|
||||||
var slot = skeleton.slots[this.slotIndex];
|
|
||||||
var attachmentName_1 = slot.data.attachmentName;
|
var attachmentName_1 = slot.data.attachmentName;
|
||||||
slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1));
|
slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
var attachmentName_2 = slot.data.attachmentName;
|
||||||
|
slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
var frameIndex = 0;
|
var frameIndex = 0;
|
||||||
if (time >= frames[frames.length - 1])
|
if (time >= frames[frames.length - 1])
|
||||||
frameIndex = frames.length - 1;
|
frameIndex = frames.length - 1;
|
||||||
@ -454,93 +480,6 @@ var spine;
|
|||||||
return AttachmentTimeline;
|
return AttachmentTimeline;
|
||||||
}());
|
}());
|
||||||
spine.AttachmentTimeline = AttachmentTimeline;
|
spine.AttachmentTimeline = AttachmentTimeline;
|
||||||
var EventTimeline = (function () {
|
|
||||||
function EventTimeline(frameCount) {
|
|
||||||
this.frames = spine.Utils.newFloatArray(frameCount);
|
|
||||||
this.events = new Array(frameCount);
|
|
||||||
}
|
|
||||||
EventTimeline.prototype.getPropertyId = function () {
|
|
||||||
return TimelineType.event << 24;
|
|
||||||
};
|
|
||||||
EventTimeline.prototype.getFrameCount = function () {
|
|
||||||
return this.frames.length;
|
|
||||||
};
|
|
||||||
EventTimeline.prototype.setFrame = function (frameIndex, event) {
|
|
||||||
this.frames[frameIndex] = event.time;
|
|
||||||
this.events[frameIndex] = event;
|
|
||||||
};
|
|
||||||
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
|
||||||
if (firedEvents == null)
|
|
||||||
return;
|
|
||||||
var frames = this.frames;
|
|
||||||
var frameCount = this.frames.length;
|
|
||||||
if (lastTime > time) {
|
|
||||||
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, setupPose, mixingOut);
|
|
||||||
lastTime = -1;
|
|
||||||
}
|
|
||||||
else if (lastTime >= frames[frameCount - 1])
|
|
||||||
return;
|
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var frame = 0;
|
|
||||||
if (lastTime < frames[0])
|
|
||||||
frame = 0;
|
|
||||||
else {
|
|
||||||
frame = Animation.binarySearch(frames, lastTime);
|
|
||||||
var frameTime = frames[frame];
|
|
||||||
while (frame > 0) {
|
|
||||||
if (frames[frame - 1] != frameTime)
|
|
||||||
break;
|
|
||||||
frame--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (; frame < frameCount && time >= frames[frame]; frame++)
|
|
||||||
firedEvents.push(this.events[frame]);
|
|
||||||
};
|
|
||||||
return EventTimeline;
|
|
||||||
}());
|
|
||||||
spine.EventTimeline = EventTimeline;
|
|
||||||
var DrawOrderTimeline = (function () {
|
|
||||||
function DrawOrderTimeline(frameCount) {
|
|
||||||
this.frames = spine.Utils.newFloatArray(frameCount);
|
|
||||||
this.drawOrders = new Array(frameCount);
|
|
||||||
}
|
|
||||||
DrawOrderTimeline.prototype.getPropertyId = function () {
|
|
||||||
return TimelineType.drawOrder << 24;
|
|
||||||
};
|
|
||||||
DrawOrderTimeline.prototype.getFrameCount = function () {
|
|
||||||
return this.frames.length;
|
|
||||||
};
|
|
||||||
DrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) {
|
|
||||||
this.frames[frameIndex] = time;
|
|
||||||
this.drawOrders[frameIndex] = drawOrder;
|
|
||||||
};
|
|
||||||
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
|
||||||
if (mixingOut && setupPose) {
|
|
||||||
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var frames = this.frames;
|
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var frame = 0;
|
|
||||||
if (time >= frames[frames.length - 1])
|
|
||||||
frame = frames.length - 1;
|
|
||||||
else
|
|
||||||
frame = Animation.binarySearch(frames, time) - 1;
|
|
||||||
var drawOrder = skeleton.drawOrder;
|
|
||||||
var slots = skeleton.slots;
|
|
||||||
var drawOrderToSetupIndex = this.drawOrders[frame];
|
|
||||||
if (drawOrderToSetupIndex == null)
|
|
||||||
spine.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length);
|
|
||||||
else {
|
|
||||||
for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++)
|
|
||||||
drawOrder[i] = slots[drawOrderToSetupIndex[i]];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return DrawOrderTimeline;
|
|
||||||
}());
|
|
||||||
spine.DrawOrderTimeline = DrawOrderTimeline;
|
|
||||||
var DeformTimeline = (function (_super) {
|
var DeformTimeline = (function (_super) {
|
||||||
__extends(DeformTimeline, _super);
|
__extends(DeformTimeline, _super);
|
||||||
function DeformTimeline(frameCount) {
|
function DeformTimeline(frameCount) {
|
||||||
@ -561,11 +500,14 @@ var spine;
|
|||||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
||||||
return;
|
return;
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
var verticesArray = slot.attachmentVertices;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
spine.Utils.setArraySize(verticesArray, 0);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
var frameVertices = this.frameVertices;
|
var frameVertices = this.frameVertices;
|
||||||
var vertexCount = frameVertices[0].length;
|
var vertexCount = frameVertices[0].length;
|
||||||
var verticesArray = slot.attachmentVertices;
|
|
||||||
if (verticesArray.length != vertexCount)
|
if (verticesArray.length != vertexCount)
|
||||||
alpha = 1;
|
alpha = 1;
|
||||||
var vertices = spine.Utils.setArraySize(verticesArray, vertexCount);
|
var vertices = spine.Utils.setArraySize(verticesArray, vertexCount);
|
||||||
@ -631,6 +573,96 @@ var spine;
|
|||||||
return DeformTimeline;
|
return DeformTimeline;
|
||||||
}(CurveTimeline));
|
}(CurveTimeline));
|
||||||
spine.DeformTimeline = DeformTimeline;
|
spine.DeformTimeline = DeformTimeline;
|
||||||
|
var EventTimeline = (function () {
|
||||||
|
function EventTimeline(frameCount) {
|
||||||
|
this.frames = spine.Utils.newFloatArray(frameCount);
|
||||||
|
this.events = new Array(frameCount);
|
||||||
|
}
|
||||||
|
EventTimeline.prototype.getPropertyId = function () {
|
||||||
|
return TimelineType.event << 24;
|
||||||
|
};
|
||||||
|
EventTimeline.prototype.getFrameCount = function () {
|
||||||
|
return this.frames.length;
|
||||||
|
};
|
||||||
|
EventTimeline.prototype.setFrame = function (frameIndex, event) {
|
||||||
|
this.frames[frameIndex] = event.time;
|
||||||
|
this.events[frameIndex] = event;
|
||||||
|
};
|
||||||
|
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
|
if (firedEvents == null)
|
||||||
|
return;
|
||||||
|
var frames = this.frames;
|
||||||
|
var frameCount = this.frames.length;
|
||||||
|
if (lastTime > time) {
|
||||||
|
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, setupPose, mixingOut);
|
||||||
|
lastTime = -1;
|
||||||
|
}
|
||||||
|
else if (lastTime >= frames[frameCount - 1])
|
||||||
|
return;
|
||||||
|
if (time < frames[0])
|
||||||
|
return;
|
||||||
|
var frame = 0;
|
||||||
|
if (lastTime < frames[0])
|
||||||
|
frame = 0;
|
||||||
|
else {
|
||||||
|
frame = Animation.binarySearch(frames, lastTime);
|
||||||
|
var frameTime = frames[frame];
|
||||||
|
while (frame > 0) {
|
||||||
|
if (frames[frame - 1] != frameTime)
|
||||||
|
break;
|
||||||
|
frame--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (; frame < frameCount && time >= frames[frame]; frame++)
|
||||||
|
firedEvents.push(this.events[frame]);
|
||||||
|
};
|
||||||
|
return EventTimeline;
|
||||||
|
}());
|
||||||
|
spine.EventTimeline = EventTimeline;
|
||||||
|
var DrawOrderTimeline = (function () {
|
||||||
|
function DrawOrderTimeline(frameCount) {
|
||||||
|
this.frames = spine.Utils.newFloatArray(frameCount);
|
||||||
|
this.drawOrders = new Array(frameCount);
|
||||||
|
}
|
||||||
|
DrawOrderTimeline.prototype.getPropertyId = function () {
|
||||||
|
return TimelineType.drawOrder << 24;
|
||||||
|
};
|
||||||
|
DrawOrderTimeline.prototype.getFrameCount = function () {
|
||||||
|
return this.frames.length;
|
||||||
|
};
|
||||||
|
DrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) {
|
||||||
|
this.frames[frameIndex] = time;
|
||||||
|
this.drawOrders[frameIndex] = drawOrder;
|
||||||
|
};
|
||||||
|
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
|
var drawOrder = skeleton.drawOrder;
|
||||||
|
var slots = skeleton.slots;
|
||||||
|
if (mixingOut && setupPose) {
|
||||||
|
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var frames = this.frames;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var frame = 0;
|
||||||
|
if (time >= frames[frames.length - 1])
|
||||||
|
frame = frames.length - 1;
|
||||||
|
else
|
||||||
|
frame = Animation.binarySearch(frames, time) - 1;
|
||||||
|
var drawOrderToSetupIndex = this.drawOrders[frame];
|
||||||
|
if (drawOrderToSetupIndex == null)
|
||||||
|
spine.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length);
|
||||||
|
else {
|
||||||
|
for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++)
|
||||||
|
drawOrder[i] = slots[drawOrderToSetupIndex[i]];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return DrawOrderTimeline;
|
||||||
|
}());
|
||||||
|
spine.DrawOrderTimeline = DrawOrderTimeline;
|
||||||
var IkConstraintTimeline = (function (_super) {
|
var IkConstraintTimeline = (function (_super) {
|
||||||
__extends(IkConstraintTimeline, _super);
|
__extends(IkConstraintTimeline, _super);
|
||||||
function IkConstraintTimeline(frameCount) {
|
function IkConstraintTimeline(frameCount) {
|
||||||
@ -648,9 +680,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
|
var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint.mix = constraint.data.mix;
|
||||||
|
constraint.bendDirection = constraint.data.bendDirection;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
|
||||||
if (setupPose) {
|
if (setupPose) {
|
||||||
constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
|
constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
|
||||||
@ -706,9 +743,17 @@ var spine;
|
|||||||
};
|
};
|
||||||
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
|
var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
var data = constraint.data;
|
||||||
|
constraint.rotateMix = data.rotateMix;
|
||||||
|
constraint.translateMix = data.rotateMix;
|
||||||
|
constraint.scaleMix = data.scaleMix;
|
||||||
|
constraint.shearMix = data.shearMix;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var rotate = 0, translate = 0, scale = 0, shear = 0;
|
var rotate = 0, translate = 0, scale = 0, shear = 0;
|
||||||
if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) {
|
||||||
var i = frames.length;
|
var i = frames.length;
|
||||||
@ -773,9 +818,12 @@ var spine;
|
|||||||
};
|
};
|
||||||
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
constraint.position = constraint.data.position;
|
||||||
|
return;
|
||||||
|
}
|
||||||
var position = 0;
|
var position = 0;
|
||||||
if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES])
|
if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES])
|
||||||
position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE];
|
position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE];
|
||||||
@ -808,9 +856,12 @@ var spine;
|
|||||||
};
|
};
|
||||||
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
constraint.spacing = constraint.data.spacing;
|
||||||
|
return;
|
||||||
|
}
|
||||||
var spacing = 0;
|
var spacing = 0;
|
||||||
if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES])
|
if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES])
|
||||||
spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE];
|
spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE];
|
||||||
@ -846,9 +897,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint.rotateMix = constraint.data.rotateMix;
|
||||||
|
constraint.translateMix = constraint.data.translateMix;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var rotate = 0, translate = 0;
|
var rotate = 0, translate = 0;
|
||||||
if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) {
|
||||||
rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE];
|
rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE];
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
20
spine-ts/build/spine-widget.d.ts
vendored
20
spine-ts/build/spine-widget.d.ts
vendored
@ -108,6 +108,16 @@ declare module spine {
|
|||||||
setFrame(frameIndex: number, time: number, attachmentName: string): void;
|
setFrame(frameIndex: number, time: number, attachmentName: string): void;
|
||||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||||
}
|
}
|
||||||
|
class DeformTimeline extends CurveTimeline {
|
||||||
|
slotIndex: number;
|
||||||
|
attachment: VertexAttachment;
|
||||||
|
frames: ArrayLike<number>;
|
||||||
|
frameVertices: Array<ArrayLike<number>>;
|
||||||
|
constructor(frameCount: number);
|
||||||
|
getPropertyId(): number;
|
||||||
|
setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
|
||||||
|
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||||
|
}
|
||||||
class EventTimeline implements Timeline {
|
class EventTimeline implements Timeline {
|
||||||
frames: ArrayLike<number>;
|
frames: ArrayLike<number>;
|
||||||
events: Array<Event>;
|
events: Array<Event>;
|
||||||
@ -126,16 +136,6 @@ declare module spine {
|
|||||||
setFrame(frameIndex: number, time: number, drawOrder: Array<number>): void;
|
setFrame(frameIndex: number, time: number, drawOrder: Array<number>): void;
|
||||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||||
}
|
}
|
||||||
class DeformTimeline extends CurveTimeline {
|
|
||||||
slotIndex: number;
|
|
||||||
attachment: VertexAttachment;
|
|
||||||
frames: ArrayLike<number>;
|
|
||||||
frameVertices: Array<ArrayLike<number>>;
|
|
||||||
constructor(frameCount: number);
|
|
||||||
getPropertyId(): number;
|
|
||||||
setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
|
|
||||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
|
||||||
}
|
|
||||||
class IkConstraintTimeline extends CurveTimeline {
|
class IkConstraintTimeline extends CurveTimeline {
|
||||||
static ENTRIES: number;
|
static ENTRIES: number;
|
||||||
static PREV_TIME: number;
|
static PREV_TIME: number;
|
||||||
|
|||||||
@ -168,9 +168,12 @@ var spine;
|
|||||||
};
|
};
|
||||||
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
bone.rotation = bone.data.rotation;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
|
||||||
if (setupPose)
|
if (setupPose)
|
||||||
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha;
|
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha;
|
||||||
@ -222,9 +225,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.x = bone.data.x;
|
||||||
|
bone.y = bone.data.y;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var x = 0, y = 0;
|
var x = 0, y = 0;
|
||||||
if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) {
|
||||||
x = frames[frames.length + TranslateTimeline.PREV_X];
|
x = frames[frames.length + TranslateTimeline.PREV_X];
|
||||||
@ -267,9 +275,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.scaleX = bone.data.scaleX;
|
||||||
|
bone.scaleY = bone.data.scaleY;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var x = 0, y = 0;
|
var x = 0, y = 0;
|
||||||
if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) {
|
||||||
x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX;
|
x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX;
|
||||||
@ -323,9 +336,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var bone = skeleton.bones[this.boneIndex];
|
var bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.shearX = bone.data.shearX;
|
||||||
|
bone.shearY = bone.data.shearY;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var x = 0, y = 0;
|
var x = 0, y = 0;
|
||||||
if (time >= frames[frames.length - ShearTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - ShearTimeline.ENTRIES]) {
|
||||||
x = frames[frames.length + ShearTimeline.PREV_X];
|
x = frames[frames.length + ShearTimeline.PREV_X];
|
||||||
@ -370,9 +388,13 @@ var spine;
|
|||||||
this.frames[frameIndex + ColorTimeline.A] = a;
|
this.frames[frameIndex + ColorTimeline.A] = a;
|
||||||
};
|
};
|
||||||
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
|
var slot = skeleton.slots[this.slotIndex];
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
slot.color.setFromColor(slot.data.color);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
var r = 0, g = 0, b = 0, a = 0;
|
var r = 0, g = 0, b = 0, a = 0;
|
||||||
if (time >= frames[frames.length - ColorTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - ColorTimeline.ENTRIES]) {
|
||||||
var i = frames.length;
|
var i = frames.length;
|
||||||
@ -394,7 +416,6 @@ var spine;
|
|||||||
b += (frames[frame + ColorTimeline.B] - b) * percent;
|
b += (frames[frame + ColorTimeline.B] - b) * percent;
|
||||||
a += (frames[frame + ColorTimeline.A] - a) * percent;
|
a += (frames[frame + ColorTimeline.A] - a) * percent;
|
||||||
}
|
}
|
||||||
var slot = skeleton.slots[this.slotIndex];
|
|
||||||
if (alpha == 1)
|
if (alpha == 1)
|
||||||
slot.color.set(r, g, b, a);
|
slot.color.set(r, g, b, a);
|
||||||
else {
|
else {
|
||||||
@ -433,15 +454,20 @@ var spine;
|
|||||||
this.attachmentNames[frameIndex] = attachmentName;
|
this.attachmentNames[frameIndex] = attachmentName;
|
||||||
};
|
};
|
||||||
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||||
|
var slot = skeleton.slots[this.slotIndex];
|
||||||
if (mixingOut && setupPose) {
|
if (mixingOut && setupPose) {
|
||||||
var slot = skeleton.slots[this.slotIndex];
|
|
||||||
var attachmentName_1 = slot.data.attachmentName;
|
var attachmentName_1 = slot.data.attachmentName;
|
||||||
slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1));
|
slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
var attachmentName_2 = slot.data.attachmentName;
|
||||||
|
slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
var frameIndex = 0;
|
var frameIndex = 0;
|
||||||
if (time >= frames[frames.length - 1])
|
if (time >= frames[frames.length - 1])
|
||||||
frameIndex = frames.length - 1;
|
frameIndex = frames.length - 1;
|
||||||
@ -454,93 +480,6 @@ var spine;
|
|||||||
return AttachmentTimeline;
|
return AttachmentTimeline;
|
||||||
}());
|
}());
|
||||||
spine.AttachmentTimeline = AttachmentTimeline;
|
spine.AttachmentTimeline = AttachmentTimeline;
|
||||||
var EventTimeline = (function () {
|
|
||||||
function EventTimeline(frameCount) {
|
|
||||||
this.frames = spine.Utils.newFloatArray(frameCount);
|
|
||||||
this.events = new Array(frameCount);
|
|
||||||
}
|
|
||||||
EventTimeline.prototype.getPropertyId = function () {
|
|
||||||
return TimelineType.event << 24;
|
|
||||||
};
|
|
||||||
EventTimeline.prototype.getFrameCount = function () {
|
|
||||||
return this.frames.length;
|
|
||||||
};
|
|
||||||
EventTimeline.prototype.setFrame = function (frameIndex, event) {
|
|
||||||
this.frames[frameIndex] = event.time;
|
|
||||||
this.events[frameIndex] = event;
|
|
||||||
};
|
|
||||||
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
|
||||||
if (firedEvents == null)
|
|
||||||
return;
|
|
||||||
var frames = this.frames;
|
|
||||||
var frameCount = this.frames.length;
|
|
||||||
if (lastTime > time) {
|
|
||||||
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, setupPose, mixingOut);
|
|
||||||
lastTime = -1;
|
|
||||||
}
|
|
||||||
else if (lastTime >= frames[frameCount - 1])
|
|
||||||
return;
|
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var frame = 0;
|
|
||||||
if (lastTime < frames[0])
|
|
||||||
frame = 0;
|
|
||||||
else {
|
|
||||||
frame = Animation.binarySearch(frames, lastTime);
|
|
||||||
var frameTime = frames[frame];
|
|
||||||
while (frame > 0) {
|
|
||||||
if (frames[frame - 1] != frameTime)
|
|
||||||
break;
|
|
||||||
frame--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (; frame < frameCount && time >= frames[frame]; frame++)
|
|
||||||
firedEvents.push(this.events[frame]);
|
|
||||||
};
|
|
||||||
return EventTimeline;
|
|
||||||
}());
|
|
||||||
spine.EventTimeline = EventTimeline;
|
|
||||||
var DrawOrderTimeline = (function () {
|
|
||||||
function DrawOrderTimeline(frameCount) {
|
|
||||||
this.frames = spine.Utils.newFloatArray(frameCount);
|
|
||||||
this.drawOrders = new Array(frameCount);
|
|
||||||
}
|
|
||||||
DrawOrderTimeline.prototype.getPropertyId = function () {
|
|
||||||
return TimelineType.drawOrder << 24;
|
|
||||||
};
|
|
||||||
DrawOrderTimeline.prototype.getFrameCount = function () {
|
|
||||||
return this.frames.length;
|
|
||||||
};
|
|
||||||
DrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) {
|
|
||||||
this.frames[frameIndex] = time;
|
|
||||||
this.drawOrders[frameIndex] = drawOrder;
|
|
||||||
};
|
|
||||||
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
|
||||||
if (mixingOut && setupPose) {
|
|
||||||
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var frames = this.frames;
|
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var frame = 0;
|
|
||||||
if (time >= frames[frames.length - 1])
|
|
||||||
frame = frames.length - 1;
|
|
||||||
else
|
|
||||||
frame = Animation.binarySearch(frames, time) - 1;
|
|
||||||
var drawOrder = skeleton.drawOrder;
|
|
||||||
var slots = skeleton.slots;
|
|
||||||
var drawOrderToSetupIndex = this.drawOrders[frame];
|
|
||||||
if (drawOrderToSetupIndex == null)
|
|
||||||
spine.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length);
|
|
||||||
else {
|
|
||||||
for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++)
|
|
||||||
drawOrder[i] = slots[drawOrderToSetupIndex[i]];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return DrawOrderTimeline;
|
|
||||||
}());
|
|
||||||
spine.DrawOrderTimeline = DrawOrderTimeline;
|
|
||||||
var DeformTimeline = (function (_super) {
|
var DeformTimeline = (function (_super) {
|
||||||
__extends(DeformTimeline, _super);
|
__extends(DeformTimeline, _super);
|
||||||
function DeformTimeline(frameCount) {
|
function DeformTimeline(frameCount) {
|
||||||
@ -561,11 +500,14 @@ var spine;
|
|||||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
||||||
return;
|
return;
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
var verticesArray = slot.attachmentVertices;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
spine.Utils.setArraySize(verticesArray, 0);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
var frameVertices = this.frameVertices;
|
var frameVertices = this.frameVertices;
|
||||||
var vertexCount = frameVertices[0].length;
|
var vertexCount = frameVertices[0].length;
|
||||||
var verticesArray = slot.attachmentVertices;
|
|
||||||
if (verticesArray.length != vertexCount)
|
if (verticesArray.length != vertexCount)
|
||||||
alpha = 1;
|
alpha = 1;
|
||||||
var vertices = spine.Utils.setArraySize(verticesArray, vertexCount);
|
var vertices = spine.Utils.setArraySize(verticesArray, vertexCount);
|
||||||
@ -631,6 +573,96 @@ var spine;
|
|||||||
return DeformTimeline;
|
return DeformTimeline;
|
||||||
}(CurveTimeline));
|
}(CurveTimeline));
|
||||||
spine.DeformTimeline = DeformTimeline;
|
spine.DeformTimeline = DeformTimeline;
|
||||||
|
var EventTimeline = (function () {
|
||||||
|
function EventTimeline(frameCount) {
|
||||||
|
this.frames = spine.Utils.newFloatArray(frameCount);
|
||||||
|
this.events = new Array(frameCount);
|
||||||
|
}
|
||||||
|
EventTimeline.prototype.getPropertyId = function () {
|
||||||
|
return TimelineType.event << 24;
|
||||||
|
};
|
||||||
|
EventTimeline.prototype.getFrameCount = function () {
|
||||||
|
return this.frames.length;
|
||||||
|
};
|
||||||
|
EventTimeline.prototype.setFrame = function (frameIndex, event) {
|
||||||
|
this.frames[frameIndex] = event.time;
|
||||||
|
this.events[frameIndex] = event;
|
||||||
|
};
|
||||||
|
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
|
if (firedEvents == null)
|
||||||
|
return;
|
||||||
|
var frames = this.frames;
|
||||||
|
var frameCount = this.frames.length;
|
||||||
|
if (lastTime > time) {
|
||||||
|
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, setupPose, mixingOut);
|
||||||
|
lastTime = -1;
|
||||||
|
}
|
||||||
|
else if (lastTime >= frames[frameCount - 1])
|
||||||
|
return;
|
||||||
|
if (time < frames[0])
|
||||||
|
return;
|
||||||
|
var frame = 0;
|
||||||
|
if (lastTime < frames[0])
|
||||||
|
frame = 0;
|
||||||
|
else {
|
||||||
|
frame = Animation.binarySearch(frames, lastTime);
|
||||||
|
var frameTime = frames[frame];
|
||||||
|
while (frame > 0) {
|
||||||
|
if (frames[frame - 1] != frameTime)
|
||||||
|
break;
|
||||||
|
frame--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (; frame < frameCount && time >= frames[frame]; frame++)
|
||||||
|
firedEvents.push(this.events[frame]);
|
||||||
|
};
|
||||||
|
return EventTimeline;
|
||||||
|
}());
|
||||||
|
spine.EventTimeline = EventTimeline;
|
||||||
|
var DrawOrderTimeline = (function () {
|
||||||
|
function DrawOrderTimeline(frameCount) {
|
||||||
|
this.frames = spine.Utils.newFloatArray(frameCount);
|
||||||
|
this.drawOrders = new Array(frameCount);
|
||||||
|
}
|
||||||
|
DrawOrderTimeline.prototype.getPropertyId = function () {
|
||||||
|
return TimelineType.drawOrder << 24;
|
||||||
|
};
|
||||||
|
DrawOrderTimeline.prototype.getFrameCount = function () {
|
||||||
|
return this.frames.length;
|
||||||
|
};
|
||||||
|
DrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) {
|
||||||
|
this.frames[frameIndex] = time;
|
||||||
|
this.drawOrders[frameIndex] = drawOrder;
|
||||||
|
};
|
||||||
|
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
|
var drawOrder = skeleton.drawOrder;
|
||||||
|
var slots = skeleton.slots;
|
||||||
|
if (mixingOut && setupPose) {
|
||||||
|
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var frames = this.frames;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var frame = 0;
|
||||||
|
if (time >= frames[frames.length - 1])
|
||||||
|
frame = frames.length - 1;
|
||||||
|
else
|
||||||
|
frame = Animation.binarySearch(frames, time) - 1;
|
||||||
|
var drawOrderToSetupIndex = this.drawOrders[frame];
|
||||||
|
if (drawOrderToSetupIndex == null)
|
||||||
|
spine.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length);
|
||||||
|
else {
|
||||||
|
for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++)
|
||||||
|
drawOrder[i] = slots[drawOrderToSetupIndex[i]];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return DrawOrderTimeline;
|
||||||
|
}());
|
||||||
|
spine.DrawOrderTimeline = DrawOrderTimeline;
|
||||||
var IkConstraintTimeline = (function (_super) {
|
var IkConstraintTimeline = (function (_super) {
|
||||||
__extends(IkConstraintTimeline, _super);
|
__extends(IkConstraintTimeline, _super);
|
||||||
function IkConstraintTimeline(frameCount) {
|
function IkConstraintTimeline(frameCount) {
|
||||||
@ -648,9 +680,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
|
var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint.mix = constraint.data.mix;
|
||||||
|
constraint.bendDirection = constraint.data.bendDirection;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
|
||||||
if (setupPose) {
|
if (setupPose) {
|
||||||
constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
|
constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
|
||||||
@ -706,9 +743,17 @@ var spine;
|
|||||||
};
|
};
|
||||||
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
|
var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
var data = constraint.data;
|
||||||
|
constraint.rotateMix = data.rotateMix;
|
||||||
|
constraint.translateMix = data.rotateMix;
|
||||||
|
constraint.scaleMix = data.scaleMix;
|
||||||
|
constraint.shearMix = data.shearMix;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var rotate = 0, translate = 0, scale = 0, shear = 0;
|
var rotate = 0, translate = 0, scale = 0, shear = 0;
|
||||||
if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) {
|
||||||
var i = frames.length;
|
var i = frames.length;
|
||||||
@ -773,9 +818,12 @@ var spine;
|
|||||||
};
|
};
|
||||||
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
constraint.position = constraint.data.position;
|
||||||
|
return;
|
||||||
|
}
|
||||||
var position = 0;
|
var position = 0;
|
||||||
if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES])
|
if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES])
|
||||||
position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE];
|
position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE];
|
||||||
@ -808,9 +856,12 @@ var spine;
|
|||||||
};
|
};
|
||||||
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose)
|
||||||
|
constraint.spacing = constraint.data.spacing;
|
||||||
|
return;
|
||||||
|
}
|
||||||
var spacing = 0;
|
var spacing = 0;
|
||||||
if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES])
|
if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES])
|
||||||
spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE];
|
spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE];
|
||||||
@ -846,9 +897,14 @@ var spine;
|
|||||||
};
|
};
|
||||||
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||||
var frames = this.frames;
|
var frames = this.frames;
|
||||||
if (time < frames[0])
|
|
||||||
return;
|
|
||||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint.rotateMix = constraint.data.rotateMix;
|
||||||
|
constraint.translateMix = constraint.data.translateMix;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var rotate = 0, translate = 0;
|
var rotate = 0, translate = 0;
|
||||||
if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) {
|
if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) {
|
||||||
rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE];
|
rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE];
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -206,9 +206,12 @@ module spine {
|
|||||||
|
|
||||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||||
let frames = this.frames;
|
let frames = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
let bone = skeleton.bones[this.boneIndex];
|
let bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) bone.rotation = bone.data.rotation;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) { // Time is after last frame.
|
||||||
if (setupPose)
|
if (setupPose)
|
||||||
@ -269,9 +272,15 @@ module spine {
|
|||||||
|
|
||||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||||
let frames = this.frames;
|
let frames = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
let bone = skeleton.bones[this.boneIndex];
|
let bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.x = bone.data.x;
|
||||||
|
bone.y = bone.data.y;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let x = 0, y = 0;
|
let x = 0, y = 0;
|
||||||
if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) { // Time is after last frame.
|
||||||
@ -310,9 +319,16 @@ module spine {
|
|||||||
|
|
||||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||||
let frames = this.frames;
|
let frames = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
let bone = skeleton.bones[this.boneIndex];
|
let bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.scaleX = bone.data.scaleX;
|
||||||
|
bone.scaleY = bone.data.scaleY;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let x = 0, y = 0;
|
let x = 0, y = 0;
|
||||||
if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) { // Time is after last frame.
|
||||||
x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX;
|
x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX;
|
||||||
@ -366,9 +382,15 @@ module spine {
|
|||||||
|
|
||||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||||
let frames = this.frames;
|
let frames = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
let bone = skeleton.bones[this.boneIndex];
|
let bone = skeleton.bones[this.boneIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
bone.shearX = bone.data.shearX;
|
||||||
|
bone.shearY = bone.data.shearY;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let x = 0, y = 0;
|
let x = 0, y = 0;
|
||||||
if (time >= frames[frames.length - ShearTimeline.ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.length - ShearTimeline.ENTRIES]) { // Time is after last frame.
|
||||||
@ -424,8 +446,12 @@ module spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||||
|
let slot = skeleton.slots[this.slotIndex];
|
||||||
let frames = this.frames;
|
let frames = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) slot.color.setFromColor(slot.data.color);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let r = 0, g = 0, b = 0, a = 0;
|
let r = 0, g = 0, b = 0, a = 0;
|
||||||
if (time >= frames[frames.length - ColorTimeline.ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.length - ColorTimeline.ENTRIES]) { // Time is after last frame.
|
||||||
@ -450,7 +476,6 @@ module spine {
|
|||||||
b += (frames[frame + ColorTimeline.B] - b) * percent;
|
b += (frames[frame + ColorTimeline.B] - b) * percent;
|
||||||
a += (frames[frame + ColorTimeline.A] - a) * percent;
|
a += (frames[frame + ColorTimeline.A] - a) * percent;
|
||||||
}
|
}
|
||||||
let slot = skeleton.slots[this.slotIndex];
|
|
||||||
if (alpha == 1)
|
if (alpha == 1)
|
||||||
slot.color.set(r, g, b, a);
|
slot.color.set(r, g, b, a);
|
||||||
else {
|
else {
|
||||||
@ -486,15 +511,21 @@ module spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||||
|
let slot = skeleton.slots[this.slotIndex];
|
||||||
if (mixingOut && setupPose) {
|
if (mixingOut && setupPose) {
|
||||||
let slot = skeleton.slots[this.slotIndex];
|
|
||||||
let attachmentName = slot.data.attachmentName;
|
let attachmentName = slot.data.attachmentName;
|
||||||
slot.setAttachment(attachmentName == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName));
|
slot.setAttachment(attachmentName == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let frames = this.frames;
|
let frames = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
let attachmentName = slot.data.attachmentName;
|
||||||
|
slot.setAttachment(attachmentName == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let frameIndex = 0;
|
let frameIndex = 0;
|
||||||
if (time >= frames[frames.length - 1]) // Time is after last frame.
|
if (time >= frames[frames.length - 1]) // Time is after last frame.
|
||||||
@ -508,6 +539,109 @@ module spine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class DeformTimeline extends CurveTimeline {
|
||||||
|
slotIndex: number;
|
||||||
|
attachment: VertexAttachment;
|
||||||
|
frames: ArrayLike<number>; // time, ...
|
||||||
|
frameVertices: Array<ArrayLike<number>>;
|
||||||
|
|
||||||
|
constructor (frameCount: number) {
|
||||||
|
super(frameCount);
|
||||||
|
this.frames = Utils.newFloatArray(frameCount);
|
||||||
|
this.frameVertices = new Array<ArrayLike<number>>(frameCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
getPropertyId () {
|
||||||
|
return (TimelineType.deform << 24) + this.slotIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sets the time of the specified keyframe. */
|
||||||
|
setFrame (frameIndex: number, time: number, vertices: ArrayLike<number>) {
|
||||||
|
this.frames[frameIndex] = time;
|
||||||
|
this.frameVertices[frameIndex] = vertices;
|
||||||
|
}
|
||||||
|
|
||||||
|
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||||
|
let slot: Slot = skeleton.slots[this.slotIndex];
|
||||||
|
let slotAttachment: Attachment = slot.getAttachment();
|
||||||
|
if (!(slotAttachment instanceof VertexAttachment) || !(<VertexAttachment>slotAttachment).applyDeform(this.attachment)) return;
|
||||||
|
|
||||||
|
let frames = this.frames;
|
||||||
|
let verticesArray: Array<number> = slot.attachmentVertices;
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) Utils.setArraySize(verticesArray, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let frameVertices = this.frameVertices;
|
||||||
|
let vertexCount = frameVertices[0].length;
|
||||||
|
|
||||||
|
if (verticesArray.length != vertexCount) alpha = 1; // Don't mix from uninitialized slot vertices.
|
||||||
|
let vertices: Array<number> = Utils.setArraySize(verticesArray, vertexCount);
|
||||||
|
|
||||||
|
if (time >= frames[frames.length - 1]) { // Time is after last frame.
|
||||||
|
let lastVertices = frameVertices[frames.length - 1];
|
||||||
|
if (alpha == 1) {
|
||||||
|
Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount);
|
||||||
|
} else if (setupPose) {
|
||||||
|
let vertexAttachment = slotAttachment as VertexAttachment;
|
||||||
|
if (vertexAttachment.bones == null) {
|
||||||
|
// Unweighted vertex positions, with alpha.
|
||||||
|
let setupVertices = vertexAttachment.vertices;
|
||||||
|
for (let i = 0; i < vertexCount; i++) {
|
||||||
|
let setup = setupVertices[i];
|
||||||
|
vertices[i] = setup + (lastVertices[i] - setup) * alpha;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Weighted deform offsets, with alpha.
|
||||||
|
for (let i = 0; i < vertexCount; i++)
|
||||||
|
vertices[i] = lastVertices[i] * alpha;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (let i = 0; i < vertexCount; i++)
|
||||||
|
vertices[i] += (lastVertices[i] - vertices[i]) * alpha;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Interpolate between the previous frame and the current frame.
|
||||||
|
let frame = Animation.binarySearch(frames, time);
|
||||||
|
let prevVertices = frameVertices[frame - 1];
|
||||||
|
let nextVertices = frameVertices[frame];
|
||||||
|
let frameTime = frames[frame];
|
||||||
|
let percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime));
|
||||||
|
|
||||||
|
if (alpha == 1) {
|
||||||
|
for (let i = 0; i < vertexCount; i++) {
|
||||||
|
let prev = prevVertices[i];
|
||||||
|
vertices[i] = prev + (nextVertices[i] - prev) * percent;
|
||||||
|
}
|
||||||
|
} else if (setupPose) {
|
||||||
|
let vertexAttachment = slotAttachment as VertexAttachment;
|
||||||
|
if (vertexAttachment.bones == null) {
|
||||||
|
// Unweighted vertex positions, with alpha.
|
||||||
|
let setupVertices = vertexAttachment.vertices;
|
||||||
|
for (let i = 0; i < vertexCount; i++) {
|
||||||
|
let prev = prevVertices[i], setup = setupVertices[i];
|
||||||
|
vertices[i] = setup + (prev + (nextVertices[i] - prev) * percent - setup) * alpha;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Weighted deform offsets, with alpha.
|
||||||
|
for (let i = 0; i < vertexCount; i++) {
|
||||||
|
let prev = prevVertices[i];
|
||||||
|
vertices[i] = (prev + (nextVertices[i] - prev) * percent) * alpha;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Vertex positions or deform offsets, with alpha.
|
||||||
|
for (let i = 0; i < vertexCount; i++) {
|
||||||
|
let prev = prevVertices[i];
|
||||||
|
vertices[i] += (prev + (nextVertices[i] - prev) * percent - vertices[i]) * alpha;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class EventTimeline implements Timeline {
|
export class EventTimeline implements Timeline {
|
||||||
frames: ArrayLike<number>; // time, ...
|
frames: ArrayLike<number>; // time, ...
|
||||||
events: Array<Event>;
|
events: Array<Event>;
|
||||||
@ -585,13 +719,18 @@ module spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||||
|
let drawOrder: Array<Slot> = skeleton.drawOrder;
|
||||||
|
let slots: Array<Slot> = skeleton.slots;
|
||||||
if (mixingOut && setupPose) {
|
if (mixingOut && setupPose) {
|
||||||
Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let frames = this.frames;
|
let frames = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let frame = 0;
|
let frame = 0;
|
||||||
if (time >= frames[frames.length - 1]) // Time is after last frame.
|
if (time >= frames[frames.length - 1]) // Time is after last frame.
|
||||||
@ -599,8 +738,6 @@ module spine {
|
|||||||
else
|
else
|
||||||
frame = Animation.binarySearch(frames, time) - 1;
|
frame = Animation.binarySearch(frames, time) - 1;
|
||||||
|
|
||||||
let drawOrder: Array<Slot> = skeleton.drawOrder;
|
|
||||||
let slots: Array<Slot> = skeleton.slots;
|
|
||||||
let drawOrderToSetupIndex = this.drawOrders[frame];
|
let drawOrderToSetupIndex = this.drawOrders[frame];
|
||||||
if (drawOrderToSetupIndex == null)
|
if (drawOrderToSetupIndex == null)
|
||||||
Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length);
|
Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length);
|
||||||
@ -611,106 +748,6 @@ module spine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DeformTimeline extends CurveTimeline {
|
|
||||||
slotIndex: number;
|
|
||||||
attachment: VertexAttachment;
|
|
||||||
frames: ArrayLike<number>; // time, ...
|
|
||||||
frameVertices: Array<ArrayLike<number>>;
|
|
||||||
|
|
||||||
constructor (frameCount: number) {
|
|
||||||
super(frameCount);
|
|
||||||
this.frames = Utils.newFloatArray(frameCount);
|
|
||||||
this.frameVertices = new Array<ArrayLike<number>>(frameCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
getPropertyId () {
|
|
||||||
return (TimelineType.deform << 24) + this.slotIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Sets the time of the specified keyframe. */
|
|
||||||
setFrame (frameIndex: number, time: number, vertices: ArrayLike<number>) {
|
|
||||||
this.frames[frameIndex] = time;
|
|
||||||
this.frameVertices[frameIndex] = vertices;
|
|
||||||
}
|
|
||||||
|
|
||||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
|
||||||
let slot: Slot = skeleton.slots[this.slotIndex];
|
|
||||||
let slotAttachment: Attachment = slot.getAttachment();
|
|
||||||
if (!(slotAttachment instanceof VertexAttachment) || !(<VertexAttachment>slotAttachment).applyDeform(this.attachment)) return;
|
|
||||||
|
|
||||||
let frames = this.frames;
|
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
let frameVertices = this.frameVertices;
|
|
||||||
let vertexCount = frameVertices[0].length;
|
|
||||||
|
|
||||||
let verticesArray: Array<number> = slot.attachmentVertices;
|
|
||||||
if (verticesArray.length != vertexCount) alpha = 1; // Don't mix from uninitialized slot vertices.
|
|
||||||
let vertices: Array<number> = Utils.setArraySize(verticesArray, vertexCount);
|
|
||||||
|
|
||||||
if (time >= frames[frames.length - 1]) { // Time is after last frame.
|
|
||||||
let lastVertices = frameVertices[frames.length - 1];
|
|
||||||
if (alpha == 1) {
|
|
||||||
Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount);
|
|
||||||
} else if (setupPose) {
|
|
||||||
let vertexAttachment = slotAttachment as VertexAttachment;
|
|
||||||
if (vertexAttachment.bones == null) {
|
|
||||||
// Unweighted vertex positions, with alpha.
|
|
||||||
let setupVertices = vertexAttachment.vertices;
|
|
||||||
for (let i = 0; i < vertexCount; i++) {
|
|
||||||
let setup = setupVertices[i];
|
|
||||||
vertices[i] = setup + (lastVertices[i] - setup) * alpha;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Weighted deform offsets, with alpha.
|
|
||||||
for (let i = 0; i < vertexCount; i++)
|
|
||||||
vertices[i] = lastVertices[i] * alpha;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (let i = 0; i < vertexCount; i++)
|
|
||||||
vertices[i] += (lastVertices[i] - vertices[i]) * alpha;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Interpolate between the previous frame and the current frame.
|
|
||||||
let frame = Animation.binarySearch(frames, time);
|
|
||||||
let prevVertices = frameVertices[frame - 1];
|
|
||||||
let nextVertices = frameVertices[frame];
|
|
||||||
let frameTime = frames[frame];
|
|
||||||
let percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime));
|
|
||||||
|
|
||||||
if (alpha == 1) {
|
|
||||||
for (let i = 0; i < vertexCount; i++) {
|
|
||||||
let prev = prevVertices[i];
|
|
||||||
vertices[i] = prev + (nextVertices[i] - prev) * percent;
|
|
||||||
}
|
|
||||||
} else if (setupPose) {
|
|
||||||
let vertexAttachment = slotAttachment as VertexAttachment;
|
|
||||||
if (vertexAttachment.bones == null) {
|
|
||||||
// Unweighted vertex positions, with alpha.
|
|
||||||
let setupVertices = vertexAttachment.vertices;
|
|
||||||
for (let i = 0; i < vertexCount; i++) {
|
|
||||||
let prev = prevVertices[i], setup = setupVertices[i];
|
|
||||||
vertices[i] = setup + (prev + (nextVertices[i] - prev) * percent - setup) * alpha;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Weighted deform offsets, with alpha.
|
|
||||||
for (let i = 0; i < vertexCount; i++) {
|
|
||||||
let prev = prevVertices[i];
|
|
||||||
vertices[i] = (prev + (nextVertices[i] - prev) * percent) * alpha;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Vertex positions or deform offsets, with alpha.
|
|
||||||
for (let i = 0; i < vertexCount; i++) {
|
|
||||||
let prev = prevVertices[i];
|
|
||||||
vertices[i] += (prev + (nextVertices[i] - prev) * percent - vertices[i]) * alpha;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class IkConstraintTimeline extends CurveTimeline {
|
export class IkConstraintTimeline extends CurveTimeline {
|
||||||
static ENTRIES = 3;
|
static ENTRIES = 3;
|
||||||
static PREV_TIME = -3; static PREV_MIX = -2; static PREV_BEND_DIRECTION = -1;
|
static PREV_TIME = -3; static PREV_MIX = -2; static PREV_BEND_DIRECTION = -1;
|
||||||
@ -738,9 +775,14 @@ module spine {
|
|||||||
|
|
||||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||||
let frames = this.frames;
|
let frames = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
let constraint: IkConstraint = skeleton.ikConstraints[this.ikConstraintIndex];
|
let constraint: IkConstraint = skeleton.ikConstraints[this.ikConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint.mix = constraint.data.mix;
|
||||||
|
constraint.bendDirection = constraint.data.bendDirection;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) { // Time is after last frame.
|
||||||
if (setupPose) {
|
if (setupPose) {
|
||||||
@ -800,9 +842,18 @@ module spine {
|
|||||||
|
|
||||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||||
let frames = this.frames;
|
let frames = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
let constraint: TransformConstraint = skeleton.transformConstraints[this.transformConstraintIndex];
|
let constraint: TransformConstraint = skeleton.transformConstraints[this.transformConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
let data = constraint.data;
|
||||||
|
constraint.rotateMix = data.rotateMix;
|
||||||
|
constraint.translateMix = data.rotateMix;
|
||||||
|
constraint.scaleMix = data.scaleMix;
|
||||||
|
constraint.shearMix = data.shearMix;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let rotate = 0, translate = 0, scale = 0, shear = 0;
|
let rotate = 0, translate = 0, scale = 0, shear = 0;
|
||||||
if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) { // Time is after last frame.
|
||||||
@ -869,9 +920,11 @@ module spine {
|
|||||||
|
|
||||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||||
let frames = this.frames;
|
let frames = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
let constraint: PathConstraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
let constraint: PathConstraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) constraint.position = constraint.data.position;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let position = 0;
|
let position = 0;
|
||||||
if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES]) // Time is after last frame.
|
if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES]) // Time is after last frame.
|
||||||
@ -904,9 +957,11 @@ module spine {
|
|||||||
|
|
||||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||||
let frames = this.frames;
|
let frames = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
let constraint: PathConstraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
let constraint: PathConstraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) constraint.spacing = constraint.data.spacing;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let spacing = 0;
|
let spacing = 0;
|
||||||
if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES]) // Time is after last frame.
|
if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES]) // Time is after last frame.
|
||||||
@ -957,10 +1012,16 @@ module spine {
|
|||||||
|
|
||||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||||
let frames = this.frames;
|
let frames = this.frames;
|
||||||
if (time < frames[0]) return; // Time is before first frame.
|
|
||||||
|
|
||||||
let constraint: PathConstraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
let constraint: PathConstraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||||
|
|
||||||
|
if (time < frames[0]) {
|
||||||
|
if (setupPose) {
|
||||||
|
constraint.rotateMix = constraint.data.rotateMix;
|
||||||
|
constraint.translateMix = constraint.data.translateMix;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let rotate = 0, translate = 0;
|
let rotate = 0, translate = 0;
|
||||||
if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) { // Time is after last frame.
|
if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) { // Time is after last frame.
|
||||||
rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE];
|
rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user