Fixed #1059 for spine-ts.

This commit is contained in:
badlogic 2018-01-10 16:36:52 +01:00
parent 82d3dd80e1
commit c3e1f9bc15
15 changed files with 2124 additions and 1340 deletions

View File

@ -4,18 +4,19 @@ declare module spine {
timelines: Array<Timeline>; timelines: Array<Timeline>;
duration: number; duration: number;
constructor(name: string, timelines: Array<Timeline>, duration: number); constructor(name: string, timelines: Array<Timeline>, duration: number);
apply(skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
static binarySearch(values: ArrayLike<number>, target: number, step?: number): number; static binarySearch(values: ArrayLike<number>, target: number, step?: number): number;
static linearSearch(values: ArrayLike<number>, target: number, step: number): number; static linearSearch(values: ArrayLike<number>, target: number, step: number): number;
} }
interface Timeline { interface Timeline {
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
getPropertyId(): number; getPropertyId(): number;
} }
enum MixPose { enum MixBlend {
setup = 0, setup = 0,
current = 1, first = 1,
currentLayered = 2, replace = 2,
add = 3,
} }
enum MixDirection { enum MixDirection {
in = 0, in = 0,
@ -52,7 +53,7 @@ declare module spine {
getCurveType(frameIndex: number): number; getCurveType(frameIndex: number): number;
setCurve(frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void; setCurve(frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void;
getCurvePercent(frameIndex: number, percent: number): number; getCurvePercent(frameIndex: number, percent: number): number;
abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class RotateTimeline extends CurveTimeline { class RotateTimeline extends CurveTimeline {
static ENTRIES: number; static ENTRIES: number;
@ -64,7 +65,7 @@ declare module spine {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
setFrame(frameIndex: number, time: number, degrees: number): void; setFrame(frameIndex: number, time: number, degrees: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class TranslateTimeline extends CurveTimeline { class TranslateTimeline extends CurveTimeline {
static ENTRIES: number; static ENTRIES: number;
@ -78,17 +79,17 @@ declare module spine {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
setFrame(frameIndex: number, time: number, x: number, y: number): void; setFrame(frameIndex: number, time: number, x: number, y: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class ScaleTimeline extends TranslateTimeline { class ScaleTimeline extends TranslateTimeline {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class ShearTimeline extends TranslateTimeline { class ShearTimeline extends TranslateTimeline {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class ColorTimeline extends CurveTimeline { class ColorTimeline extends CurveTimeline {
static ENTRIES: number; static ENTRIES: number;
@ -106,7 +107,7 @@ declare module spine {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number): void; setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class TwoColorTimeline extends CurveTimeline { class TwoColorTimeline extends CurveTimeline {
static ENTRIES: number; static ENTRIES: number;
@ -130,7 +131,7 @@ declare module spine {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number, r2: number, g2: number, b2: number): void; setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number, r2: number, g2: number, b2: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class AttachmentTimeline implements Timeline { class AttachmentTimeline implements Timeline {
slotIndex: number; slotIndex: number;
@ -140,7 +141,7 @@ declare module spine {
getPropertyId(): number; getPropertyId(): number;
getFrameCount(): number; getFrameCount(): number;
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, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class DeformTimeline extends CurveTimeline { class DeformTimeline extends CurveTimeline {
slotIndex: number; slotIndex: number;
@ -150,7 +151,7 @@ declare module spine {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void; setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class EventTimeline implements Timeline { class EventTimeline implements Timeline {
frames: ArrayLike<number>; frames: ArrayLike<number>;
@ -159,7 +160,7 @@ declare module spine {
getPropertyId(): number; getPropertyId(): number;
getFrameCount(): number; getFrameCount(): number;
setFrame(frameIndex: number, event: Event): void; setFrame(frameIndex: number, event: Event): void;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class DrawOrderTimeline implements Timeline { class DrawOrderTimeline implements Timeline {
frames: ArrayLike<number>; frames: ArrayLike<number>;
@ -168,7 +169,7 @@ declare module spine {
getPropertyId(): number; getPropertyId(): number;
getFrameCount(): number; getFrameCount(): number;
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, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class IkConstraintTimeline extends CurveTimeline { class IkConstraintTimeline extends CurveTimeline {
static ENTRIES: number; static ENTRIES: number;
@ -182,7 +183,7 @@ declare module spine {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
setFrame(frameIndex: number, time: number, mix: number, bendDirection: number): void; setFrame(frameIndex: number, time: number, mix: number, bendDirection: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class TransformConstraintTimeline extends CurveTimeline { class TransformConstraintTimeline extends CurveTimeline {
static ENTRIES: number; static ENTRIES: number;
@ -200,7 +201,7 @@ declare module spine {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number, scaleMix: number, shearMix: number): void; setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number, scaleMix: number, shearMix: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class PathConstraintPositionTimeline extends CurveTimeline { class PathConstraintPositionTimeline extends CurveTimeline {
static ENTRIES: number; static ENTRIES: number;
@ -212,12 +213,12 @@ declare module spine {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
setFrame(frameIndex: number, time: number, value: number): void; setFrame(frameIndex: number, time: number, value: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class PathConstraintSpacingTimeline extends PathConstraintPositionTimeline { class PathConstraintSpacingTimeline extends PathConstraintPositionTimeline {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class PathConstraintMixTimeline extends CurveTimeline { class PathConstraintMixTimeline extends CurveTimeline {
static ENTRIES: number; static ENTRIES: number;
@ -231,7 +232,7 @@ declare module spine {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number): void; setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
} }
declare module spine { declare module spine {
@ -255,8 +256,8 @@ declare module spine {
update(delta: number): void; update(delta: number): void;
updateMixingFrom(to: TrackEntry, delta: number): boolean; updateMixingFrom(to: TrackEntry, delta: number): boolean;
apply(skeleton: Skeleton): boolean; apply(skeleton: Skeleton): boolean;
applyMixingFrom(to: TrackEntry, skeleton: Skeleton, currentPose: MixPose): number; applyMixingFrom(to: TrackEntry, skeleton: Skeleton, blend: MixBlend): number;
applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, pose: MixPose, timelinesRotation: Array<number>, i: number, firstFrame: boolean): void; applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, blend: MixBlend, timelinesRotation: Array<number>, i: number, firstFrame: boolean): void;
queueEvents(entry: TrackEntry, animationTime: number): void; queueEvents(entry: TrackEntry, animationTime: number): void;
clearTracks(): void; clearTracks(): void;
clearTrack(trackIndex: number): void; clearTrack(trackIndex: number): void;
@ -303,6 +304,7 @@ declare module spine {
mixDuration: number; mixDuration: number;
interruptAlpha: number; interruptAlpha: number;
totalAlpha: number; totalAlpha: number;
mixBlend: MixBlend;
timelineData: number[]; timelineData: number[];
timelineDipMix: TrackEntry[]; timelineDipMix: TrackEntry[];
timelinesRotation: number[]; timelinesRotation: number[];

View File

@ -20,7 +20,7 @@ var spine;
this.timelines = timelines; this.timelines = timelines;
this.duration = duration; this.duration = duration;
} }
Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, pose, direction) { Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, blend, direction) {
if (skeleton == null) if (skeleton == null)
throw new Error("skeleton cannot be null."); throw new Error("skeleton cannot be null.");
if (loop && this.duration != 0) { if (loop && this.duration != 0) {
@ -30,7 +30,7 @@ var spine;
} }
var timelines = this.timelines; var timelines = this.timelines;
for (var i = 0, n = timelines.length; i < n; i++) for (var i = 0, n = timelines.length; i < n; i++)
timelines[i].apply(skeleton, lastTime, time, events, alpha, pose, direction); timelines[i].apply(skeleton, lastTime, time, events, alpha, blend, direction);
}; };
Animation.binarySearch = function (values, target, step) { Animation.binarySearch = function (values, target, step) {
if (step === void 0) { step = 1; } if (step === void 0) { step = 1; }
@ -58,12 +58,13 @@ var spine;
return Animation; return Animation;
}()); }());
spine.Animation = Animation; spine.Animation = Animation;
var MixPose; var MixBlend;
(function (MixPose) { (function (MixBlend) {
MixPose[MixPose["setup"] = 0] = "setup"; MixBlend[MixBlend["setup"] = 0] = "setup";
MixPose[MixPose["current"] = 1] = "current"; MixBlend[MixBlend["first"] = 1] = "first";
MixPose[MixPose["currentLayered"] = 2] = "currentLayered"; MixBlend[MixBlend["replace"] = 2] = "replace";
})(MixPose = spine.MixPose || (spine.MixPose = {})); MixBlend[MixBlend["add"] = 3] = "add";
})(MixBlend = spine.MixBlend || (spine.MixBlend = {}));
var MixDirection; var MixDirection;
(function (MixDirection) { (function (MixDirection) {
MixDirection[MixDirection["in"] = 0] = "in"; MixDirection[MixDirection["in"] = 0] = "in";
@ -184,28 +185,32 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.frames[frameIndex + RotateTimeline.ROTATION] = degrees; this.frames[frameIndex + RotateTimeline.ROTATION] = degrees;
}; };
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.rotation = bone.data.rotation; bone.rotation = bone.data.rotation;
return; return;
case MixPose.current: case MixBlend.first:
var r_1 = bone.data.rotation - bone.rotation; var r_1 = bone.data.rotation - bone.rotation;
r_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360; bone.rotation += (r_1 - (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360) * alpha;
bone.rotation += r_1 * alpha;
} }
return; return;
} }
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) { if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
if (pose == MixPose.setup) var r = frames[frames.length + RotateTimeline.PREV_ROTATION];
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha; switch (blend) {
else { case MixBlend.setup:
var r_2 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation; bone.rotation = bone.data.rotation + r * alpha;
r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360; break;
bone.rotation += r_2 * alpha; case MixBlend.first:
case MixBlend.replace:
r += bone.data.rotation - bone.rotation;
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
case MixBlend.add:
bone.rotation += r * alpha;
} }
return; return;
} }
@ -213,17 +218,17 @@ var spine;
var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION]; var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION];
var frameTime = frames[frame]; var frameTime = frames[frame];
var percent = this.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime));
var r = frames[frame + RotateTimeline.ROTATION] - prevRotation; r = frames[frame + RotateTimeline.ROTATION] - prevRotation;
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; r = prevRotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * percent;
r = prevRotation + r * percent; switch (blend) {
if (pose == MixPose.setup) { case MixBlend.setup:
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; bone.rotation = bone.data.rotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha;
bone.rotation = bone.data.rotation + r * alpha; break;
} case MixBlend.first:
else { case MixBlend.replace:
r = bone.data.rotation + r - bone.rotation; r += bone.data.rotation - bone.rotation;
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; case MixBlend.add:
bone.rotation += r * alpha; bone.rotation += (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha;
} }
}; };
return RotateTimeline; return RotateTimeline;
@ -249,16 +254,16 @@ var spine;
this.frames[frameIndex + TranslateTimeline.X] = x; this.frames[frameIndex + TranslateTimeline.X] = x;
this.frames[frameIndex + TranslateTimeline.Y] = y; this.frames[frameIndex + TranslateTimeline.Y] = y;
}; };
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.x = bone.data.x; bone.x = bone.data.x;
bone.y = bone.data.y; bone.y = bone.data.y;
return; return;
case MixPose.current: case MixBlend.first:
bone.x += (bone.data.x - bone.x) * alpha; bone.x += (bone.data.x - bone.x) * alpha;
bone.y += (bone.data.y - bone.y) * alpha; bone.y += (bone.data.y - bone.y) * alpha;
} }
@ -278,13 +283,19 @@ var spine;
x += (frames[frame + TranslateTimeline.X] - x) * percent; x += (frames[frame + TranslateTimeline.X] - x) * percent;
y += (frames[frame + TranslateTimeline.Y] - y) * percent; y += (frames[frame + TranslateTimeline.Y] - y) * percent;
} }
if (pose == MixPose.setup) { switch (blend) {
bone.x = bone.data.x + x * alpha; case MixBlend.setup:
bone.y = bone.data.y + y * alpha; bone.x = bone.data.x + x * alpha;
} bone.y = bone.data.y + y * alpha;
else { break;
bone.x += (bone.data.x + x - bone.x) * alpha; case MixBlend.first:
bone.y += (bone.data.y + y - bone.y) * alpha; case MixBlend.replace:
bone.x += (bone.data.x + x - bone.x) * alpha;
bone.y += (bone.data.y + y - bone.y) * alpha;
break;
case MixBlend.add:
bone.x += x * alpha;
bone.y += y * alpha;
} }
}; };
return TranslateTimeline; return TranslateTimeline;
@ -304,16 +315,16 @@ var spine;
ScaleTimeline.prototype.getPropertyId = function () { ScaleTimeline.prototype.getPropertyId = function () {
return (TimelineType.scale << 24) + this.boneIndex; return (TimelineType.scale << 24) + this.boneIndex;
}; };
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.scaleX = bone.data.scaleX; bone.scaleX = bone.data.scaleX;
bone.scaleY = bone.data.scaleY; bone.scaleY = bone.data.scaleY;
return; return;
case MixPose.current: case MixBlend.first:
bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha; bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;
bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha; bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;
} }
@ -334,29 +345,61 @@ var spine;
y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY; y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY;
} }
if (alpha == 1) { if (alpha == 1) {
bone.scaleX = x; if (blend == MixBlend.add) {
bone.scaleY = y; bone.scaleX += x - bone.data.scaleX;
bone.scaleY += y - bone.data.scaleY;
}
else {
bone.scaleX = x;
bone.scaleY = y;
}
} }
else { else {
var bx = 0, by = 0; var bx = 0, by = 0;
if (pose == MixPose.setup) {
bx = bone.data.scaleX;
by = bone.data.scaleY;
}
else {
bx = bone.scaleX;
by = bone.scaleY;
}
if (direction == MixDirection.out) { if (direction == MixDirection.out) {
x = Math.abs(x) * spine.MathUtils.signum(bx); switch (blend) {
y = Math.abs(y) * spine.MathUtils.signum(by); case MixBlend.setup:
bx = bone.data.scaleX;
by = bone.data.scaleY;
bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bx) * alpha;
bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - by) * alpha;
break;
case MixBlend.first:
case MixBlend.replace:
bx = bone.scaleX;
by = bone.scaleY;
bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bx) * alpha;
bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - by) * alpha;
break;
case MixBlend.add:
bx = bone.scaleX;
by = bone.scaleY;
bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bone.data.scaleX) * alpha;
bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - bone.data.scaleY) * alpha;
}
} }
else { else {
bx = Math.abs(bx) * spine.MathUtils.signum(x); switch (blend) {
by = Math.abs(by) * spine.MathUtils.signum(y); case MixBlend.setup:
bx = Math.abs(bone.data.scaleX) * spine.MathUtils.signum(x);
by = Math.abs(bone.data.scaleY) * spine.MathUtils.signum(y);
bone.scaleX = bx + (x - bx) * alpha;
bone.scaleY = by + (y - by) * alpha;
break;
case MixBlend.first:
case MixBlend.replace:
bx = Math.abs(bone.scaleX) * spine.MathUtils.signum(x);
by = Math.abs(bone.scaleY) * spine.MathUtils.signum(y);
bone.scaleX = bx + (x - bx) * alpha;
bone.scaleY = by + (y - by) * alpha;
break;
case MixBlend.add:
bx = spine.MathUtils.signum(x);
by = spine.MathUtils.signum(y);
bone.scaleX = Math.abs(bone.scaleX) * bx + (x - Math.abs(bone.data.scaleX) * bx) * alpha;
bone.scaleY = Math.abs(bone.scaleY) * by + (y - Math.abs(bone.data.scaleY) * by) * alpha;
}
} }
bone.scaleX = bx + (x - bx) * alpha;
bone.scaleY = by + (y - by) * alpha;
} }
}; };
return ScaleTimeline; return ScaleTimeline;
@ -370,16 +413,16 @@ var spine;
ShearTimeline.prototype.getPropertyId = function () { ShearTimeline.prototype.getPropertyId = function () {
return (TimelineType.shear << 24) + this.boneIndex; return (TimelineType.shear << 24) + this.boneIndex;
}; };
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.shearX = bone.data.shearX; bone.shearX = bone.data.shearX;
bone.shearY = bone.data.shearY; bone.shearY = bone.data.shearY;
return; return;
case MixPose.current: case MixBlend.first:
bone.shearX += (bone.data.shearX - bone.shearX) * alpha; bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
bone.shearY += (bone.data.shearY - bone.shearY) * alpha; bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
} }
@ -399,13 +442,19 @@ var spine;
x = x + (frames[frame + ShearTimeline.X] - x) * percent; x = x + (frames[frame + ShearTimeline.X] - x) * percent;
y = y + (frames[frame + ShearTimeline.Y] - y) * percent; y = y + (frames[frame + ShearTimeline.Y] - y) * percent;
} }
if (pose == MixPose.setup) { switch (blend) {
bone.shearX = bone.data.shearX + x * alpha; case MixBlend.setup:
bone.shearY = bone.data.shearY + y * alpha; bone.shearX = bone.data.shearX + x * alpha;
} bone.shearY = bone.data.shearY + y * alpha;
else { break;
bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha; case MixBlend.first:
bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha; case MixBlend.replace:
bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha;
bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha;
break;
case MixBlend.add:
bone.shearX += x * alpha;
bone.shearY += y * alpha;
} }
}; };
return ShearTimeline; return ShearTimeline;
@ -429,15 +478,15 @@ var spine;
this.frames[frameIndex + ColorTimeline.B] = b; this.frames[frameIndex + ColorTimeline.B] = b;
this.frames[frameIndex + ColorTimeline.A] = a; this.frames[frameIndex + ColorTimeline.A] = a;
}; };
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
slot.color.setFromColor(slot.data.color); slot.color.setFromColor(slot.data.color);
return; return;
case MixPose.current: case MixBlend.first:
var color = slot.color, setup = slot.data.color; var color = slot.color, setup = slot.data.color;
color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha); color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha);
} }
@ -468,7 +517,7 @@ var spine;
slot.color.set(r, g, b, a); slot.color.set(r, g, b, a);
else { else {
var color = slot.color; var color = slot.color;
if (pose == MixPose.setup) if (blend == MixBlend.setup)
color.setFromColor(slot.data.color); color.setFromColor(slot.data.color);
color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha); color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
} }
@ -507,16 +556,16 @@ var spine;
this.frames[frameIndex + TwoColorTimeline.G2] = g2; this.frames[frameIndex + TwoColorTimeline.G2] = g2;
this.frames[frameIndex + TwoColorTimeline.B2] = b2; this.frames[frameIndex + TwoColorTimeline.B2] = b2;
}; };
TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
slot.color.setFromColor(slot.data.color); slot.color.setFromColor(slot.data.color);
slot.darkColor.setFromColor(slot.data.darkColor); slot.darkColor.setFromColor(slot.data.darkColor);
return; return;
case MixPose.current: case MixBlend.setup:
var light = slot.color, dark = slot.darkColor, setupLight = slot.data.color, setupDark = slot.data.darkColor; var light = slot.color, dark = slot.darkColor, setupLight = slot.data.color, setupDark = slot.data.darkColor;
light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha); light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha);
dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0); dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0);
@ -559,7 +608,7 @@ var spine;
} }
else { else {
var light = slot.color, dark = slot.darkColor; var light = slot.color, dark = slot.darkColor;
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
light.setFromColor(slot.data.color); light.setFromColor(slot.data.color);
dark.setFromColor(slot.data.darkColor); dark.setFromColor(slot.data.darkColor);
} }
@ -601,16 +650,16 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.attachmentNames[frameIndex] = attachmentName; this.attachmentNames[frameIndex] = attachmentName;
}; };
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
if (direction == MixDirection.out && pose == MixPose.setup) { if (direction == MixDirection.out && blend == MixBlend.setup) {
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 (pose == MixPose.setup) { if (blend == MixBlend.setup || blend == MixBlend.first) {
var attachmentName_2 = slot.data.attachmentName; var attachmentName_2 = slot.data.attachmentName;
slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2)); slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2));
} }
@ -646,24 +695,24 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.frameVertices[frameIndex] = vertices; this.frameVertices[frameIndex] = vertices;
}; };
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
var slotAttachment = slot.getAttachment(); var slotAttachment = slot.getAttachment();
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment)) if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
return; return;
var verticesArray = slot.attachmentVertices; var verticesArray = slot.attachmentVertices;
if (verticesArray.length == 0) if (verticesArray.length == 0)
alpha = 1; blend = MixBlend.setup;
var frameVertices = this.frameVertices; var frameVertices = this.frameVertices;
var vertexCount = frameVertices[0].length; var vertexCount = frameVertices[0].length;
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
var vertexAttachment = slotAttachment; var vertexAttachment = slotAttachment;
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
verticesArray.length = 0; verticesArray.length = 0;
return; return;
case MixPose.current: case MixBlend.first:
if (alpha == 1) { if (alpha == 1) {
verticesArray.length = 0; verticesArray.length = 0;
break; break;
@ -686,25 +735,57 @@ var spine;
if (time >= frames[frames.length - 1]) { if (time >= frames[frames.length - 1]) {
var lastVertices = frameVertices[frames.length - 1]; var lastVertices = frameVertices[frames.length - 1];
if (alpha == 1) { if (alpha == 1) {
spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount); if (blend == MixBlend.add) {
} var vertexAttachment = slotAttachment;
else if (pose == MixPose.setup) { if (vertexAttachment.bones == null) {
var vertexAttachment = slotAttachment; var setupVertices_1 = vertexAttachment.vertices;
if (vertexAttachment.bones == null) { for (var i_1 = 0; i_1 < vertexCount; i_1++) {
var setupVertices_1 = vertexAttachment.vertices; vertices[i_1] += lastVertices[i_1] - setupVertices_1[i_1];
for (var i_1 = 0; i_1 < vertexCount; i_1++) { }
var setup = setupVertices_1[i_1]; }
vertices[i_1] = setup + (lastVertices[i_1] - setup) * alpha; else {
for (var i_2 = 0; i_2 < vertexCount; i_2++)
vertices[i_2] += lastVertices[i_2];
} }
} }
else { else {
for (var i_2 = 0; i_2 < vertexCount; i_2++) spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount);
vertices[i_2] = lastVertices[i_2] * alpha;
} }
} }
else { else {
for (var i_3 = 0; i_3 < vertexCount; i_3++) switch (blend) {
vertices[i_3] += (lastVertices[i_3] - vertices[i_3]) * alpha; case MixBlend.setup: {
var vertexAttachment_1 = slotAttachment;
if (vertexAttachment_1.bones == null) {
var setupVertices_2 = vertexAttachment_1.vertices;
for (var i_3 = 0; i_3 < vertexCount; i_3++) {
var setup = setupVertices_2[i_3];
vertices[i_3] = setup + (lastVertices[i_3] - setup) * alpha;
}
}
else {
for (var i_4 = 0; i_4 < vertexCount; i_4++)
vertices[i_4] = lastVertices[i_4] * alpha;
}
break;
}
case MixBlend.first:
case MixBlend.replace:
for (var i_5 = 0; i_5 < vertexCount; i_5++)
vertices[i_5] += (lastVertices[i_5] - vertices[i_5]) * alpha;
case MixBlend.add:
var vertexAttachment = slotAttachment;
if (vertexAttachment.bones == null) {
var setupVertices_3 = vertexAttachment.vertices;
for (var i_6 = 0; i_6 < vertexCount; i_6++) {
vertices[i_6] += (lastVertices[i_6] - setupVertices_3[i_6]) * alpha;
}
}
else {
for (var i_7 = 0; i_7 < vertexCount; i_7++)
vertices[i_7] += lastVertices[i_7] * alpha;
}
}
} }
return; return;
} }
@ -714,31 +795,70 @@ var spine;
var frameTime = frames[frame]; var frameTime = frames[frame];
var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime)); var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime));
if (alpha == 1) { if (alpha == 1) {
for (var i_4 = 0; i_4 < vertexCount; i_4++) { if (blend == MixBlend.add) {
var prev = prevVertices[i_4]; var vertexAttachment = slotAttachment;
vertices[i_4] = prev + (nextVertices[i_4] - prev) * percent; if (vertexAttachment.bones == null) {
} var setupVertices_4 = vertexAttachment.vertices;
} for (var i_8 = 0; i_8 < vertexCount; i_8++) {
else if (pose == MixPose.setup) { var prev = prevVertices[i_8];
var vertexAttachment = slotAttachment; vertices[i_8] += prev + (nextVertices[i_8] - prev) * percent - setupVertices_4[i_8];
if (vertexAttachment.bones == null) { }
var setupVertices_2 = vertexAttachment.vertices; }
for (var i_5 = 0; i_5 < vertexCount; i_5++) { else {
var prev = prevVertices[i_5], setup = setupVertices_2[i_5]; for (var i_9 = 0; i_9 < vertexCount; i_9++) {
vertices[i_5] = setup + (prev + (nextVertices[i_5] - prev) * percent - setup) * alpha; var prev = prevVertices[i_9];
vertices[i_9] += prev + (nextVertices[i_9] - prev) * percent;
}
} }
} }
else { else {
for (var i_6 = 0; i_6 < vertexCount; i_6++) { for (var i_10 = 0; i_10 < vertexCount; i_10++) {
var prev = prevVertices[i_6]; var prev = prevVertices[i_10];
vertices[i_6] = (prev + (nextVertices[i_6] - prev) * percent) * alpha; vertices[i_10] = prev + (nextVertices[i_10] - prev) * percent;
} }
} }
} }
else { else {
for (var i_7 = 0; i_7 < vertexCount; i_7++) { switch (blend) {
var prev = prevVertices[i_7]; case MixBlend.setup: {
vertices[i_7] += (prev + (nextVertices[i_7] - prev) * percent - vertices[i_7]) * alpha; var vertexAttachment_2 = slotAttachment;
if (vertexAttachment_2.bones == null) {
var setupVertices_5 = vertexAttachment_2.vertices;
for (var i_11 = 0; i_11 < vertexCount; i_11++) {
var prev = prevVertices[i_11], setup = setupVertices_5[i_11];
vertices[i_11] = setup + (prev + (nextVertices[i_11] - prev) * percent - setup) * alpha;
}
}
else {
for (var i_12 = 0; i_12 < vertexCount; i_12++) {
var prev = prevVertices[i_12];
vertices[i_12] = (prev + (nextVertices[i_12] - prev) * percent) * alpha;
}
}
break;
}
case MixBlend.first:
case MixBlend.replace:
for (var i_13 = 0; i_13 < vertexCount; i_13++) {
var prev = prevVertices[i_13];
vertices[i_13] += (prev + (nextVertices[i_13] - prev) * percent - vertices[i_13]) * alpha;
}
break;
case MixBlend.add:
var vertexAttachment = slotAttachment;
if (vertexAttachment.bones == null) {
var setupVertices_6 = vertexAttachment.vertices;
for (var i_14 = 0; i_14 < vertexCount; i_14++) {
var prev = prevVertices[i_14];
vertices[i_14] += (prev + (nextVertices[i_14] - prev) * percent - setupVertices_6[i_14]) * alpha;
}
}
else {
for (var i_15 = 0; i_15 < vertexCount; i_15++) {
var prev = prevVertices[i_15];
vertices[i_15] += (prev + (nextVertices[i_15] - prev) * percent) * alpha;
}
}
} }
} }
}; };
@ -760,13 +880,13 @@ var spine;
this.frames[frameIndex] = event.time; this.frames[frameIndex] = event.time;
this.events[frameIndex] = event; this.events[frameIndex] = event;
}; };
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
if (firedEvents == null) if (firedEvents == null)
return; return;
var frames = this.frames; var frames = this.frames;
var frameCount = this.frames.length; var frameCount = this.frames.length;
if (lastTime > time) { if (lastTime > time) {
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, pose, direction); this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, blend, direction);
lastTime = -1; lastTime = -1;
} }
else if (lastTime >= frames[frameCount - 1]) else if (lastTime >= frames[frameCount - 1])
@ -806,16 +926,16 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.drawOrders[frameIndex] = drawOrder; this.drawOrders[frameIndex] = drawOrder;
}; };
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var drawOrder = skeleton.drawOrder; var drawOrder = skeleton.drawOrder;
var slots = skeleton.slots; var slots = skeleton.slots;
if (direction == MixDirection.out && pose == MixPose.setup) { if (direction == MixDirection.out && blend == MixBlend.setup) {
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
return; return;
} }
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
if (pose == MixPose.setup) if (blend == MixBlend.setup)
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
return; return;
} }
@ -851,23 +971,23 @@ var spine;
this.frames[frameIndex + IkConstraintTimeline.MIX] = mix; this.frames[frameIndex + IkConstraintTimeline.MIX] = mix;
this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection; this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection;
}; };
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.ikConstraints[this.ikConstraintIndex]; var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.mix = constraint.data.mix; constraint.mix = constraint.data.mix;
constraint.bendDirection = constraint.data.bendDirection; constraint.bendDirection = constraint.data.bendDirection;
return; return;
case MixPose.current: case MixBlend.first:
constraint.mix += (constraint.data.mix - constraint.mix) * alpha; constraint.mix += (constraint.data.mix - constraint.mix) * alpha;
constraint.bendDirection = constraint.data.bendDirection; constraint.bendDirection = constraint.data.bendDirection;
} }
return; return;
} }
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) { if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
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;
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection
: frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION]; : frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
@ -883,7 +1003,7 @@ var spine;
var mix = frames[frame + IkConstraintTimeline.PREV_MIX]; var mix = frames[frame + IkConstraintTimeline.PREV_MIX];
var frameTime = frames[frame]; var frameTime = frames[frame];
var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime));
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha; constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha;
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
} }
@ -920,19 +1040,19 @@ var spine;
this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix; this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix;
this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix; this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix;
}; };
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.transformConstraints[this.transformConstraintIndex]; var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
var data = constraint.data; var data = constraint.data;
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.rotateMix = data.rotateMix; constraint.rotateMix = data.rotateMix;
constraint.translateMix = data.translateMix; constraint.translateMix = data.translateMix;
constraint.scaleMix = data.scaleMix; constraint.scaleMix = data.scaleMix;
constraint.shearMix = data.shearMix; constraint.shearMix = data.shearMix;
return; return;
case MixPose.current: case MixBlend.setup:
constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha; constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha;
constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha; constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha;
constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha; constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha;
@ -961,7 +1081,7 @@ var spine;
scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent; scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent;
shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent; shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent;
} }
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
var data = constraint.data; var 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;
@ -1003,15 +1123,15 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value; this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value;
}; };
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.position = constraint.data.position; constraint.position = constraint.data.position;
return; return;
case MixPose.current: case MixBlend.first:
constraint.position += (constraint.data.position - constraint.position) * alpha; constraint.position += (constraint.data.position - constraint.position) * alpha;
} }
return; return;
@ -1026,7 +1146,7 @@ var spine;
var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime));
position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent; position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent;
} }
if (pose == MixPose.setup) if (blend == MixBlend.setup)
constraint.position = constraint.data.position + (position - constraint.data.position) * alpha; constraint.position = constraint.data.position + (position - constraint.data.position) * alpha;
else else
constraint.position += (position - constraint.position) * alpha; constraint.position += (position - constraint.position) * alpha;
@ -1046,15 +1166,15 @@ var spine;
PathConstraintSpacingTimeline.prototype.getPropertyId = function () { PathConstraintSpacingTimeline.prototype.getPropertyId = function () {
return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex; return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex;
}; };
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.spacing = constraint.data.spacing; constraint.spacing = constraint.data.spacing;
return; return;
case MixPose.current: case MixBlend.first:
constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha; constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha;
} }
return; return;
@ -1069,7 +1189,7 @@ var spine;
var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime));
spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent; spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent;
} }
if (pose == MixPose.setup) if (blend == MixBlend.setup)
constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha; constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;
else else
constraint.spacing += (spacing - constraint.spacing) * alpha; constraint.spacing += (spacing - constraint.spacing) * alpha;
@ -1093,16 +1213,16 @@ var spine;
this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix; this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix;
this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix; this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix;
}; };
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.rotateMix = constraint.data.rotateMix; constraint.rotateMix = constraint.data.rotateMix;
constraint.translateMix = constraint.data.translateMix; constraint.translateMix = constraint.data.translateMix;
return; return;
case MixPose.current: case MixBlend.first:
constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha; constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha;
constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha; constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha;
} }
@ -1122,7 +1242,7 @@ var spine;
rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent; rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent;
translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent; translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent;
} }
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha; constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha;
constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha; constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha;
} }
@ -1238,18 +1358,18 @@ var spine;
if (current == null || current.delay > 0) if (current == null || current.delay > 0)
continue; continue;
applied = true; applied = true;
var currentPose = i == 0 ? spine.MixPose.current : spine.MixPose.currentLayered; var blend = i == 0 ? spine.MixBlend.first : current.mixBlend;
var mix = current.alpha; var mix = current.alpha;
if (current.mixingFrom != null) if (current.mixingFrom != null)
mix *= this.applyMixingFrom(current, skeleton, currentPose); mix *= this.applyMixingFrom(current, skeleton, blend);
else if (current.trackTime >= current.trackEnd && current.next == null) else if (current.trackTime >= current.trackEnd && current.next == null)
mix = 0; mix = 0;
var animationLast = current.animationLast, animationTime = current.getAnimationTime(); var animationLast = current.animationLast, animationTime = current.getAnimationTime();
var timelineCount = current.animation.timelines.length; var timelineCount = current.animation.timelines.length;
var timelines = current.animation.timelines; var timelines = current.animation.timelines;
if (mix == 1) { if (mix == 1 || blend == spine.MixBlend.add) {
for (var ii = 0; ii < timelineCount; ii++) for (var ii = 0; ii < timelineCount; ii++)
timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, spine.MixPose.setup, spine.MixDirection["in"]); timelines[ii].apply(skeleton, animationLast, animationTime, events, mix, blend, spine.MixDirection["in"]);
} }
else { else {
var timelineData = current.timelineData; var timelineData = current.timelineData;
@ -1259,12 +1379,12 @@ var spine;
var timelinesRotation = current.timelinesRotation; var timelinesRotation = current.timelinesRotation;
for (var ii = 0; ii < timelineCount; ii++) { for (var ii = 0; ii < timelineCount; ii++) {
var timeline = timelines[ii]; var timeline = timelines[ii];
var pose = timelineData[ii] >= AnimationState.FIRST ? spine.MixPose.setup : currentPose; var timelineBlend = timelineData[ii] == AnimationState.SUBSEQUENT ? blend : spine.MixBlend.setup;
if (timeline instanceof spine.RotateTimeline) { if (timeline instanceof spine.RotateTimeline) {
this.applyRotateTimeline(timeline, skeleton, animationTime, mix, pose, timelinesRotation, ii << 1, firstFrame); this.applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineBlend, timelinesRotation, ii << 1, firstFrame);
} }
else else
timeline.apply(skeleton, animationLast, animationTime, events, mix, pose, spine.MixDirection["in"]); timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineBlend, spine.MixDirection["in"]);
} }
} }
this.queueEvents(current, animationTime); this.queueEvents(current, animationTime);
@ -1275,65 +1395,74 @@ var spine;
this.queue.drain(); this.queue.drain();
return applied; return applied;
}; };
AnimationState.prototype.applyMixingFrom = function (to, skeleton, currentPose) { AnimationState.prototype.applyMixingFrom = function (to, skeleton, blend) {
var from = to.mixingFrom; var from = to.mixingFrom;
if (from.mixingFrom != null) if (from.mixingFrom != null)
this.applyMixingFrom(from, skeleton, currentPose); this.applyMixingFrom(from, skeleton, blend);
var mix = 0; var mix = 0;
if (to.mixDuration == 0) { if (to.mixDuration == 0) {
mix = 1; mix = 1;
currentPose = spine.MixPose.setup; if (blend == spine.MixBlend.first)
blend = spine.MixBlend.setup;
} }
else { else {
mix = to.mixTime / to.mixDuration; mix = to.mixTime / to.mixDuration;
if (mix > 1) if (mix > 1)
mix = 1; mix = 1;
if (blend != spine.MixBlend.first)
blend = from.mixBlend;
} }
var events = mix < from.eventThreshold ? this.events : null; var events = mix < from.eventThreshold ? this.events : null;
var attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold; var attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold;
var animationLast = from.animationLast, animationTime = from.getAnimationTime(); var animationLast = from.animationLast, animationTime = from.getAnimationTime();
var timelineCount = from.animation.timelines.length; var timelineCount = from.animation.timelines.length;
var timelines = from.animation.timelines; var timelines = from.animation.timelines;
var timelineData = from.timelineData; var alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix);
var timelineDipMix = from.timelineDipMix; if (blend == spine.MixBlend.add) {
var firstFrame = from.timelinesRotation.length == 0; for (var i = 0; i < timelineCount; i++)
if (firstFrame) timelines[i].apply(skeleton, animationLast, animationTime, events, alphaMix, blend, spine.MixDirection.out);
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null); }
var timelinesRotation = from.timelinesRotation; else {
var pose; var timelineData = from.timelineData;
var alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix), alpha = 0; var timelineDipMix = from.timelineDipMix;
from.totalAlpha = 0; var firstFrame = from.timelinesRotation.length == 0;
for (var i = 0; i < timelineCount; i++) { if (firstFrame)
var timeline = timelines[i]; spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
switch (timelineData[i]) { var timelinesRotation = from.timelinesRotation;
case AnimationState.SUBSEQUENT: from.totalAlpha = 0;
if (!attachments && timeline instanceof spine.AttachmentTimeline) for (var i = 0; i < timelineCount; i++) {
continue; var timeline = timelines[i];
if (!drawOrder && timeline instanceof spine.DrawOrderTimeline) var timelineBlend;
continue; var alpha = 0;
pose = currentPose; switch (timelineData[i]) {
alpha = alphaMix; case AnimationState.SUBSEQUENT:
break; if (!attachments && timeline instanceof spine.AttachmentTimeline)
case AnimationState.FIRST: continue;
pose = spine.MixPose.setup; if (!drawOrder && timeline instanceof spine.DrawOrderTimeline)
alpha = alphaMix; continue;
break; timelineBlend = blend;
case AnimationState.DIP: alpha = alphaMix;
pose = spine.MixPose.setup; break;
alpha = alphaDip; case AnimationState.FIRST:
break; timelineBlend = spine.MixBlend.setup;
default: alpha = alphaMix;
pose = spine.MixPose.setup; break;
alpha = alphaDip; case AnimationState.DIP:
var dipMix = timelineDipMix[i]; timelineBlend = spine.MixBlend.setup;
alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration); alpha = alphaDip;
break; break;
} default:
from.totalAlpha += alpha; timelineBlend = spine.MixBlend.setup;
if (timeline instanceof spine.RotateTimeline) var dipMix = timelineDipMix[i];
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame); alpha = alphaDip * Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
else { break;
timeline.apply(skeleton, animationLast, animationTime, events, alpha, pose, spine.MixDirection.out); }
from.totalAlpha += alpha;
if (timeline instanceof spine.RotateTimeline)
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, timelineBlend, timelinesRotation, i << 1, firstFrame);
else {
timeline.apply(skeleton, animationLast, animationTime, events, alpha, timelineBlend, spine.MixDirection.out);
}
} }
} }
if (to.mixDuration > 0) if (to.mixDuration > 0)
@ -1343,18 +1472,18 @@ var spine;
from.nextTrackLast = from.trackTime; from.nextTrackLast = from.trackTime;
return mix; return mix;
}; };
AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, pose, timelinesRotation, i, firstFrame) { AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, blend, timelinesRotation, i, firstFrame) {
if (firstFrame) if (firstFrame)
timelinesRotation[i] = 0; timelinesRotation[i] = 0;
if (alpha == 1) { if (alpha == 1) {
timeline.apply(skeleton, 0, time, null, 1, pose, spine.MixDirection["in"]); timeline.apply(skeleton, 0, time, null, 1, blend, spine.MixDirection["in"]);
return; return;
} }
var rotateTimeline = timeline; var rotateTimeline = timeline;
var frames = rotateTimeline.frames; var frames = rotateTimeline.frames;
var bone = skeleton.bones[rotateTimeline.boneIndex]; var bone = skeleton.bones[rotateTimeline.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
if (pose == spine.MixPose.setup) if (blend == spine.MixBlend.setup)
bone.rotation = bone.data.rotation; bone.rotation = bone.data.rotation;
return; return;
} }
@ -1371,7 +1500,7 @@ var spine;
r2 = prevRotation + r2 * percent + bone.data.rotation; r2 = prevRotation + r2 * percent + bone.data.rotation;
r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360; r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
} }
var r1 = pose == spine.MixPose.setup ? bone.data.rotation : bone.rotation; var r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation;
var total = 0, diff = r2 - r1; var total = 0, diff = r2 - r1;
if (diff == 0) { if (diff == 0) {
total = timelinesRotation[i]; total = timelinesRotation[i];
@ -1601,7 +1730,7 @@ var spine;
var mixingTo = this.mixingTo; var mixingTo = this.mixingTo;
for (var i = 0, n = this.tracks.length; i < n; i++) { for (var i = 0, n = this.tracks.length; i < n; i++) {
var entry = this.tracks[i]; var entry = this.tracks[i];
if (entry != null) if (entry != null && (i == 0 || entry.mixBlend != spine.MixBlend.add))
entry.setTimelineData(null, mixingTo, propertyIDs); entry.setTimelineData(null, mixingTo, propertyIDs);
} }
}; };
@ -1636,6 +1765,7 @@ var spine;
spine.AnimationState = AnimationState; spine.AnimationState = AnimationState;
var TrackEntry = (function () { var TrackEntry = (function () {
function TrackEntry() { function TrackEntry() {
this.mixBlend = spine.MixBlend.replace;
this.timelineData = new Array(); this.timelineData = new Array();
this.timelineDipMix = new Array(); this.timelineDipMix = new Array();
this.timelinesRotation = new Array(); this.timelinesRotation = new Array();
@ -7055,8 +7185,8 @@ var spine;
break; break;
} }
var listeners = _this.listeners; var listeners = _this.listeners;
for (var i_8 = 0; i_8 < listeners.length; i_8++) { for (var i_16 = 0; i_16 < listeners.length; i_16++) {
listeners[i_8].down(_this.currTouch.x, _this.currTouch.y); listeners[i_16].down(_this.currTouch.x, _this.currTouch.y);
} }
console.log("Start " + _this.currTouch.x + ", " + _this.currTouch.y); console.log("Start " + _this.currTouch.x + ", " + _this.currTouch.y);
_this.lastX = _this.currTouch.x; _this.lastX = _this.currTouch.x;
@ -7074,8 +7204,8 @@ var spine;
var y = _this.currTouch.y = touch.clientY - rect.top; var y = _this.currTouch.y = touch.clientY - rect.top;
_this.touchesPool.free(_this.currTouch); _this.touchesPool.free(_this.currTouch);
var listeners = _this.listeners; var listeners = _this.listeners;
for (var i_9 = 0; i_9 < listeners.length; i_9++) { for (var i_17 = 0; i_17 < listeners.length; i_17++) {
listeners[i_9].up(x, y); listeners[i_17].up(x, y);
} }
console.log("End " + x + ", " + y); console.log("End " + x + ", " + y);
_this.lastX = x; _this.lastX = x;
@ -7097,8 +7227,8 @@ var spine;
var y = _this.currTouch.y = touch.clientY - rect.top; var y = _this.currTouch.y = touch.clientY - rect.top;
_this.touchesPool.free(_this.currTouch); _this.touchesPool.free(_this.currTouch);
var listeners = _this.listeners; var listeners = _this.listeners;
for (var i_10 = 0; i_10 < listeners.length; i_10++) { for (var i_18 = 0; i_18 < listeners.length; i_18++) {
listeners[i_10].up(x, y); listeners[i_18].up(x, y);
} }
console.log("End " + x + ", " + y); console.log("End " + x + ", " + y);
_this.lastX = x; _this.lastX = x;
@ -7121,8 +7251,8 @@ var spine;
var x = touch.clientX - rect.left; var x = touch.clientX - rect.left;
var y = touch.clientY - rect.top; var y = touch.clientY - rect.top;
var listeners = _this.listeners; var listeners = _this.listeners;
for (var i_11 = 0; i_11 < listeners.length; i_11++) { for (var i_19 = 0; i_19 < listeners.length; i_19++) {
listeners[i_11].dragged(x, y); listeners[i_19].dragged(x, y);
} }
console.log("Drag " + x + ", " + y); console.log("Drag " + x + ", " + y);
_this.lastX = _this.currTouch.x = x; _this.lastX = _this.currTouch.x = x;
@ -8970,11 +9100,11 @@ var spine;
var nn = clip.worldVerticesLength; var nn = clip.worldVerticesLength;
var world = this.temp = spine.Utils.setArraySize(this.temp, nn, 0); var world = this.temp = spine.Utils.setArraySize(this.temp, nn, 0);
clip.computeWorldVertices(slot, 0, nn, world, 0, 2); clip.computeWorldVertices(slot, 0, nn, world, 0, 2);
for (var i_12 = 0, n_2 = world.length; i_12 < n_2; i_12 += 2) { for (var i_20 = 0, n_2 = world.length; i_20 < n_2; i_20 += 2) {
var x = world[i_12]; var x = world[i_20];
var y = world[i_12 + 1]; var y = world[i_20 + 1];
var x2 = world[(i_12 + 2) % world.length]; var x2 = world[(i_20 + 2) % world.length];
var y2 = world[(i_12 + 3) % world.length]; var y2 = world[(i_20 + 3) % world.length];
shapes.line(x, y, x2, y2); shapes.line(x, y, x2, y2);
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -4,18 +4,19 @@ declare module spine {
timelines: Array<Timeline>; timelines: Array<Timeline>;
duration: number; duration: number;
constructor(name: string, timelines: Array<Timeline>, duration: number); constructor(name: string, timelines: Array<Timeline>, duration: number);
apply(skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
static binarySearch(values: ArrayLike<number>, target: number, step?: number): number; static binarySearch(values: ArrayLike<number>, target: number, step?: number): number;
static linearSearch(values: ArrayLike<number>, target: number, step: number): number; static linearSearch(values: ArrayLike<number>, target: number, step: number): number;
} }
interface Timeline { interface Timeline {
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
getPropertyId(): number; getPropertyId(): number;
} }
enum MixPose { enum MixBlend {
setup = 0, setup = 0,
current = 1, first = 1,
currentLayered = 2, replace = 2,
add = 3,
} }
enum MixDirection { enum MixDirection {
in = 0, in = 0,
@ -52,7 +53,7 @@ declare module spine {
getCurveType(frameIndex: number): number; getCurveType(frameIndex: number): number;
setCurve(frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void; setCurve(frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void;
getCurvePercent(frameIndex: number, percent: number): number; getCurvePercent(frameIndex: number, percent: number): number;
abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class RotateTimeline extends CurveTimeline { class RotateTimeline extends CurveTimeline {
static ENTRIES: number; static ENTRIES: number;
@ -64,7 +65,7 @@ declare module spine {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
setFrame(frameIndex: number, time: number, degrees: number): void; setFrame(frameIndex: number, time: number, degrees: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class TranslateTimeline extends CurveTimeline { class TranslateTimeline extends CurveTimeline {
static ENTRIES: number; static ENTRIES: number;
@ -78,17 +79,17 @@ declare module spine {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
setFrame(frameIndex: number, time: number, x: number, y: number): void; setFrame(frameIndex: number, time: number, x: number, y: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class ScaleTimeline extends TranslateTimeline { class ScaleTimeline extends TranslateTimeline {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class ShearTimeline extends TranslateTimeline { class ShearTimeline extends TranslateTimeline {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class ColorTimeline extends CurveTimeline { class ColorTimeline extends CurveTimeline {
static ENTRIES: number; static ENTRIES: number;
@ -106,7 +107,7 @@ declare module spine {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number): void; setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class TwoColorTimeline extends CurveTimeline { class TwoColorTimeline extends CurveTimeline {
static ENTRIES: number; static ENTRIES: number;
@ -130,7 +131,7 @@ declare module spine {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number, r2: number, g2: number, b2: number): void; setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number, r2: number, g2: number, b2: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class AttachmentTimeline implements Timeline { class AttachmentTimeline implements Timeline {
slotIndex: number; slotIndex: number;
@ -140,7 +141,7 @@ declare module spine {
getPropertyId(): number; getPropertyId(): number;
getFrameCount(): number; getFrameCount(): number;
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, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class DeformTimeline extends CurveTimeline { class DeformTimeline extends CurveTimeline {
slotIndex: number; slotIndex: number;
@ -150,7 +151,7 @@ declare module spine {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void; setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class EventTimeline implements Timeline { class EventTimeline implements Timeline {
frames: ArrayLike<number>; frames: ArrayLike<number>;
@ -159,7 +160,7 @@ declare module spine {
getPropertyId(): number; getPropertyId(): number;
getFrameCount(): number; getFrameCount(): number;
setFrame(frameIndex: number, event: Event): void; setFrame(frameIndex: number, event: Event): void;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class DrawOrderTimeline implements Timeline { class DrawOrderTimeline implements Timeline {
frames: ArrayLike<number>; frames: ArrayLike<number>;
@ -168,7 +169,7 @@ declare module spine {
getPropertyId(): number; getPropertyId(): number;
getFrameCount(): number; getFrameCount(): number;
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, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class IkConstraintTimeline extends CurveTimeline { class IkConstraintTimeline extends CurveTimeline {
static ENTRIES: number; static ENTRIES: number;
@ -182,7 +183,7 @@ declare module spine {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
setFrame(frameIndex: number, time: number, mix: number, bendDirection: number): void; setFrame(frameIndex: number, time: number, mix: number, bendDirection: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class TransformConstraintTimeline extends CurveTimeline { class TransformConstraintTimeline extends CurveTimeline {
static ENTRIES: number; static ENTRIES: number;
@ -200,7 +201,7 @@ declare module spine {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number, scaleMix: number, shearMix: number): void; setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number, scaleMix: number, shearMix: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class PathConstraintPositionTimeline extends CurveTimeline { class PathConstraintPositionTimeline extends CurveTimeline {
static ENTRIES: number; static ENTRIES: number;
@ -212,12 +213,12 @@ declare module spine {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
setFrame(frameIndex: number, time: number, value: number): void; setFrame(frameIndex: number, time: number, value: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class PathConstraintSpacingTimeline extends PathConstraintPositionTimeline { class PathConstraintSpacingTimeline extends PathConstraintPositionTimeline {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
class PathConstraintMixTimeline extends CurveTimeline { class PathConstraintMixTimeline extends CurveTimeline {
static ENTRIES: number; static ENTRIES: number;
@ -231,7 +232,7 @@ declare module spine {
constructor(frameCount: number); constructor(frameCount: number);
getPropertyId(): number; getPropertyId(): number;
setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number): void; setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number): void;
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void; apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection): void;
} }
} }
declare module spine { declare module spine {
@ -255,8 +256,8 @@ declare module spine {
update(delta: number): void; update(delta: number): void;
updateMixingFrom(to: TrackEntry, delta: number): boolean; updateMixingFrom(to: TrackEntry, delta: number): boolean;
apply(skeleton: Skeleton): boolean; apply(skeleton: Skeleton): boolean;
applyMixingFrom(to: TrackEntry, skeleton: Skeleton, currentPose: MixPose): number; applyMixingFrom(to: TrackEntry, skeleton: Skeleton, blend: MixBlend): number;
applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, pose: MixPose, timelinesRotation: Array<number>, i: number, firstFrame: boolean): void; applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, blend: MixBlend, timelinesRotation: Array<number>, i: number, firstFrame: boolean): void;
queueEvents(entry: TrackEntry, animationTime: number): void; queueEvents(entry: TrackEntry, animationTime: number): void;
clearTracks(): void; clearTracks(): void;
clearTrack(trackIndex: number): void; clearTrack(trackIndex: number): void;
@ -303,6 +304,7 @@ declare module spine {
mixDuration: number; mixDuration: number;
interruptAlpha: number; interruptAlpha: number;
totalAlpha: number; totalAlpha: number;
mixBlend: MixBlend;
timelineData: number[]; timelineData: number[];
timelineDipMix: TrackEntry[]; timelineDipMix: TrackEntry[];
timelinesRotation: number[]; timelinesRotation: number[];

View File

@ -20,7 +20,7 @@ var spine;
this.timelines = timelines; this.timelines = timelines;
this.duration = duration; this.duration = duration;
} }
Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, pose, direction) { Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, blend, direction) {
if (skeleton == null) if (skeleton == null)
throw new Error("skeleton cannot be null."); throw new Error("skeleton cannot be null.");
if (loop && this.duration != 0) { if (loop && this.duration != 0) {
@ -30,7 +30,7 @@ var spine;
} }
var timelines = this.timelines; var timelines = this.timelines;
for (var i = 0, n = timelines.length; i < n; i++) for (var i = 0, n = timelines.length; i < n; i++)
timelines[i].apply(skeleton, lastTime, time, events, alpha, pose, direction); timelines[i].apply(skeleton, lastTime, time, events, alpha, blend, direction);
}; };
Animation.binarySearch = function (values, target, step) { Animation.binarySearch = function (values, target, step) {
if (step === void 0) { step = 1; } if (step === void 0) { step = 1; }
@ -58,12 +58,13 @@ var spine;
return Animation; return Animation;
}()); }());
spine.Animation = Animation; spine.Animation = Animation;
var MixPose; var MixBlend;
(function (MixPose) { (function (MixBlend) {
MixPose[MixPose["setup"] = 0] = "setup"; MixBlend[MixBlend["setup"] = 0] = "setup";
MixPose[MixPose["current"] = 1] = "current"; MixBlend[MixBlend["first"] = 1] = "first";
MixPose[MixPose["currentLayered"] = 2] = "currentLayered"; MixBlend[MixBlend["replace"] = 2] = "replace";
})(MixPose = spine.MixPose || (spine.MixPose = {})); MixBlend[MixBlend["add"] = 3] = "add";
})(MixBlend = spine.MixBlend || (spine.MixBlend = {}));
var MixDirection; var MixDirection;
(function (MixDirection) { (function (MixDirection) {
MixDirection[MixDirection["in"] = 0] = "in"; MixDirection[MixDirection["in"] = 0] = "in";
@ -184,28 +185,32 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.frames[frameIndex + RotateTimeline.ROTATION] = degrees; this.frames[frameIndex + RotateTimeline.ROTATION] = degrees;
}; };
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.rotation = bone.data.rotation; bone.rotation = bone.data.rotation;
return; return;
case MixPose.current: case MixBlend.first:
var r_1 = bone.data.rotation - bone.rotation; var r_1 = bone.data.rotation - bone.rotation;
r_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360; bone.rotation += (r_1 - (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360) * alpha;
bone.rotation += r_1 * alpha;
} }
return; return;
} }
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) { if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
if (pose == MixPose.setup) var r = frames[frames.length + RotateTimeline.PREV_ROTATION];
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha; switch (blend) {
else { case MixBlend.setup:
var r_2 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation; bone.rotation = bone.data.rotation + r * alpha;
r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360; break;
bone.rotation += r_2 * alpha; case MixBlend.first:
case MixBlend.replace:
r += bone.data.rotation - bone.rotation;
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
case MixBlend.add:
bone.rotation += r * alpha;
} }
return; return;
} }
@ -213,17 +218,17 @@ var spine;
var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION]; var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION];
var frameTime = frames[frame]; var frameTime = frames[frame];
var percent = this.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime));
var r = frames[frame + RotateTimeline.ROTATION] - prevRotation; r = frames[frame + RotateTimeline.ROTATION] - prevRotation;
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; r = prevRotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * percent;
r = prevRotation + r * percent; switch (blend) {
if (pose == MixPose.setup) { case MixBlend.setup:
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; bone.rotation = bone.data.rotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha;
bone.rotation = bone.data.rotation + r * alpha; break;
} case MixBlend.first:
else { case MixBlend.replace:
r = bone.data.rotation + r - bone.rotation; r += bone.data.rotation - bone.rotation;
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; case MixBlend.add:
bone.rotation += r * alpha; bone.rotation += (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha;
} }
}; };
return RotateTimeline; return RotateTimeline;
@ -249,16 +254,16 @@ var spine;
this.frames[frameIndex + TranslateTimeline.X] = x; this.frames[frameIndex + TranslateTimeline.X] = x;
this.frames[frameIndex + TranslateTimeline.Y] = y; this.frames[frameIndex + TranslateTimeline.Y] = y;
}; };
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.x = bone.data.x; bone.x = bone.data.x;
bone.y = bone.data.y; bone.y = bone.data.y;
return; return;
case MixPose.current: case MixBlend.first:
bone.x += (bone.data.x - bone.x) * alpha; bone.x += (bone.data.x - bone.x) * alpha;
bone.y += (bone.data.y - bone.y) * alpha; bone.y += (bone.data.y - bone.y) * alpha;
} }
@ -278,13 +283,19 @@ var spine;
x += (frames[frame + TranslateTimeline.X] - x) * percent; x += (frames[frame + TranslateTimeline.X] - x) * percent;
y += (frames[frame + TranslateTimeline.Y] - y) * percent; y += (frames[frame + TranslateTimeline.Y] - y) * percent;
} }
if (pose == MixPose.setup) { switch (blend) {
bone.x = bone.data.x + x * alpha; case MixBlend.setup:
bone.y = bone.data.y + y * alpha; bone.x = bone.data.x + x * alpha;
} bone.y = bone.data.y + y * alpha;
else { break;
bone.x += (bone.data.x + x - bone.x) * alpha; case MixBlend.first:
bone.y += (bone.data.y + y - bone.y) * alpha; case MixBlend.replace:
bone.x += (bone.data.x + x - bone.x) * alpha;
bone.y += (bone.data.y + y - bone.y) * alpha;
break;
case MixBlend.add:
bone.x += x * alpha;
bone.y += y * alpha;
} }
}; };
return TranslateTimeline; return TranslateTimeline;
@ -304,16 +315,16 @@ var spine;
ScaleTimeline.prototype.getPropertyId = function () { ScaleTimeline.prototype.getPropertyId = function () {
return (TimelineType.scale << 24) + this.boneIndex; return (TimelineType.scale << 24) + this.boneIndex;
}; };
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.scaleX = bone.data.scaleX; bone.scaleX = bone.data.scaleX;
bone.scaleY = bone.data.scaleY; bone.scaleY = bone.data.scaleY;
return; return;
case MixPose.current: case MixBlend.first:
bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha; bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;
bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha; bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;
} }
@ -334,29 +345,61 @@ var spine;
y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY; y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY;
} }
if (alpha == 1) { if (alpha == 1) {
bone.scaleX = x; if (blend == MixBlend.add) {
bone.scaleY = y; bone.scaleX += x - bone.data.scaleX;
bone.scaleY += y - bone.data.scaleY;
}
else {
bone.scaleX = x;
bone.scaleY = y;
}
} }
else { else {
var bx = 0, by = 0; var bx = 0, by = 0;
if (pose == MixPose.setup) {
bx = bone.data.scaleX;
by = bone.data.scaleY;
}
else {
bx = bone.scaleX;
by = bone.scaleY;
}
if (direction == MixDirection.out) { if (direction == MixDirection.out) {
x = Math.abs(x) * spine.MathUtils.signum(bx); switch (blend) {
y = Math.abs(y) * spine.MathUtils.signum(by); case MixBlend.setup:
bx = bone.data.scaleX;
by = bone.data.scaleY;
bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bx) * alpha;
bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - by) * alpha;
break;
case MixBlend.first:
case MixBlend.replace:
bx = bone.scaleX;
by = bone.scaleY;
bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bx) * alpha;
bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - by) * alpha;
break;
case MixBlend.add:
bx = bone.scaleX;
by = bone.scaleY;
bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bone.data.scaleX) * alpha;
bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - bone.data.scaleY) * alpha;
}
} }
else { else {
bx = Math.abs(bx) * spine.MathUtils.signum(x); switch (blend) {
by = Math.abs(by) * spine.MathUtils.signum(y); case MixBlend.setup:
bx = Math.abs(bone.data.scaleX) * spine.MathUtils.signum(x);
by = Math.abs(bone.data.scaleY) * spine.MathUtils.signum(y);
bone.scaleX = bx + (x - bx) * alpha;
bone.scaleY = by + (y - by) * alpha;
break;
case MixBlend.first:
case MixBlend.replace:
bx = Math.abs(bone.scaleX) * spine.MathUtils.signum(x);
by = Math.abs(bone.scaleY) * spine.MathUtils.signum(y);
bone.scaleX = bx + (x - bx) * alpha;
bone.scaleY = by + (y - by) * alpha;
break;
case MixBlend.add:
bx = spine.MathUtils.signum(x);
by = spine.MathUtils.signum(y);
bone.scaleX = Math.abs(bone.scaleX) * bx + (x - Math.abs(bone.data.scaleX) * bx) * alpha;
bone.scaleY = Math.abs(bone.scaleY) * by + (y - Math.abs(bone.data.scaleY) * by) * alpha;
}
} }
bone.scaleX = bx + (x - bx) * alpha;
bone.scaleY = by + (y - by) * alpha;
} }
}; };
return ScaleTimeline; return ScaleTimeline;
@ -370,16 +413,16 @@ var spine;
ShearTimeline.prototype.getPropertyId = function () { ShearTimeline.prototype.getPropertyId = function () {
return (TimelineType.shear << 24) + this.boneIndex; return (TimelineType.shear << 24) + this.boneIndex;
}; };
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.shearX = bone.data.shearX; bone.shearX = bone.data.shearX;
bone.shearY = bone.data.shearY; bone.shearY = bone.data.shearY;
return; return;
case MixPose.current: case MixBlend.first:
bone.shearX += (bone.data.shearX - bone.shearX) * alpha; bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
bone.shearY += (bone.data.shearY - bone.shearY) * alpha; bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
} }
@ -399,13 +442,19 @@ var spine;
x = x + (frames[frame + ShearTimeline.X] - x) * percent; x = x + (frames[frame + ShearTimeline.X] - x) * percent;
y = y + (frames[frame + ShearTimeline.Y] - y) * percent; y = y + (frames[frame + ShearTimeline.Y] - y) * percent;
} }
if (pose == MixPose.setup) { switch (blend) {
bone.shearX = bone.data.shearX + x * alpha; case MixBlend.setup:
bone.shearY = bone.data.shearY + y * alpha; bone.shearX = bone.data.shearX + x * alpha;
} bone.shearY = bone.data.shearY + y * alpha;
else { break;
bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha; case MixBlend.first:
bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha; case MixBlend.replace:
bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha;
bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha;
break;
case MixBlend.add:
bone.shearX += x * alpha;
bone.shearY += y * alpha;
} }
}; };
return ShearTimeline; return ShearTimeline;
@ -429,15 +478,15 @@ var spine;
this.frames[frameIndex + ColorTimeline.B] = b; this.frames[frameIndex + ColorTimeline.B] = b;
this.frames[frameIndex + ColorTimeline.A] = a; this.frames[frameIndex + ColorTimeline.A] = a;
}; };
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
slot.color.setFromColor(slot.data.color); slot.color.setFromColor(slot.data.color);
return; return;
case MixPose.current: case MixBlend.first:
var color = slot.color, setup = slot.data.color; var color = slot.color, setup = slot.data.color;
color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha); color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha);
} }
@ -468,7 +517,7 @@ var spine;
slot.color.set(r, g, b, a); slot.color.set(r, g, b, a);
else { else {
var color = slot.color; var color = slot.color;
if (pose == MixPose.setup) if (blend == MixBlend.setup)
color.setFromColor(slot.data.color); color.setFromColor(slot.data.color);
color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha); color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
} }
@ -507,16 +556,16 @@ var spine;
this.frames[frameIndex + TwoColorTimeline.G2] = g2; this.frames[frameIndex + TwoColorTimeline.G2] = g2;
this.frames[frameIndex + TwoColorTimeline.B2] = b2; this.frames[frameIndex + TwoColorTimeline.B2] = b2;
}; };
TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
slot.color.setFromColor(slot.data.color); slot.color.setFromColor(slot.data.color);
slot.darkColor.setFromColor(slot.data.darkColor); slot.darkColor.setFromColor(slot.data.darkColor);
return; return;
case MixPose.current: case MixBlend.setup:
var light = slot.color, dark = slot.darkColor, setupLight = slot.data.color, setupDark = slot.data.darkColor; var light = slot.color, dark = slot.darkColor, setupLight = slot.data.color, setupDark = slot.data.darkColor;
light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha); light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha);
dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0); dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0);
@ -559,7 +608,7 @@ var spine;
} }
else { else {
var light = slot.color, dark = slot.darkColor; var light = slot.color, dark = slot.darkColor;
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
light.setFromColor(slot.data.color); light.setFromColor(slot.data.color);
dark.setFromColor(slot.data.darkColor); dark.setFromColor(slot.data.darkColor);
} }
@ -601,16 +650,16 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.attachmentNames[frameIndex] = attachmentName; this.attachmentNames[frameIndex] = attachmentName;
}; };
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
if (direction == MixDirection.out && pose == MixPose.setup) { if (direction == MixDirection.out && blend == MixBlend.setup) {
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 (pose == MixPose.setup) { if (blend == MixBlend.setup || blend == MixBlend.first) {
var attachmentName_2 = slot.data.attachmentName; var attachmentName_2 = slot.data.attachmentName;
slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2)); slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2));
} }
@ -646,24 +695,24 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.frameVertices[frameIndex] = vertices; this.frameVertices[frameIndex] = vertices;
}; };
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
var slotAttachment = slot.getAttachment(); var slotAttachment = slot.getAttachment();
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment)) if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
return; return;
var verticesArray = slot.attachmentVertices; var verticesArray = slot.attachmentVertices;
if (verticesArray.length == 0) if (verticesArray.length == 0)
alpha = 1; blend = MixBlend.setup;
var frameVertices = this.frameVertices; var frameVertices = this.frameVertices;
var vertexCount = frameVertices[0].length; var vertexCount = frameVertices[0].length;
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
var vertexAttachment = slotAttachment; var vertexAttachment = slotAttachment;
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
verticesArray.length = 0; verticesArray.length = 0;
return; return;
case MixPose.current: case MixBlend.first:
if (alpha == 1) { if (alpha == 1) {
verticesArray.length = 0; verticesArray.length = 0;
break; break;
@ -686,25 +735,57 @@ var spine;
if (time >= frames[frames.length - 1]) { if (time >= frames[frames.length - 1]) {
var lastVertices = frameVertices[frames.length - 1]; var lastVertices = frameVertices[frames.length - 1];
if (alpha == 1) { if (alpha == 1) {
spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount); if (blend == MixBlend.add) {
} var vertexAttachment = slotAttachment;
else if (pose == MixPose.setup) { if (vertexAttachment.bones == null) {
var vertexAttachment = slotAttachment; var setupVertices_1 = vertexAttachment.vertices;
if (vertexAttachment.bones == null) { for (var i_1 = 0; i_1 < vertexCount; i_1++) {
var setupVertices_1 = vertexAttachment.vertices; vertices[i_1] += lastVertices[i_1] - setupVertices_1[i_1];
for (var i_1 = 0; i_1 < vertexCount; i_1++) { }
var setup = setupVertices_1[i_1]; }
vertices[i_1] = setup + (lastVertices[i_1] - setup) * alpha; else {
for (var i_2 = 0; i_2 < vertexCount; i_2++)
vertices[i_2] += lastVertices[i_2];
} }
} }
else { else {
for (var i_2 = 0; i_2 < vertexCount; i_2++) spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount);
vertices[i_2] = lastVertices[i_2] * alpha;
} }
} }
else { else {
for (var i_3 = 0; i_3 < vertexCount; i_3++) switch (blend) {
vertices[i_3] += (lastVertices[i_3] - vertices[i_3]) * alpha; case MixBlend.setup: {
var vertexAttachment_1 = slotAttachment;
if (vertexAttachment_1.bones == null) {
var setupVertices_2 = vertexAttachment_1.vertices;
for (var i_3 = 0; i_3 < vertexCount; i_3++) {
var setup = setupVertices_2[i_3];
vertices[i_3] = setup + (lastVertices[i_3] - setup) * alpha;
}
}
else {
for (var i_4 = 0; i_4 < vertexCount; i_4++)
vertices[i_4] = lastVertices[i_4] * alpha;
}
break;
}
case MixBlend.first:
case MixBlend.replace:
for (var i_5 = 0; i_5 < vertexCount; i_5++)
vertices[i_5] += (lastVertices[i_5] - vertices[i_5]) * alpha;
case MixBlend.add:
var vertexAttachment = slotAttachment;
if (vertexAttachment.bones == null) {
var setupVertices_3 = vertexAttachment.vertices;
for (var i_6 = 0; i_6 < vertexCount; i_6++) {
vertices[i_6] += (lastVertices[i_6] - setupVertices_3[i_6]) * alpha;
}
}
else {
for (var i_7 = 0; i_7 < vertexCount; i_7++)
vertices[i_7] += lastVertices[i_7] * alpha;
}
}
} }
return; return;
} }
@ -714,31 +795,70 @@ var spine;
var frameTime = frames[frame]; var frameTime = frames[frame];
var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime)); var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime));
if (alpha == 1) { if (alpha == 1) {
for (var i_4 = 0; i_4 < vertexCount; i_4++) { if (blend == MixBlend.add) {
var prev = prevVertices[i_4]; var vertexAttachment = slotAttachment;
vertices[i_4] = prev + (nextVertices[i_4] - prev) * percent; if (vertexAttachment.bones == null) {
} var setupVertices_4 = vertexAttachment.vertices;
} for (var i_8 = 0; i_8 < vertexCount; i_8++) {
else if (pose == MixPose.setup) { var prev = prevVertices[i_8];
var vertexAttachment = slotAttachment; vertices[i_8] += prev + (nextVertices[i_8] - prev) * percent - setupVertices_4[i_8];
if (vertexAttachment.bones == null) { }
var setupVertices_2 = vertexAttachment.vertices; }
for (var i_5 = 0; i_5 < vertexCount; i_5++) { else {
var prev = prevVertices[i_5], setup = setupVertices_2[i_5]; for (var i_9 = 0; i_9 < vertexCount; i_9++) {
vertices[i_5] = setup + (prev + (nextVertices[i_5] - prev) * percent - setup) * alpha; var prev = prevVertices[i_9];
vertices[i_9] += prev + (nextVertices[i_9] - prev) * percent;
}
} }
} }
else { else {
for (var i_6 = 0; i_6 < vertexCount; i_6++) { for (var i_10 = 0; i_10 < vertexCount; i_10++) {
var prev = prevVertices[i_6]; var prev = prevVertices[i_10];
vertices[i_6] = (prev + (nextVertices[i_6] - prev) * percent) * alpha; vertices[i_10] = prev + (nextVertices[i_10] - prev) * percent;
} }
} }
} }
else { else {
for (var i_7 = 0; i_7 < vertexCount; i_7++) { switch (blend) {
var prev = prevVertices[i_7]; case MixBlend.setup: {
vertices[i_7] += (prev + (nextVertices[i_7] - prev) * percent - vertices[i_7]) * alpha; var vertexAttachment_2 = slotAttachment;
if (vertexAttachment_2.bones == null) {
var setupVertices_5 = vertexAttachment_2.vertices;
for (var i_11 = 0; i_11 < vertexCount; i_11++) {
var prev = prevVertices[i_11], setup = setupVertices_5[i_11];
vertices[i_11] = setup + (prev + (nextVertices[i_11] - prev) * percent - setup) * alpha;
}
}
else {
for (var i_12 = 0; i_12 < vertexCount; i_12++) {
var prev = prevVertices[i_12];
vertices[i_12] = (prev + (nextVertices[i_12] - prev) * percent) * alpha;
}
}
break;
}
case MixBlend.first:
case MixBlend.replace:
for (var i_13 = 0; i_13 < vertexCount; i_13++) {
var prev = prevVertices[i_13];
vertices[i_13] += (prev + (nextVertices[i_13] - prev) * percent - vertices[i_13]) * alpha;
}
break;
case MixBlend.add:
var vertexAttachment = slotAttachment;
if (vertexAttachment.bones == null) {
var setupVertices_6 = vertexAttachment.vertices;
for (var i_14 = 0; i_14 < vertexCount; i_14++) {
var prev = prevVertices[i_14];
vertices[i_14] += (prev + (nextVertices[i_14] - prev) * percent - setupVertices_6[i_14]) * alpha;
}
}
else {
for (var i_15 = 0; i_15 < vertexCount; i_15++) {
var prev = prevVertices[i_15];
vertices[i_15] += (prev + (nextVertices[i_15] - prev) * percent) * alpha;
}
}
} }
} }
}; };
@ -760,13 +880,13 @@ var spine;
this.frames[frameIndex] = event.time; this.frames[frameIndex] = event.time;
this.events[frameIndex] = event; this.events[frameIndex] = event;
}; };
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
if (firedEvents == null) if (firedEvents == null)
return; return;
var frames = this.frames; var frames = this.frames;
var frameCount = this.frames.length; var frameCount = this.frames.length;
if (lastTime > time) { if (lastTime > time) {
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, pose, direction); this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, blend, direction);
lastTime = -1; lastTime = -1;
} }
else if (lastTime >= frames[frameCount - 1]) else if (lastTime >= frames[frameCount - 1])
@ -806,16 +926,16 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.drawOrders[frameIndex] = drawOrder; this.drawOrders[frameIndex] = drawOrder;
}; };
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var drawOrder = skeleton.drawOrder; var drawOrder = skeleton.drawOrder;
var slots = skeleton.slots; var slots = skeleton.slots;
if (direction == MixDirection.out && pose == MixPose.setup) { if (direction == MixDirection.out && blend == MixBlend.setup) {
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
return; return;
} }
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
if (pose == MixPose.setup) if (blend == MixBlend.setup)
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
return; return;
} }
@ -851,23 +971,23 @@ var spine;
this.frames[frameIndex + IkConstraintTimeline.MIX] = mix; this.frames[frameIndex + IkConstraintTimeline.MIX] = mix;
this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection; this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection;
}; };
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.ikConstraints[this.ikConstraintIndex]; var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.mix = constraint.data.mix; constraint.mix = constraint.data.mix;
constraint.bendDirection = constraint.data.bendDirection; constraint.bendDirection = constraint.data.bendDirection;
return; return;
case MixPose.current: case MixBlend.first:
constraint.mix += (constraint.data.mix - constraint.mix) * alpha; constraint.mix += (constraint.data.mix - constraint.mix) * alpha;
constraint.bendDirection = constraint.data.bendDirection; constraint.bendDirection = constraint.data.bendDirection;
} }
return; return;
} }
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) { if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
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;
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection
: frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION]; : frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
@ -883,7 +1003,7 @@ var spine;
var mix = frames[frame + IkConstraintTimeline.PREV_MIX]; var mix = frames[frame + IkConstraintTimeline.PREV_MIX];
var frameTime = frames[frame]; var frameTime = frames[frame];
var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime));
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha; constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha;
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
} }
@ -920,19 +1040,19 @@ var spine;
this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix; this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix;
this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix; this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix;
}; };
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.transformConstraints[this.transformConstraintIndex]; var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
var data = constraint.data; var data = constraint.data;
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.rotateMix = data.rotateMix; constraint.rotateMix = data.rotateMix;
constraint.translateMix = data.translateMix; constraint.translateMix = data.translateMix;
constraint.scaleMix = data.scaleMix; constraint.scaleMix = data.scaleMix;
constraint.shearMix = data.shearMix; constraint.shearMix = data.shearMix;
return; return;
case MixPose.current: case MixBlend.setup:
constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha; constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha;
constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha; constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha;
constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha; constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha;
@ -961,7 +1081,7 @@ var spine;
scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent; scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent;
shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent; shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent;
} }
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
var data = constraint.data; var 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;
@ -1003,15 +1123,15 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value; this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value;
}; };
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.position = constraint.data.position; constraint.position = constraint.data.position;
return; return;
case MixPose.current: case MixBlend.first:
constraint.position += (constraint.data.position - constraint.position) * alpha; constraint.position += (constraint.data.position - constraint.position) * alpha;
} }
return; return;
@ -1026,7 +1146,7 @@ var spine;
var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime));
position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent; position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent;
} }
if (pose == MixPose.setup) if (blend == MixBlend.setup)
constraint.position = constraint.data.position + (position - constraint.data.position) * alpha; constraint.position = constraint.data.position + (position - constraint.data.position) * alpha;
else else
constraint.position += (position - constraint.position) * alpha; constraint.position += (position - constraint.position) * alpha;
@ -1046,15 +1166,15 @@ var spine;
PathConstraintSpacingTimeline.prototype.getPropertyId = function () { PathConstraintSpacingTimeline.prototype.getPropertyId = function () {
return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex; return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex;
}; };
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.spacing = constraint.data.spacing; constraint.spacing = constraint.data.spacing;
return; return;
case MixPose.current: case MixBlend.first:
constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha; constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha;
} }
return; return;
@ -1069,7 +1189,7 @@ var spine;
var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime));
spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent; spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent;
} }
if (pose == MixPose.setup) if (blend == MixBlend.setup)
constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha; constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;
else else
constraint.spacing += (spacing - constraint.spacing) * alpha; constraint.spacing += (spacing - constraint.spacing) * alpha;
@ -1093,16 +1213,16 @@ var spine;
this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix; this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix;
this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix; this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix;
}; };
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.rotateMix = constraint.data.rotateMix; constraint.rotateMix = constraint.data.rotateMix;
constraint.translateMix = constraint.data.translateMix; constraint.translateMix = constraint.data.translateMix;
return; return;
case MixPose.current: case MixBlend.first:
constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha; constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha;
constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha; constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha;
} }
@ -1122,7 +1242,7 @@ var spine;
rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent; rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent;
translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent; translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent;
} }
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha; constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha;
constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha; constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha;
} }
@ -1238,18 +1358,18 @@ var spine;
if (current == null || current.delay > 0) if (current == null || current.delay > 0)
continue; continue;
applied = true; applied = true;
var currentPose = i == 0 ? spine.MixPose.current : spine.MixPose.currentLayered; var blend = i == 0 ? spine.MixBlend.first : current.mixBlend;
var mix = current.alpha; var mix = current.alpha;
if (current.mixingFrom != null) if (current.mixingFrom != null)
mix *= this.applyMixingFrom(current, skeleton, currentPose); mix *= this.applyMixingFrom(current, skeleton, blend);
else if (current.trackTime >= current.trackEnd && current.next == null) else if (current.trackTime >= current.trackEnd && current.next == null)
mix = 0; mix = 0;
var animationLast = current.animationLast, animationTime = current.getAnimationTime(); var animationLast = current.animationLast, animationTime = current.getAnimationTime();
var timelineCount = current.animation.timelines.length; var timelineCount = current.animation.timelines.length;
var timelines = current.animation.timelines; var timelines = current.animation.timelines;
if (mix == 1) { if (mix == 1 || blend == spine.MixBlend.add) {
for (var ii = 0; ii < timelineCount; ii++) for (var ii = 0; ii < timelineCount; ii++)
timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, spine.MixPose.setup, spine.MixDirection["in"]); timelines[ii].apply(skeleton, animationLast, animationTime, events, mix, blend, spine.MixDirection["in"]);
} }
else { else {
var timelineData = current.timelineData; var timelineData = current.timelineData;
@ -1259,12 +1379,12 @@ var spine;
var timelinesRotation = current.timelinesRotation; var timelinesRotation = current.timelinesRotation;
for (var ii = 0; ii < timelineCount; ii++) { for (var ii = 0; ii < timelineCount; ii++) {
var timeline = timelines[ii]; var timeline = timelines[ii];
var pose = timelineData[ii] >= AnimationState.FIRST ? spine.MixPose.setup : currentPose; var timelineBlend = timelineData[ii] == AnimationState.SUBSEQUENT ? blend : spine.MixBlend.setup;
if (timeline instanceof spine.RotateTimeline) { if (timeline instanceof spine.RotateTimeline) {
this.applyRotateTimeline(timeline, skeleton, animationTime, mix, pose, timelinesRotation, ii << 1, firstFrame); this.applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineBlend, timelinesRotation, ii << 1, firstFrame);
} }
else else
timeline.apply(skeleton, animationLast, animationTime, events, mix, pose, spine.MixDirection["in"]); timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineBlend, spine.MixDirection["in"]);
} }
} }
this.queueEvents(current, animationTime); this.queueEvents(current, animationTime);
@ -1275,65 +1395,74 @@ var spine;
this.queue.drain(); this.queue.drain();
return applied; return applied;
}; };
AnimationState.prototype.applyMixingFrom = function (to, skeleton, currentPose) { AnimationState.prototype.applyMixingFrom = function (to, skeleton, blend) {
var from = to.mixingFrom; var from = to.mixingFrom;
if (from.mixingFrom != null) if (from.mixingFrom != null)
this.applyMixingFrom(from, skeleton, currentPose); this.applyMixingFrom(from, skeleton, blend);
var mix = 0; var mix = 0;
if (to.mixDuration == 0) { if (to.mixDuration == 0) {
mix = 1; mix = 1;
currentPose = spine.MixPose.setup; if (blend == spine.MixBlend.first)
blend = spine.MixBlend.setup;
} }
else { else {
mix = to.mixTime / to.mixDuration; mix = to.mixTime / to.mixDuration;
if (mix > 1) if (mix > 1)
mix = 1; mix = 1;
if (blend != spine.MixBlend.first)
blend = from.mixBlend;
} }
var events = mix < from.eventThreshold ? this.events : null; var events = mix < from.eventThreshold ? this.events : null;
var attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold; var attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold;
var animationLast = from.animationLast, animationTime = from.getAnimationTime(); var animationLast = from.animationLast, animationTime = from.getAnimationTime();
var timelineCount = from.animation.timelines.length; var timelineCount = from.animation.timelines.length;
var timelines = from.animation.timelines; var timelines = from.animation.timelines;
var timelineData = from.timelineData; var alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix);
var timelineDipMix = from.timelineDipMix; if (blend == spine.MixBlend.add) {
var firstFrame = from.timelinesRotation.length == 0; for (var i = 0; i < timelineCount; i++)
if (firstFrame) timelines[i].apply(skeleton, animationLast, animationTime, events, alphaMix, blend, spine.MixDirection.out);
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null); }
var timelinesRotation = from.timelinesRotation; else {
var pose; var timelineData = from.timelineData;
var alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix), alpha = 0; var timelineDipMix = from.timelineDipMix;
from.totalAlpha = 0; var firstFrame = from.timelinesRotation.length == 0;
for (var i = 0; i < timelineCount; i++) { if (firstFrame)
var timeline = timelines[i]; spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
switch (timelineData[i]) { var timelinesRotation = from.timelinesRotation;
case AnimationState.SUBSEQUENT: from.totalAlpha = 0;
if (!attachments && timeline instanceof spine.AttachmentTimeline) for (var i = 0; i < timelineCount; i++) {
continue; var timeline = timelines[i];
if (!drawOrder && timeline instanceof spine.DrawOrderTimeline) var timelineBlend;
continue; var alpha = 0;
pose = currentPose; switch (timelineData[i]) {
alpha = alphaMix; case AnimationState.SUBSEQUENT:
break; if (!attachments && timeline instanceof spine.AttachmentTimeline)
case AnimationState.FIRST: continue;
pose = spine.MixPose.setup; if (!drawOrder && timeline instanceof spine.DrawOrderTimeline)
alpha = alphaMix; continue;
break; timelineBlend = blend;
case AnimationState.DIP: alpha = alphaMix;
pose = spine.MixPose.setup; break;
alpha = alphaDip; case AnimationState.FIRST:
break; timelineBlend = spine.MixBlend.setup;
default: alpha = alphaMix;
pose = spine.MixPose.setup; break;
alpha = alphaDip; case AnimationState.DIP:
var dipMix = timelineDipMix[i]; timelineBlend = spine.MixBlend.setup;
alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration); alpha = alphaDip;
break; break;
} default:
from.totalAlpha += alpha; timelineBlend = spine.MixBlend.setup;
if (timeline instanceof spine.RotateTimeline) var dipMix = timelineDipMix[i];
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame); alpha = alphaDip * Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
else { break;
timeline.apply(skeleton, animationLast, animationTime, events, alpha, pose, spine.MixDirection.out); }
from.totalAlpha += alpha;
if (timeline instanceof spine.RotateTimeline)
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, timelineBlend, timelinesRotation, i << 1, firstFrame);
else {
timeline.apply(skeleton, animationLast, animationTime, events, alpha, timelineBlend, spine.MixDirection.out);
}
} }
} }
if (to.mixDuration > 0) if (to.mixDuration > 0)
@ -1343,18 +1472,18 @@ var spine;
from.nextTrackLast = from.trackTime; from.nextTrackLast = from.trackTime;
return mix; return mix;
}; };
AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, pose, timelinesRotation, i, firstFrame) { AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, blend, timelinesRotation, i, firstFrame) {
if (firstFrame) if (firstFrame)
timelinesRotation[i] = 0; timelinesRotation[i] = 0;
if (alpha == 1) { if (alpha == 1) {
timeline.apply(skeleton, 0, time, null, 1, pose, spine.MixDirection["in"]); timeline.apply(skeleton, 0, time, null, 1, blend, spine.MixDirection["in"]);
return; return;
} }
var rotateTimeline = timeline; var rotateTimeline = timeline;
var frames = rotateTimeline.frames; var frames = rotateTimeline.frames;
var bone = skeleton.bones[rotateTimeline.boneIndex]; var bone = skeleton.bones[rotateTimeline.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
if (pose == spine.MixPose.setup) if (blend == spine.MixBlend.setup)
bone.rotation = bone.data.rotation; bone.rotation = bone.data.rotation;
return; return;
} }
@ -1371,7 +1500,7 @@ var spine;
r2 = prevRotation + r2 * percent + bone.data.rotation; r2 = prevRotation + r2 * percent + bone.data.rotation;
r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360; r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
} }
var r1 = pose == spine.MixPose.setup ? bone.data.rotation : bone.rotation; var r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation;
var total = 0, diff = r2 - r1; var total = 0, diff = r2 - r1;
if (diff == 0) { if (diff == 0) {
total = timelinesRotation[i]; total = timelinesRotation[i];
@ -1601,7 +1730,7 @@ var spine;
var mixingTo = this.mixingTo; var mixingTo = this.mixingTo;
for (var i = 0, n = this.tracks.length; i < n; i++) { for (var i = 0, n = this.tracks.length; i < n; i++) {
var entry = this.tracks[i]; var entry = this.tracks[i];
if (entry != null) if (entry != null && (i == 0 || entry.mixBlend != spine.MixBlend.add))
entry.setTimelineData(null, mixingTo, propertyIDs); entry.setTimelineData(null, mixingTo, propertyIDs);
} }
}; };
@ -1636,6 +1765,7 @@ var spine;
spine.AnimationState = AnimationState; spine.AnimationState = AnimationState;
var TrackEntry = (function () { var TrackEntry = (function () {
function TrackEntry() { function TrackEntry() {
this.mixBlend = spine.MixBlend.replace;
this.timelineData = new Array(); this.timelineData = new Array();
this.timelineDipMix = new Array(); this.timelineDipMix = new Array();
this.timelinesRotation = new Array(); this.timelinesRotation = new Array();

File diff suppressed because one or more lines are too long

View File

@ -20,7 +20,7 @@ var spine;
this.timelines = timelines; this.timelines = timelines;
this.duration = duration; this.duration = duration;
} }
Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, pose, direction) { Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, blend, direction) {
if (skeleton == null) if (skeleton == null)
throw new Error("skeleton cannot be null."); throw new Error("skeleton cannot be null.");
if (loop && this.duration != 0) { if (loop && this.duration != 0) {
@ -30,7 +30,7 @@ var spine;
} }
var timelines = this.timelines; var timelines = this.timelines;
for (var i = 0, n = timelines.length; i < n; i++) for (var i = 0, n = timelines.length; i < n; i++)
timelines[i].apply(skeleton, lastTime, time, events, alpha, pose, direction); timelines[i].apply(skeleton, lastTime, time, events, alpha, blend, direction);
}; };
Animation.binarySearch = function (values, target, step) { Animation.binarySearch = function (values, target, step) {
if (step === void 0) { step = 1; } if (step === void 0) { step = 1; }
@ -58,12 +58,13 @@ var spine;
return Animation; return Animation;
}()); }());
spine.Animation = Animation; spine.Animation = Animation;
var MixPose; var MixBlend;
(function (MixPose) { (function (MixBlend) {
MixPose[MixPose["setup"] = 0] = "setup"; MixBlend[MixBlend["setup"] = 0] = "setup";
MixPose[MixPose["current"] = 1] = "current"; MixBlend[MixBlend["first"] = 1] = "first";
MixPose[MixPose["currentLayered"] = 2] = "currentLayered"; MixBlend[MixBlend["replace"] = 2] = "replace";
})(MixPose = spine.MixPose || (spine.MixPose = {})); MixBlend[MixBlend["add"] = 3] = "add";
})(MixBlend = spine.MixBlend || (spine.MixBlend = {}));
var MixDirection; var MixDirection;
(function (MixDirection) { (function (MixDirection) {
MixDirection[MixDirection["in"] = 0] = "in"; MixDirection[MixDirection["in"] = 0] = "in";
@ -184,28 +185,32 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.frames[frameIndex + RotateTimeline.ROTATION] = degrees; this.frames[frameIndex + RotateTimeline.ROTATION] = degrees;
}; };
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.rotation = bone.data.rotation; bone.rotation = bone.data.rotation;
return; return;
case MixPose.current: case MixBlend.first:
var r_1 = bone.data.rotation - bone.rotation; var r_1 = bone.data.rotation - bone.rotation;
r_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360; bone.rotation += (r_1 - (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360) * alpha;
bone.rotation += r_1 * alpha;
} }
return; return;
} }
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) { if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
if (pose == MixPose.setup) var r = frames[frames.length + RotateTimeline.PREV_ROTATION];
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha; switch (blend) {
else { case MixBlend.setup:
var r_2 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation; bone.rotation = bone.data.rotation + r * alpha;
r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360; break;
bone.rotation += r_2 * alpha; case MixBlend.first:
case MixBlend.replace:
r += bone.data.rotation - bone.rotation;
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
case MixBlend.add:
bone.rotation += r * alpha;
} }
return; return;
} }
@ -213,17 +218,17 @@ var spine;
var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION]; var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION];
var frameTime = frames[frame]; var frameTime = frames[frame];
var percent = this.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime));
var r = frames[frame + RotateTimeline.ROTATION] - prevRotation; r = frames[frame + RotateTimeline.ROTATION] - prevRotation;
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; r = prevRotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * percent;
r = prevRotation + r * percent; switch (blend) {
if (pose == MixPose.setup) { case MixBlend.setup:
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; bone.rotation = bone.data.rotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha;
bone.rotation = bone.data.rotation + r * alpha; break;
} case MixBlend.first:
else { case MixBlend.replace:
r = bone.data.rotation + r - bone.rotation; r += bone.data.rotation - bone.rotation;
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; case MixBlend.add:
bone.rotation += r * alpha; bone.rotation += (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha;
} }
}; };
return RotateTimeline; return RotateTimeline;
@ -249,16 +254,16 @@ var spine;
this.frames[frameIndex + TranslateTimeline.X] = x; this.frames[frameIndex + TranslateTimeline.X] = x;
this.frames[frameIndex + TranslateTimeline.Y] = y; this.frames[frameIndex + TranslateTimeline.Y] = y;
}; };
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.x = bone.data.x; bone.x = bone.data.x;
bone.y = bone.data.y; bone.y = bone.data.y;
return; return;
case MixPose.current: case MixBlend.first:
bone.x += (bone.data.x - bone.x) * alpha; bone.x += (bone.data.x - bone.x) * alpha;
bone.y += (bone.data.y - bone.y) * alpha; bone.y += (bone.data.y - bone.y) * alpha;
} }
@ -278,13 +283,19 @@ var spine;
x += (frames[frame + TranslateTimeline.X] - x) * percent; x += (frames[frame + TranslateTimeline.X] - x) * percent;
y += (frames[frame + TranslateTimeline.Y] - y) * percent; y += (frames[frame + TranslateTimeline.Y] - y) * percent;
} }
if (pose == MixPose.setup) { switch (blend) {
bone.x = bone.data.x + x * alpha; case MixBlend.setup:
bone.y = bone.data.y + y * alpha; bone.x = bone.data.x + x * alpha;
} bone.y = bone.data.y + y * alpha;
else { break;
bone.x += (bone.data.x + x - bone.x) * alpha; case MixBlend.first:
bone.y += (bone.data.y + y - bone.y) * alpha; case MixBlend.replace:
bone.x += (bone.data.x + x - bone.x) * alpha;
bone.y += (bone.data.y + y - bone.y) * alpha;
break;
case MixBlend.add:
bone.x += x * alpha;
bone.y += y * alpha;
} }
}; };
return TranslateTimeline; return TranslateTimeline;
@ -304,16 +315,16 @@ var spine;
ScaleTimeline.prototype.getPropertyId = function () { ScaleTimeline.prototype.getPropertyId = function () {
return (TimelineType.scale << 24) + this.boneIndex; return (TimelineType.scale << 24) + this.boneIndex;
}; };
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.scaleX = bone.data.scaleX; bone.scaleX = bone.data.scaleX;
bone.scaleY = bone.data.scaleY; bone.scaleY = bone.data.scaleY;
return; return;
case MixPose.current: case MixBlend.first:
bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha; bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;
bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha; bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;
} }
@ -334,29 +345,61 @@ var spine;
y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY; y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY;
} }
if (alpha == 1) { if (alpha == 1) {
bone.scaleX = x; if (blend == MixBlend.add) {
bone.scaleY = y; bone.scaleX += x - bone.data.scaleX;
bone.scaleY += y - bone.data.scaleY;
}
else {
bone.scaleX = x;
bone.scaleY = y;
}
} }
else { else {
var bx = 0, by = 0; var bx = 0, by = 0;
if (pose == MixPose.setup) {
bx = bone.data.scaleX;
by = bone.data.scaleY;
}
else {
bx = bone.scaleX;
by = bone.scaleY;
}
if (direction == MixDirection.out) { if (direction == MixDirection.out) {
x = Math.abs(x) * spine.MathUtils.signum(bx); switch (blend) {
y = Math.abs(y) * spine.MathUtils.signum(by); case MixBlend.setup:
bx = bone.data.scaleX;
by = bone.data.scaleY;
bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bx) * alpha;
bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - by) * alpha;
break;
case MixBlend.first:
case MixBlend.replace:
bx = bone.scaleX;
by = bone.scaleY;
bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bx) * alpha;
bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - by) * alpha;
break;
case MixBlend.add:
bx = bone.scaleX;
by = bone.scaleY;
bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bone.data.scaleX) * alpha;
bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - bone.data.scaleY) * alpha;
}
} }
else { else {
bx = Math.abs(bx) * spine.MathUtils.signum(x); switch (blend) {
by = Math.abs(by) * spine.MathUtils.signum(y); case MixBlend.setup:
bx = Math.abs(bone.data.scaleX) * spine.MathUtils.signum(x);
by = Math.abs(bone.data.scaleY) * spine.MathUtils.signum(y);
bone.scaleX = bx + (x - bx) * alpha;
bone.scaleY = by + (y - by) * alpha;
break;
case MixBlend.first:
case MixBlend.replace:
bx = Math.abs(bone.scaleX) * spine.MathUtils.signum(x);
by = Math.abs(bone.scaleY) * spine.MathUtils.signum(y);
bone.scaleX = bx + (x - bx) * alpha;
bone.scaleY = by + (y - by) * alpha;
break;
case MixBlend.add:
bx = spine.MathUtils.signum(x);
by = spine.MathUtils.signum(y);
bone.scaleX = Math.abs(bone.scaleX) * bx + (x - Math.abs(bone.data.scaleX) * bx) * alpha;
bone.scaleY = Math.abs(bone.scaleY) * by + (y - Math.abs(bone.data.scaleY) * by) * alpha;
}
} }
bone.scaleX = bx + (x - bx) * alpha;
bone.scaleY = by + (y - by) * alpha;
} }
}; };
return ScaleTimeline; return ScaleTimeline;
@ -370,16 +413,16 @@ var spine;
ShearTimeline.prototype.getPropertyId = function () { ShearTimeline.prototype.getPropertyId = function () {
return (TimelineType.shear << 24) + this.boneIndex; return (TimelineType.shear << 24) + this.boneIndex;
}; };
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.shearX = bone.data.shearX; bone.shearX = bone.data.shearX;
bone.shearY = bone.data.shearY; bone.shearY = bone.data.shearY;
return; return;
case MixPose.current: case MixBlend.first:
bone.shearX += (bone.data.shearX - bone.shearX) * alpha; bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
bone.shearY += (bone.data.shearY - bone.shearY) * alpha; bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
} }
@ -399,13 +442,19 @@ var spine;
x = x + (frames[frame + ShearTimeline.X] - x) * percent; x = x + (frames[frame + ShearTimeline.X] - x) * percent;
y = y + (frames[frame + ShearTimeline.Y] - y) * percent; y = y + (frames[frame + ShearTimeline.Y] - y) * percent;
} }
if (pose == MixPose.setup) { switch (blend) {
bone.shearX = bone.data.shearX + x * alpha; case MixBlend.setup:
bone.shearY = bone.data.shearY + y * alpha; bone.shearX = bone.data.shearX + x * alpha;
} bone.shearY = bone.data.shearY + y * alpha;
else { break;
bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha; case MixBlend.first:
bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha; case MixBlend.replace:
bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha;
bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha;
break;
case MixBlend.add:
bone.shearX += x * alpha;
bone.shearY += y * alpha;
} }
}; };
return ShearTimeline; return ShearTimeline;
@ -429,15 +478,15 @@ var spine;
this.frames[frameIndex + ColorTimeline.B] = b; this.frames[frameIndex + ColorTimeline.B] = b;
this.frames[frameIndex + ColorTimeline.A] = a; this.frames[frameIndex + ColorTimeline.A] = a;
}; };
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
slot.color.setFromColor(slot.data.color); slot.color.setFromColor(slot.data.color);
return; return;
case MixPose.current: case MixBlend.first:
var color = slot.color, setup = slot.data.color; var color = slot.color, setup = slot.data.color;
color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha); color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha);
} }
@ -468,7 +517,7 @@ var spine;
slot.color.set(r, g, b, a); slot.color.set(r, g, b, a);
else { else {
var color = slot.color; var color = slot.color;
if (pose == MixPose.setup) if (blend == MixBlend.setup)
color.setFromColor(slot.data.color); color.setFromColor(slot.data.color);
color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha); color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
} }
@ -507,16 +556,16 @@ var spine;
this.frames[frameIndex + TwoColorTimeline.G2] = g2; this.frames[frameIndex + TwoColorTimeline.G2] = g2;
this.frames[frameIndex + TwoColorTimeline.B2] = b2; this.frames[frameIndex + TwoColorTimeline.B2] = b2;
}; };
TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
slot.color.setFromColor(slot.data.color); slot.color.setFromColor(slot.data.color);
slot.darkColor.setFromColor(slot.data.darkColor); slot.darkColor.setFromColor(slot.data.darkColor);
return; return;
case MixPose.current: case MixBlend.setup:
var light = slot.color, dark = slot.darkColor, setupLight = slot.data.color, setupDark = slot.data.darkColor; var light = slot.color, dark = slot.darkColor, setupLight = slot.data.color, setupDark = slot.data.darkColor;
light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha); light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha);
dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0); dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0);
@ -559,7 +608,7 @@ var spine;
} }
else { else {
var light = slot.color, dark = slot.darkColor; var light = slot.color, dark = slot.darkColor;
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
light.setFromColor(slot.data.color); light.setFromColor(slot.data.color);
dark.setFromColor(slot.data.darkColor); dark.setFromColor(slot.data.darkColor);
} }
@ -601,16 +650,16 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.attachmentNames[frameIndex] = attachmentName; this.attachmentNames[frameIndex] = attachmentName;
}; };
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
if (direction == MixDirection.out && pose == MixPose.setup) { if (direction == MixDirection.out && blend == MixBlend.setup) {
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 (pose == MixPose.setup) { if (blend == MixBlend.setup || blend == MixBlend.first) {
var attachmentName_2 = slot.data.attachmentName; var attachmentName_2 = slot.data.attachmentName;
slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2)); slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2));
} }
@ -646,24 +695,24 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.frameVertices[frameIndex] = vertices; this.frameVertices[frameIndex] = vertices;
}; };
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
var slotAttachment = slot.getAttachment(); var slotAttachment = slot.getAttachment();
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment)) if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
return; return;
var verticesArray = slot.attachmentVertices; var verticesArray = slot.attachmentVertices;
if (verticesArray.length == 0) if (verticesArray.length == 0)
alpha = 1; blend = MixBlend.setup;
var frameVertices = this.frameVertices; var frameVertices = this.frameVertices;
var vertexCount = frameVertices[0].length; var vertexCount = frameVertices[0].length;
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
var vertexAttachment = slotAttachment; var vertexAttachment = slotAttachment;
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
verticesArray.length = 0; verticesArray.length = 0;
return; return;
case MixPose.current: case MixBlend.first:
if (alpha == 1) { if (alpha == 1) {
verticesArray.length = 0; verticesArray.length = 0;
break; break;
@ -686,25 +735,57 @@ var spine;
if (time >= frames[frames.length - 1]) { if (time >= frames[frames.length - 1]) {
var lastVertices = frameVertices[frames.length - 1]; var lastVertices = frameVertices[frames.length - 1];
if (alpha == 1) { if (alpha == 1) {
spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount); if (blend == MixBlend.add) {
} var vertexAttachment = slotAttachment;
else if (pose == MixPose.setup) { if (vertexAttachment.bones == null) {
var vertexAttachment = slotAttachment; var setupVertices_1 = vertexAttachment.vertices;
if (vertexAttachment.bones == null) { for (var i_1 = 0; i_1 < vertexCount; i_1++) {
var setupVertices_1 = vertexAttachment.vertices; vertices[i_1] += lastVertices[i_1] - setupVertices_1[i_1];
for (var i_1 = 0; i_1 < vertexCount; i_1++) { }
var setup = setupVertices_1[i_1]; }
vertices[i_1] = setup + (lastVertices[i_1] - setup) * alpha; else {
for (var i_2 = 0; i_2 < vertexCount; i_2++)
vertices[i_2] += lastVertices[i_2];
} }
} }
else { else {
for (var i_2 = 0; i_2 < vertexCount; i_2++) spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount);
vertices[i_2] = lastVertices[i_2] * alpha;
} }
} }
else { else {
for (var i_3 = 0; i_3 < vertexCount; i_3++) switch (blend) {
vertices[i_3] += (lastVertices[i_3] - vertices[i_3]) * alpha; case MixBlend.setup: {
var vertexAttachment_1 = slotAttachment;
if (vertexAttachment_1.bones == null) {
var setupVertices_2 = vertexAttachment_1.vertices;
for (var i_3 = 0; i_3 < vertexCount; i_3++) {
var setup = setupVertices_2[i_3];
vertices[i_3] = setup + (lastVertices[i_3] - setup) * alpha;
}
}
else {
for (var i_4 = 0; i_4 < vertexCount; i_4++)
vertices[i_4] = lastVertices[i_4] * alpha;
}
break;
}
case MixBlend.first:
case MixBlend.replace:
for (var i_5 = 0; i_5 < vertexCount; i_5++)
vertices[i_5] += (lastVertices[i_5] - vertices[i_5]) * alpha;
case MixBlend.add:
var vertexAttachment = slotAttachment;
if (vertexAttachment.bones == null) {
var setupVertices_3 = vertexAttachment.vertices;
for (var i_6 = 0; i_6 < vertexCount; i_6++) {
vertices[i_6] += (lastVertices[i_6] - setupVertices_3[i_6]) * alpha;
}
}
else {
for (var i_7 = 0; i_7 < vertexCount; i_7++)
vertices[i_7] += lastVertices[i_7] * alpha;
}
}
} }
return; return;
} }
@ -714,31 +795,70 @@ var spine;
var frameTime = frames[frame]; var frameTime = frames[frame];
var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime)); var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime));
if (alpha == 1) { if (alpha == 1) {
for (var i_4 = 0; i_4 < vertexCount; i_4++) { if (blend == MixBlend.add) {
var prev = prevVertices[i_4]; var vertexAttachment = slotAttachment;
vertices[i_4] = prev + (nextVertices[i_4] - prev) * percent; if (vertexAttachment.bones == null) {
} var setupVertices_4 = vertexAttachment.vertices;
} for (var i_8 = 0; i_8 < vertexCount; i_8++) {
else if (pose == MixPose.setup) { var prev = prevVertices[i_8];
var vertexAttachment = slotAttachment; vertices[i_8] += prev + (nextVertices[i_8] - prev) * percent - setupVertices_4[i_8];
if (vertexAttachment.bones == null) { }
var setupVertices_2 = vertexAttachment.vertices; }
for (var i_5 = 0; i_5 < vertexCount; i_5++) { else {
var prev = prevVertices[i_5], setup = setupVertices_2[i_5]; for (var i_9 = 0; i_9 < vertexCount; i_9++) {
vertices[i_5] = setup + (prev + (nextVertices[i_5] - prev) * percent - setup) * alpha; var prev = prevVertices[i_9];
vertices[i_9] += prev + (nextVertices[i_9] - prev) * percent;
}
} }
} }
else { else {
for (var i_6 = 0; i_6 < vertexCount; i_6++) { for (var i_10 = 0; i_10 < vertexCount; i_10++) {
var prev = prevVertices[i_6]; var prev = prevVertices[i_10];
vertices[i_6] = (prev + (nextVertices[i_6] - prev) * percent) * alpha; vertices[i_10] = prev + (nextVertices[i_10] - prev) * percent;
} }
} }
} }
else { else {
for (var i_7 = 0; i_7 < vertexCount; i_7++) { switch (blend) {
var prev = prevVertices[i_7]; case MixBlend.setup: {
vertices[i_7] += (prev + (nextVertices[i_7] - prev) * percent - vertices[i_7]) * alpha; var vertexAttachment_2 = slotAttachment;
if (vertexAttachment_2.bones == null) {
var setupVertices_5 = vertexAttachment_2.vertices;
for (var i_11 = 0; i_11 < vertexCount; i_11++) {
var prev = prevVertices[i_11], setup = setupVertices_5[i_11];
vertices[i_11] = setup + (prev + (nextVertices[i_11] - prev) * percent - setup) * alpha;
}
}
else {
for (var i_12 = 0; i_12 < vertexCount; i_12++) {
var prev = prevVertices[i_12];
vertices[i_12] = (prev + (nextVertices[i_12] - prev) * percent) * alpha;
}
}
break;
}
case MixBlend.first:
case MixBlend.replace:
for (var i_13 = 0; i_13 < vertexCount; i_13++) {
var prev = prevVertices[i_13];
vertices[i_13] += (prev + (nextVertices[i_13] - prev) * percent - vertices[i_13]) * alpha;
}
break;
case MixBlend.add:
var vertexAttachment = slotAttachment;
if (vertexAttachment.bones == null) {
var setupVertices_6 = vertexAttachment.vertices;
for (var i_14 = 0; i_14 < vertexCount; i_14++) {
var prev = prevVertices[i_14];
vertices[i_14] += (prev + (nextVertices[i_14] - prev) * percent - setupVertices_6[i_14]) * alpha;
}
}
else {
for (var i_15 = 0; i_15 < vertexCount; i_15++) {
var prev = prevVertices[i_15];
vertices[i_15] += (prev + (nextVertices[i_15] - prev) * percent) * alpha;
}
}
} }
} }
}; };
@ -760,13 +880,13 @@ var spine;
this.frames[frameIndex] = event.time; this.frames[frameIndex] = event.time;
this.events[frameIndex] = event; this.events[frameIndex] = event;
}; };
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
if (firedEvents == null) if (firedEvents == null)
return; return;
var frames = this.frames; var frames = this.frames;
var frameCount = this.frames.length; var frameCount = this.frames.length;
if (lastTime > time) { if (lastTime > time) {
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, pose, direction); this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, blend, direction);
lastTime = -1; lastTime = -1;
} }
else if (lastTime >= frames[frameCount - 1]) else if (lastTime >= frames[frameCount - 1])
@ -806,16 +926,16 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.drawOrders[frameIndex] = drawOrder; this.drawOrders[frameIndex] = drawOrder;
}; };
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var drawOrder = skeleton.drawOrder; var drawOrder = skeleton.drawOrder;
var slots = skeleton.slots; var slots = skeleton.slots;
if (direction == MixDirection.out && pose == MixPose.setup) { if (direction == MixDirection.out && blend == MixBlend.setup) {
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
return; return;
} }
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
if (pose == MixPose.setup) if (blend == MixBlend.setup)
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
return; return;
} }
@ -851,23 +971,23 @@ var spine;
this.frames[frameIndex + IkConstraintTimeline.MIX] = mix; this.frames[frameIndex + IkConstraintTimeline.MIX] = mix;
this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection; this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection;
}; };
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.ikConstraints[this.ikConstraintIndex]; var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.mix = constraint.data.mix; constraint.mix = constraint.data.mix;
constraint.bendDirection = constraint.data.bendDirection; constraint.bendDirection = constraint.data.bendDirection;
return; return;
case MixPose.current: case MixBlend.first:
constraint.mix += (constraint.data.mix - constraint.mix) * alpha; constraint.mix += (constraint.data.mix - constraint.mix) * alpha;
constraint.bendDirection = constraint.data.bendDirection; constraint.bendDirection = constraint.data.bendDirection;
} }
return; return;
} }
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) { if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
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;
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection
: frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION]; : frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
@ -883,7 +1003,7 @@ var spine;
var mix = frames[frame + IkConstraintTimeline.PREV_MIX]; var mix = frames[frame + IkConstraintTimeline.PREV_MIX];
var frameTime = frames[frame]; var frameTime = frames[frame];
var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime));
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha; constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha;
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
} }
@ -920,19 +1040,19 @@ var spine;
this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix; this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix;
this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix; this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix;
}; };
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.transformConstraints[this.transformConstraintIndex]; var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
var data = constraint.data; var data = constraint.data;
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.rotateMix = data.rotateMix; constraint.rotateMix = data.rotateMix;
constraint.translateMix = data.translateMix; constraint.translateMix = data.translateMix;
constraint.scaleMix = data.scaleMix; constraint.scaleMix = data.scaleMix;
constraint.shearMix = data.shearMix; constraint.shearMix = data.shearMix;
return; return;
case MixPose.current: case MixBlend.setup:
constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha; constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha;
constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha; constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha;
constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha; constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha;
@ -961,7 +1081,7 @@ var spine;
scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent; scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent;
shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent; shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent;
} }
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
var data = constraint.data; var 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;
@ -1003,15 +1123,15 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value; this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value;
}; };
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.position = constraint.data.position; constraint.position = constraint.data.position;
return; return;
case MixPose.current: case MixBlend.first:
constraint.position += (constraint.data.position - constraint.position) * alpha; constraint.position += (constraint.data.position - constraint.position) * alpha;
} }
return; return;
@ -1026,7 +1146,7 @@ var spine;
var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime));
position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent; position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent;
} }
if (pose == MixPose.setup) if (blend == MixBlend.setup)
constraint.position = constraint.data.position + (position - constraint.data.position) * alpha; constraint.position = constraint.data.position + (position - constraint.data.position) * alpha;
else else
constraint.position += (position - constraint.position) * alpha; constraint.position += (position - constraint.position) * alpha;
@ -1046,15 +1166,15 @@ var spine;
PathConstraintSpacingTimeline.prototype.getPropertyId = function () { PathConstraintSpacingTimeline.prototype.getPropertyId = function () {
return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex; return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex;
}; };
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.spacing = constraint.data.spacing; constraint.spacing = constraint.data.spacing;
return; return;
case MixPose.current: case MixBlend.first:
constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha; constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha;
} }
return; return;
@ -1069,7 +1189,7 @@ var spine;
var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime));
spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent; spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent;
} }
if (pose == MixPose.setup) if (blend == MixBlend.setup)
constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha; constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;
else else
constraint.spacing += (spacing - constraint.spacing) * alpha; constraint.spacing += (spacing - constraint.spacing) * alpha;
@ -1093,16 +1213,16 @@ var spine;
this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix; this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix;
this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix; this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix;
}; };
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.rotateMix = constraint.data.rotateMix; constraint.rotateMix = constraint.data.rotateMix;
constraint.translateMix = constraint.data.translateMix; constraint.translateMix = constraint.data.translateMix;
return; return;
case MixPose.current: case MixBlend.first:
constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha; constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha;
constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha; constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha;
} }
@ -1122,7 +1242,7 @@ var spine;
rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent; rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent;
translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent; translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent;
} }
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha; constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha;
constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha; constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha;
} }
@ -1238,18 +1358,18 @@ var spine;
if (current == null || current.delay > 0) if (current == null || current.delay > 0)
continue; continue;
applied = true; applied = true;
var currentPose = i == 0 ? spine.MixPose.current : spine.MixPose.currentLayered; var blend = i == 0 ? spine.MixBlend.first : current.mixBlend;
var mix = current.alpha; var mix = current.alpha;
if (current.mixingFrom != null) if (current.mixingFrom != null)
mix *= this.applyMixingFrom(current, skeleton, currentPose); mix *= this.applyMixingFrom(current, skeleton, blend);
else if (current.trackTime >= current.trackEnd && current.next == null) else if (current.trackTime >= current.trackEnd && current.next == null)
mix = 0; mix = 0;
var animationLast = current.animationLast, animationTime = current.getAnimationTime(); var animationLast = current.animationLast, animationTime = current.getAnimationTime();
var timelineCount = current.animation.timelines.length; var timelineCount = current.animation.timelines.length;
var timelines = current.animation.timelines; var timelines = current.animation.timelines;
if (mix == 1) { if (mix == 1 || blend == spine.MixBlend.add) {
for (var ii = 0; ii < timelineCount; ii++) for (var ii = 0; ii < timelineCount; ii++)
timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, spine.MixPose.setup, spine.MixDirection["in"]); timelines[ii].apply(skeleton, animationLast, animationTime, events, mix, blend, spine.MixDirection["in"]);
} }
else { else {
var timelineData = current.timelineData; var timelineData = current.timelineData;
@ -1259,12 +1379,12 @@ var spine;
var timelinesRotation = current.timelinesRotation; var timelinesRotation = current.timelinesRotation;
for (var ii = 0; ii < timelineCount; ii++) { for (var ii = 0; ii < timelineCount; ii++) {
var timeline = timelines[ii]; var timeline = timelines[ii];
var pose = timelineData[ii] >= AnimationState.FIRST ? spine.MixPose.setup : currentPose; var timelineBlend = timelineData[ii] == AnimationState.SUBSEQUENT ? blend : spine.MixBlend.setup;
if (timeline instanceof spine.RotateTimeline) { if (timeline instanceof spine.RotateTimeline) {
this.applyRotateTimeline(timeline, skeleton, animationTime, mix, pose, timelinesRotation, ii << 1, firstFrame); this.applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineBlend, timelinesRotation, ii << 1, firstFrame);
} }
else else
timeline.apply(skeleton, animationLast, animationTime, events, mix, pose, spine.MixDirection["in"]); timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineBlend, spine.MixDirection["in"]);
} }
} }
this.queueEvents(current, animationTime); this.queueEvents(current, animationTime);
@ -1275,65 +1395,74 @@ var spine;
this.queue.drain(); this.queue.drain();
return applied; return applied;
}; };
AnimationState.prototype.applyMixingFrom = function (to, skeleton, currentPose) { AnimationState.prototype.applyMixingFrom = function (to, skeleton, blend) {
var from = to.mixingFrom; var from = to.mixingFrom;
if (from.mixingFrom != null) if (from.mixingFrom != null)
this.applyMixingFrom(from, skeleton, currentPose); this.applyMixingFrom(from, skeleton, blend);
var mix = 0; var mix = 0;
if (to.mixDuration == 0) { if (to.mixDuration == 0) {
mix = 1; mix = 1;
currentPose = spine.MixPose.setup; if (blend == spine.MixBlend.first)
blend = spine.MixBlend.setup;
} }
else { else {
mix = to.mixTime / to.mixDuration; mix = to.mixTime / to.mixDuration;
if (mix > 1) if (mix > 1)
mix = 1; mix = 1;
if (blend != spine.MixBlend.first)
blend = from.mixBlend;
} }
var events = mix < from.eventThreshold ? this.events : null; var events = mix < from.eventThreshold ? this.events : null;
var attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold; var attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold;
var animationLast = from.animationLast, animationTime = from.getAnimationTime(); var animationLast = from.animationLast, animationTime = from.getAnimationTime();
var timelineCount = from.animation.timelines.length; var timelineCount = from.animation.timelines.length;
var timelines = from.animation.timelines; var timelines = from.animation.timelines;
var timelineData = from.timelineData; var alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix);
var timelineDipMix = from.timelineDipMix; if (blend == spine.MixBlend.add) {
var firstFrame = from.timelinesRotation.length == 0; for (var i = 0; i < timelineCount; i++)
if (firstFrame) timelines[i].apply(skeleton, animationLast, animationTime, events, alphaMix, blend, spine.MixDirection.out);
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null); }
var timelinesRotation = from.timelinesRotation; else {
var pose; var timelineData = from.timelineData;
var alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix), alpha = 0; var timelineDipMix = from.timelineDipMix;
from.totalAlpha = 0; var firstFrame = from.timelinesRotation.length == 0;
for (var i = 0; i < timelineCount; i++) { if (firstFrame)
var timeline = timelines[i]; spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
switch (timelineData[i]) { var timelinesRotation = from.timelinesRotation;
case AnimationState.SUBSEQUENT: from.totalAlpha = 0;
if (!attachments && timeline instanceof spine.AttachmentTimeline) for (var i = 0; i < timelineCount; i++) {
continue; var timeline = timelines[i];
if (!drawOrder && timeline instanceof spine.DrawOrderTimeline) var timelineBlend;
continue; var alpha = 0;
pose = currentPose; switch (timelineData[i]) {
alpha = alphaMix; case AnimationState.SUBSEQUENT:
break; if (!attachments && timeline instanceof spine.AttachmentTimeline)
case AnimationState.FIRST: continue;
pose = spine.MixPose.setup; if (!drawOrder && timeline instanceof spine.DrawOrderTimeline)
alpha = alphaMix; continue;
break; timelineBlend = blend;
case AnimationState.DIP: alpha = alphaMix;
pose = spine.MixPose.setup; break;
alpha = alphaDip; case AnimationState.FIRST:
break; timelineBlend = spine.MixBlend.setup;
default: alpha = alphaMix;
pose = spine.MixPose.setup; break;
alpha = alphaDip; case AnimationState.DIP:
var dipMix = timelineDipMix[i]; timelineBlend = spine.MixBlend.setup;
alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration); alpha = alphaDip;
break; break;
} default:
from.totalAlpha += alpha; timelineBlend = spine.MixBlend.setup;
if (timeline instanceof spine.RotateTimeline) var dipMix = timelineDipMix[i];
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame); alpha = alphaDip * Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
else { break;
timeline.apply(skeleton, animationLast, animationTime, events, alpha, pose, spine.MixDirection.out); }
from.totalAlpha += alpha;
if (timeline instanceof spine.RotateTimeline)
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, timelineBlend, timelinesRotation, i << 1, firstFrame);
else {
timeline.apply(skeleton, animationLast, animationTime, events, alpha, timelineBlend, spine.MixDirection.out);
}
} }
} }
if (to.mixDuration > 0) if (to.mixDuration > 0)
@ -1343,18 +1472,18 @@ var spine;
from.nextTrackLast = from.trackTime; from.nextTrackLast = from.trackTime;
return mix; return mix;
}; };
AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, pose, timelinesRotation, i, firstFrame) { AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, blend, timelinesRotation, i, firstFrame) {
if (firstFrame) if (firstFrame)
timelinesRotation[i] = 0; timelinesRotation[i] = 0;
if (alpha == 1) { if (alpha == 1) {
timeline.apply(skeleton, 0, time, null, 1, pose, spine.MixDirection["in"]); timeline.apply(skeleton, 0, time, null, 1, blend, spine.MixDirection["in"]);
return; return;
} }
var rotateTimeline = timeline; var rotateTimeline = timeline;
var frames = rotateTimeline.frames; var frames = rotateTimeline.frames;
var bone = skeleton.bones[rotateTimeline.boneIndex]; var bone = skeleton.bones[rotateTimeline.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
if (pose == spine.MixPose.setup) if (blend == spine.MixBlend.setup)
bone.rotation = bone.data.rotation; bone.rotation = bone.data.rotation;
return; return;
} }
@ -1371,7 +1500,7 @@ var spine;
r2 = prevRotation + r2 * percent + bone.data.rotation; r2 = prevRotation + r2 * percent + bone.data.rotation;
r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360; r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
} }
var r1 = pose == spine.MixPose.setup ? bone.data.rotation : bone.rotation; var r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation;
var total = 0, diff = r2 - r1; var total = 0, diff = r2 - r1;
if (diff == 0) { if (diff == 0) {
total = timelinesRotation[i]; total = timelinesRotation[i];
@ -1601,7 +1730,7 @@ var spine;
var mixingTo = this.mixingTo; var mixingTo = this.mixingTo;
for (var i = 0, n = this.tracks.length; i < n; i++) { for (var i = 0, n = this.tracks.length; i < n; i++) {
var entry = this.tracks[i]; var entry = this.tracks[i];
if (entry != null) if (entry != null && (i == 0 || entry.mixBlend != spine.MixBlend.add))
entry.setTimelineData(null, mixingTo, propertyIDs); entry.setTimelineData(null, mixingTo, propertyIDs);
} }
}; };
@ -1636,6 +1765,7 @@ var spine;
spine.AnimationState = AnimationState; spine.AnimationState = AnimationState;
var TrackEntry = (function () { var TrackEntry = (function () {
function TrackEntry() { function TrackEntry() {
this.mixBlend = spine.MixBlend.replace;
this.timelineData = new Array(); this.timelineData = new Array();
this.timelineDipMix = new Array(); this.timelineDipMix = new Array();
this.timelinesRotation = new Array(); this.timelinesRotation = new Array();

File diff suppressed because one or more lines are too long

View File

@ -20,7 +20,7 @@ var spine;
this.timelines = timelines; this.timelines = timelines;
this.duration = duration; this.duration = duration;
} }
Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, pose, direction) { Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, blend, direction) {
if (skeleton == null) if (skeleton == null)
throw new Error("skeleton cannot be null."); throw new Error("skeleton cannot be null.");
if (loop && this.duration != 0) { if (loop && this.duration != 0) {
@ -30,7 +30,7 @@ var spine;
} }
var timelines = this.timelines; var timelines = this.timelines;
for (var i = 0, n = timelines.length; i < n; i++) for (var i = 0, n = timelines.length; i < n; i++)
timelines[i].apply(skeleton, lastTime, time, events, alpha, pose, direction); timelines[i].apply(skeleton, lastTime, time, events, alpha, blend, direction);
}; };
Animation.binarySearch = function (values, target, step) { Animation.binarySearch = function (values, target, step) {
if (step === void 0) { step = 1; } if (step === void 0) { step = 1; }
@ -58,12 +58,13 @@ var spine;
return Animation; return Animation;
}()); }());
spine.Animation = Animation; spine.Animation = Animation;
var MixPose; var MixBlend;
(function (MixPose) { (function (MixBlend) {
MixPose[MixPose["setup"] = 0] = "setup"; MixBlend[MixBlend["setup"] = 0] = "setup";
MixPose[MixPose["current"] = 1] = "current"; MixBlend[MixBlend["first"] = 1] = "first";
MixPose[MixPose["currentLayered"] = 2] = "currentLayered"; MixBlend[MixBlend["replace"] = 2] = "replace";
})(MixPose = spine.MixPose || (spine.MixPose = {})); MixBlend[MixBlend["add"] = 3] = "add";
})(MixBlend = spine.MixBlend || (spine.MixBlend = {}));
var MixDirection; var MixDirection;
(function (MixDirection) { (function (MixDirection) {
MixDirection[MixDirection["in"] = 0] = "in"; MixDirection[MixDirection["in"] = 0] = "in";
@ -184,28 +185,32 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.frames[frameIndex + RotateTimeline.ROTATION] = degrees; this.frames[frameIndex + RotateTimeline.ROTATION] = degrees;
}; };
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.rotation = bone.data.rotation; bone.rotation = bone.data.rotation;
return; return;
case MixPose.current: case MixBlend.first:
var r_1 = bone.data.rotation - bone.rotation; var r_1 = bone.data.rotation - bone.rotation;
r_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360; bone.rotation += (r_1 - (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360) * alpha;
bone.rotation += r_1 * alpha;
} }
return; return;
} }
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) { if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
if (pose == MixPose.setup) var r = frames[frames.length + RotateTimeline.PREV_ROTATION];
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha; switch (blend) {
else { case MixBlend.setup:
var r_2 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation; bone.rotation = bone.data.rotation + r * alpha;
r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360; break;
bone.rotation += r_2 * alpha; case MixBlend.first:
case MixBlend.replace:
r += bone.data.rotation - bone.rotation;
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
case MixBlend.add:
bone.rotation += r * alpha;
} }
return; return;
} }
@ -213,17 +218,17 @@ var spine;
var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION]; var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION];
var frameTime = frames[frame]; var frameTime = frames[frame];
var percent = this.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime));
var r = frames[frame + RotateTimeline.ROTATION] - prevRotation; r = frames[frame + RotateTimeline.ROTATION] - prevRotation;
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; r = prevRotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * percent;
r = prevRotation + r * percent; switch (blend) {
if (pose == MixPose.setup) { case MixBlend.setup:
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; bone.rotation = bone.data.rotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha;
bone.rotation = bone.data.rotation + r * alpha; break;
} case MixBlend.first:
else { case MixBlend.replace:
r = bone.data.rotation + r - bone.rotation; r += bone.data.rotation - bone.rotation;
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; case MixBlend.add:
bone.rotation += r * alpha; bone.rotation += (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha;
} }
}; };
return RotateTimeline; return RotateTimeline;
@ -249,16 +254,16 @@ var spine;
this.frames[frameIndex + TranslateTimeline.X] = x; this.frames[frameIndex + TranslateTimeline.X] = x;
this.frames[frameIndex + TranslateTimeline.Y] = y; this.frames[frameIndex + TranslateTimeline.Y] = y;
}; };
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.x = bone.data.x; bone.x = bone.data.x;
bone.y = bone.data.y; bone.y = bone.data.y;
return; return;
case MixPose.current: case MixBlend.first:
bone.x += (bone.data.x - bone.x) * alpha; bone.x += (bone.data.x - bone.x) * alpha;
bone.y += (bone.data.y - bone.y) * alpha; bone.y += (bone.data.y - bone.y) * alpha;
} }
@ -278,13 +283,19 @@ var spine;
x += (frames[frame + TranslateTimeline.X] - x) * percent; x += (frames[frame + TranslateTimeline.X] - x) * percent;
y += (frames[frame + TranslateTimeline.Y] - y) * percent; y += (frames[frame + TranslateTimeline.Y] - y) * percent;
} }
if (pose == MixPose.setup) { switch (blend) {
bone.x = bone.data.x + x * alpha; case MixBlend.setup:
bone.y = bone.data.y + y * alpha; bone.x = bone.data.x + x * alpha;
} bone.y = bone.data.y + y * alpha;
else { break;
bone.x += (bone.data.x + x - bone.x) * alpha; case MixBlend.first:
bone.y += (bone.data.y + y - bone.y) * alpha; case MixBlend.replace:
bone.x += (bone.data.x + x - bone.x) * alpha;
bone.y += (bone.data.y + y - bone.y) * alpha;
break;
case MixBlend.add:
bone.x += x * alpha;
bone.y += y * alpha;
} }
}; };
return TranslateTimeline; return TranslateTimeline;
@ -304,16 +315,16 @@ var spine;
ScaleTimeline.prototype.getPropertyId = function () { ScaleTimeline.prototype.getPropertyId = function () {
return (TimelineType.scale << 24) + this.boneIndex; return (TimelineType.scale << 24) + this.boneIndex;
}; };
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.scaleX = bone.data.scaleX; bone.scaleX = bone.data.scaleX;
bone.scaleY = bone.data.scaleY; bone.scaleY = bone.data.scaleY;
return; return;
case MixPose.current: case MixBlend.first:
bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha; bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;
bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha; bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;
} }
@ -334,29 +345,61 @@ var spine;
y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY; y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY;
} }
if (alpha == 1) { if (alpha == 1) {
bone.scaleX = x; if (blend == MixBlend.add) {
bone.scaleY = y; bone.scaleX += x - bone.data.scaleX;
bone.scaleY += y - bone.data.scaleY;
}
else {
bone.scaleX = x;
bone.scaleY = y;
}
} }
else { else {
var bx = 0, by = 0; var bx = 0, by = 0;
if (pose == MixPose.setup) {
bx = bone.data.scaleX;
by = bone.data.scaleY;
}
else {
bx = bone.scaleX;
by = bone.scaleY;
}
if (direction == MixDirection.out) { if (direction == MixDirection.out) {
x = Math.abs(x) * spine.MathUtils.signum(bx); switch (blend) {
y = Math.abs(y) * spine.MathUtils.signum(by); case MixBlend.setup:
bx = bone.data.scaleX;
by = bone.data.scaleY;
bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bx) * alpha;
bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - by) * alpha;
break;
case MixBlend.first:
case MixBlend.replace:
bx = bone.scaleX;
by = bone.scaleY;
bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bx) * alpha;
bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - by) * alpha;
break;
case MixBlend.add:
bx = bone.scaleX;
by = bone.scaleY;
bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bone.data.scaleX) * alpha;
bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - bone.data.scaleY) * alpha;
}
} }
else { else {
bx = Math.abs(bx) * spine.MathUtils.signum(x); switch (blend) {
by = Math.abs(by) * spine.MathUtils.signum(y); case MixBlend.setup:
bx = Math.abs(bone.data.scaleX) * spine.MathUtils.signum(x);
by = Math.abs(bone.data.scaleY) * spine.MathUtils.signum(y);
bone.scaleX = bx + (x - bx) * alpha;
bone.scaleY = by + (y - by) * alpha;
break;
case MixBlend.first:
case MixBlend.replace:
bx = Math.abs(bone.scaleX) * spine.MathUtils.signum(x);
by = Math.abs(bone.scaleY) * spine.MathUtils.signum(y);
bone.scaleX = bx + (x - bx) * alpha;
bone.scaleY = by + (y - by) * alpha;
break;
case MixBlend.add:
bx = spine.MathUtils.signum(x);
by = spine.MathUtils.signum(y);
bone.scaleX = Math.abs(bone.scaleX) * bx + (x - Math.abs(bone.data.scaleX) * bx) * alpha;
bone.scaleY = Math.abs(bone.scaleY) * by + (y - Math.abs(bone.data.scaleY) * by) * alpha;
}
} }
bone.scaleX = bx + (x - bx) * alpha;
bone.scaleY = by + (y - by) * alpha;
} }
}; };
return ScaleTimeline; return ScaleTimeline;
@ -370,16 +413,16 @@ var spine;
ShearTimeline.prototype.getPropertyId = function () { ShearTimeline.prototype.getPropertyId = function () {
return (TimelineType.shear << 24) + this.boneIndex; return (TimelineType.shear << 24) + this.boneIndex;
}; };
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.shearX = bone.data.shearX; bone.shearX = bone.data.shearX;
bone.shearY = bone.data.shearY; bone.shearY = bone.data.shearY;
return; return;
case MixPose.current: case MixBlend.first:
bone.shearX += (bone.data.shearX - bone.shearX) * alpha; bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
bone.shearY += (bone.data.shearY - bone.shearY) * alpha; bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
} }
@ -399,13 +442,19 @@ var spine;
x = x + (frames[frame + ShearTimeline.X] - x) * percent; x = x + (frames[frame + ShearTimeline.X] - x) * percent;
y = y + (frames[frame + ShearTimeline.Y] - y) * percent; y = y + (frames[frame + ShearTimeline.Y] - y) * percent;
} }
if (pose == MixPose.setup) { switch (blend) {
bone.shearX = bone.data.shearX + x * alpha; case MixBlend.setup:
bone.shearY = bone.data.shearY + y * alpha; bone.shearX = bone.data.shearX + x * alpha;
} bone.shearY = bone.data.shearY + y * alpha;
else { break;
bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha; case MixBlend.first:
bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha; case MixBlend.replace:
bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha;
bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha;
break;
case MixBlend.add:
bone.shearX += x * alpha;
bone.shearY += y * alpha;
} }
}; };
return ShearTimeline; return ShearTimeline;
@ -429,15 +478,15 @@ var spine;
this.frames[frameIndex + ColorTimeline.B] = b; this.frames[frameIndex + ColorTimeline.B] = b;
this.frames[frameIndex + ColorTimeline.A] = a; this.frames[frameIndex + ColorTimeline.A] = a;
}; };
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
slot.color.setFromColor(slot.data.color); slot.color.setFromColor(slot.data.color);
return; return;
case MixPose.current: case MixBlend.first:
var color = slot.color, setup = slot.data.color; var color = slot.color, setup = slot.data.color;
color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha); color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha);
} }
@ -468,7 +517,7 @@ var spine;
slot.color.set(r, g, b, a); slot.color.set(r, g, b, a);
else { else {
var color = slot.color; var color = slot.color;
if (pose == MixPose.setup) if (blend == MixBlend.setup)
color.setFromColor(slot.data.color); color.setFromColor(slot.data.color);
color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha); color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
} }
@ -507,16 +556,16 @@ var spine;
this.frames[frameIndex + TwoColorTimeline.G2] = g2; this.frames[frameIndex + TwoColorTimeline.G2] = g2;
this.frames[frameIndex + TwoColorTimeline.B2] = b2; this.frames[frameIndex + TwoColorTimeline.B2] = b2;
}; };
TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
slot.color.setFromColor(slot.data.color); slot.color.setFromColor(slot.data.color);
slot.darkColor.setFromColor(slot.data.darkColor); slot.darkColor.setFromColor(slot.data.darkColor);
return; return;
case MixPose.current: case MixBlend.setup:
var light = slot.color, dark = slot.darkColor, setupLight = slot.data.color, setupDark = slot.data.darkColor; var light = slot.color, dark = slot.darkColor, setupLight = slot.data.color, setupDark = slot.data.darkColor;
light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha); light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha);
dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0); dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0);
@ -559,7 +608,7 @@ var spine;
} }
else { else {
var light = slot.color, dark = slot.darkColor; var light = slot.color, dark = slot.darkColor;
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
light.setFromColor(slot.data.color); light.setFromColor(slot.data.color);
dark.setFromColor(slot.data.darkColor); dark.setFromColor(slot.data.darkColor);
} }
@ -601,16 +650,16 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.attachmentNames[frameIndex] = attachmentName; this.attachmentNames[frameIndex] = attachmentName;
}; };
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
if (direction == MixDirection.out && pose == MixPose.setup) { if (direction == MixDirection.out && blend == MixBlend.setup) {
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 (pose == MixPose.setup) { if (blend == MixBlend.setup || blend == MixBlend.first) {
var attachmentName_2 = slot.data.attachmentName; var attachmentName_2 = slot.data.attachmentName;
slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2)); slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2));
} }
@ -646,24 +695,24 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.frameVertices[frameIndex] = vertices; this.frameVertices[frameIndex] = vertices;
}; };
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
var slotAttachment = slot.getAttachment(); var slotAttachment = slot.getAttachment();
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment)) if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
return; return;
var verticesArray = slot.attachmentVertices; var verticesArray = slot.attachmentVertices;
if (verticesArray.length == 0) if (verticesArray.length == 0)
alpha = 1; blend = MixBlend.setup;
var frameVertices = this.frameVertices; var frameVertices = this.frameVertices;
var vertexCount = frameVertices[0].length; var vertexCount = frameVertices[0].length;
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
var vertexAttachment = slotAttachment; var vertexAttachment = slotAttachment;
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
verticesArray.length = 0; verticesArray.length = 0;
return; return;
case MixPose.current: case MixBlend.first:
if (alpha == 1) { if (alpha == 1) {
verticesArray.length = 0; verticesArray.length = 0;
break; break;
@ -686,25 +735,57 @@ var spine;
if (time >= frames[frames.length - 1]) { if (time >= frames[frames.length - 1]) {
var lastVertices = frameVertices[frames.length - 1]; var lastVertices = frameVertices[frames.length - 1];
if (alpha == 1) { if (alpha == 1) {
spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount); if (blend == MixBlend.add) {
} var vertexAttachment = slotAttachment;
else if (pose == MixPose.setup) { if (vertexAttachment.bones == null) {
var vertexAttachment = slotAttachment; var setupVertices_1 = vertexAttachment.vertices;
if (vertexAttachment.bones == null) { for (var i_1 = 0; i_1 < vertexCount; i_1++) {
var setupVertices_1 = vertexAttachment.vertices; vertices[i_1] += lastVertices[i_1] - setupVertices_1[i_1];
for (var i_1 = 0; i_1 < vertexCount; i_1++) { }
var setup = setupVertices_1[i_1]; }
vertices[i_1] = setup + (lastVertices[i_1] - setup) * alpha; else {
for (var i_2 = 0; i_2 < vertexCount; i_2++)
vertices[i_2] += lastVertices[i_2];
} }
} }
else { else {
for (var i_2 = 0; i_2 < vertexCount; i_2++) spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount);
vertices[i_2] = lastVertices[i_2] * alpha;
} }
} }
else { else {
for (var i_3 = 0; i_3 < vertexCount; i_3++) switch (blend) {
vertices[i_3] += (lastVertices[i_3] - vertices[i_3]) * alpha; case MixBlend.setup: {
var vertexAttachment_1 = slotAttachment;
if (vertexAttachment_1.bones == null) {
var setupVertices_2 = vertexAttachment_1.vertices;
for (var i_3 = 0; i_3 < vertexCount; i_3++) {
var setup = setupVertices_2[i_3];
vertices[i_3] = setup + (lastVertices[i_3] - setup) * alpha;
}
}
else {
for (var i_4 = 0; i_4 < vertexCount; i_4++)
vertices[i_4] = lastVertices[i_4] * alpha;
}
break;
}
case MixBlend.first:
case MixBlend.replace:
for (var i_5 = 0; i_5 < vertexCount; i_5++)
vertices[i_5] += (lastVertices[i_5] - vertices[i_5]) * alpha;
case MixBlend.add:
var vertexAttachment = slotAttachment;
if (vertexAttachment.bones == null) {
var setupVertices_3 = vertexAttachment.vertices;
for (var i_6 = 0; i_6 < vertexCount; i_6++) {
vertices[i_6] += (lastVertices[i_6] - setupVertices_3[i_6]) * alpha;
}
}
else {
for (var i_7 = 0; i_7 < vertexCount; i_7++)
vertices[i_7] += lastVertices[i_7] * alpha;
}
}
} }
return; return;
} }
@ -714,31 +795,70 @@ var spine;
var frameTime = frames[frame]; var frameTime = frames[frame];
var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime)); var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime));
if (alpha == 1) { if (alpha == 1) {
for (var i_4 = 0; i_4 < vertexCount; i_4++) { if (blend == MixBlend.add) {
var prev = prevVertices[i_4]; var vertexAttachment = slotAttachment;
vertices[i_4] = prev + (nextVertices[i_4] - prev) * percent; if (vertexAttachment.bones == null) {
} var setupVertices_4 = vertexAttachment.vertices;
} for (var i_8 = 0; i_8 < vertexCount; i_8++) {
else if (pose == MixPose.setup) { var prev = prevVertices[i_8];
var vertexAttachment = slotAttachment; vertices[i_8] += prev + (nextVertices[i_8] - prev) * percent - setupVertices_4[i_8];
if (vertexAttachment.bones == null) { }
var setupVertices_2 = vertexAttachment.vertices; }
for (var i_5 = 0; i_5 < vertexCount; i_5++) { else {
var prev = prevVertices[i_5], setup = setupVertices_2[i_5]; for (var i_9 = 0; i_9 < vertexCount; i_9++) {
vertices[i_5] = setup + (prev + (nextVertices[i_5] - prev) * percent - setup) * alpha; var prev = prevVertices[i_9];
vertices[i_9] += prev + (nextVertices[i_9] - prev) * percent;
}
} }
} }
else { else {
for (var i_6 = 0; i_6 < vertexCount; i_6++) { for (var i_10 = 0; i_10 < vertexCount; i_10++) {
var prev = prevVertices[i_6]; var prev = prevVertices[i_10];
vertices[i_6] = (prev + (nextVertices[i_6] - prev) * percent) * alpha; vertices[i_10] = prev + (nextVertices[i_10] - prev) * percent;
} }
} }
} }
else { else {
for (var i_7 = 0; i_7 < vertexCount; i_7++) { switch (blend) {
var prev = prevVertices[i_7]; case MixBlend.setup: {
vertices[i_7] += (prev + (nextVertices[i_7] - prev) * percent - vertices[i_7]) * alpha; var vertexAttachment_2 = slotAttachment;
if (vertexAttachment_2.bones == null) {
var setupVertices_5 = vertexAttachment_2.vertices;
for (var i_11 = 0; i_11 < vertexCount; i_11++) {
var prev = prevVertices[i_11], setup = setupVertices_5[i_11];
vertices[i_11] = setup + (prev + (nextVertices[i_11] - prev) * percent - setup) * alpha;
}
}
else {
for (var i_12 = 0; i_12 < vertexCount; i_12++) {
var prev = prevVertices[i_12];
vertices[i_12] = (prev + (nextVertices[i_12] - prev) * percent) * alpha;
}
}
break;
}
case MixBlend.first:
case MixBlend.replace:
for (var i_13 = 0; i_13 < vertexCount; i_13++) {
var prev = prevVertices[i_13];
vertices[i_13] += (prev + (nextVertices[i_13] - prev) * percent - vertices[i_13]) * alpha;
}
break;
case MixBlend.add:
var vertexAttachment = slotAttachment;
if (vertexAttachment.bones == null) {
var setupVertices_6 = vertexAttachment.vertices;
for (var i_14 = 0; i_14 < vertexCount; i_14++) {
var prev = prevVertices[i_14];
vertices[i_14] += (prev + (nextVertices[i_14] - prev) * percent - setupVertices_6[i_14]) * alpha;
}
}
else {
for (var i_15 = 0; i_15 < vertexCount; i_15++) {
var prev = prevVertices[i_15];
vertices[i_15] += (prev + (nextVertices[i_15] - prev) * percent) * alpha;
}
}
} }
} }
}; };
@ -760,13 +880,13 @@ var spine;
this.frames[frameIndex] = event.time; this.frames[frameIndex] = event.time;
this.events[frameIndex] = event; this.events[frameIndex] = event;
}; };
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
if (firedEvents == null) if (firedEvents == null)
return; return;
var frames = this.frames; var frames = this.frames;
var frameCount = this.frames.length; var frameCount = this.frames.length;
if (lastTime > time) { if (lastTime > time) {
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, pose, direction); this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, blend, direction);
lastTime = -1; lastTime = -1;
} }
else if (lastTime >= frames[frameCount - 1]) else if (lastTime >= frames[frameCount - 1])
@ -806,16 +926,16 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.drawOrders[frameIndex] = drawOrder; this.drawOrders[frameIndex] = drawOrder;
}; };
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var drawOrder = skeleton.drawOrder; var drawOrder = skeleton.drawOrder;
var slots = skeleton.slots; var slots = skeleton.slots;
if (direction == MixDirection.out && pose == MixPose.setup) { if (direction == MixDirection.out && blend == MixBlend.setup) {
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
return; return;
} }
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
if (pose == MixPose.setup) if (blend == MixBlend.setup)
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
return; return;
} }
@ -851,23 +971,23 @@ var spine;
this.frames[frameIndex + IkConstraintTimeline.MIX] = mix; this.frames[frameIndex + IkConstraintTimeline.MIX] = mix;
this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection; this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection;
}; };
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.ikConstraints[this.ikConstraintIndex]; var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.mix = constraint.data.mix; constraint.mix = constraint.data.mix;
constraint.bendDirection = constraint.data.bendDirection; constraint.bendDirection = constraint.data.bendDirection;
return; return;
case MixPose.current: case MixBlend.first:
constraint.mix += (constraint.data.mix - constraint.mix) * alpha; constraint.mix += (constraint.data.mix - constraint.mix) * alpha;
constraint.bendDirection = constraint.data.bendDirection; constraint.bendDirection = constraint.data.bendDirection;
} }
return; return;
} }
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) { if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
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;
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection
: frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION]; : frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
@ -883,7 +1003,7 @@ var spine;
var mix = frames[frame + IkConstraintTimeline.PREV_MIX]; var mix = frames[frame + IkConstraintTimeline.PREV_MIX];
var frameTime = frames[frame]; var frameTime = frames[frame];
var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime));
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha; constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha;
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
} }
@ -920,19 +1040,19 @@ var spine;
this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix; this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix;
this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix; this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix;
}; };
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.transformConstraints[this.transformConstraintIndex]; var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
var data = constraint.data; var data = constraint.data;
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.rotateMix = data.rotateMix; constraint.rotateMix = data.rotateMix;
constraint.translateMix = data.translateMix; constraint.translateMix = data.translateMix;
constraint.scaleMix = data.scaleMix; constraint.scaleMix = data.scaleMix;
constraint.shearMix = data.shearMix; constraint.shearMix = data.shearMix;
return; return;
case MixPose.current: case MixBlend.setup:
constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha; constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha;
constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha; constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha;
constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha; constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha;
@ -961,7 +1081,7 @@ var spine;
scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent; scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent;
shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent; shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent;
} }
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
var data = constraint.data; var 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;
@ -1003,15 +1123,15 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value; this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value;
}; };
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.position = constraint.data.position; constraint.position = constraint.data.position;
return; return;
case MixPose.current: case MixBlend.first:
constraint.position += (constraint.data.position - constraint.position) * alpha; constraint.position += (constraint.data.position - constraint.position) * alpha;
} }
return; return;
@ -1026,7 +1146,7 @@ var spine;
var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime));
position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent; position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent;
} }
if (pose == MixPose.setup) if (blend == MixBlend.setup)
constraint.position = constraint.data.position + (position - constraint.data.position) * alpha; constraint.position = constraint.data.position + (position - constraint.data.position) * alpha;
else else
constraint.position += (position - constraint.position) * alpha; constraint.position += (position - constraint.position) * alpha;
@ -1046,15 +1166,15 @@ var spine;
PathConstraintSpacingTimeline.prototype.getPropertyId = function () { PathConstraintSpacingTimeline.prototype.getPropertyId = function () {
return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex; return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex;
}; };
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.spacing = constraint.data.spacing; constraint.spacing = constraint.data.spacing;
return; return;
case MixPose.current: case MixBlend.first:
constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha; constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha;
} }
return; return;
@ -1069,7 +1189,7 @@ var spine;
var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime));
spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent; spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent;
} }
if (pose == MixPose.setup) if (blend == MixBlend.setup)
constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha; constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;
else else
constraint.spacing += (spacing - constraint.spacing) * alpha; constraint.spacing += (spacing - constraint.spacing) * alpha;
@ -1093,16 +1213,16 @@ var spine;
this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix; this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix;
this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix; this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix;
}; };
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.rotateMix = constraint.data.rotateMix; constraint.rotateMix = constraint.data.rotateMix;
constraint.translateMix = constraint.data.translateMix; constraint.translateMix = constraint.data.translateMix;
return; return;
case MixPose.current: case MixBlend.first:
constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha; constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha;
constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha; constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha;
} }
@ -1122,7 +1242,7 @@ var spine;
rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent; rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent;
translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent; translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent;
} }
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha; constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha;
constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha; constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha;
} }
@ -1238,18 +1358,18 @@ var spine;
if (current == null || current.delay > 0) if (current == null || current.delay > 0)
continue; continue;
applied = true; applied = true;
var currentPose = i == 0 ? spine.MixPose.current : spine.MixPose.currentLayered; var blend = i == 0 ? spine.MixBlend.first : current.mixBlend;
var mix = current.alpha; var mix = current.alpha;
if (current.mixingFrom != null) if (current.mixingFrom != null)
mix *= this.applyMixingFrom(current, skeleton, currentPose); mix *= this.applyMixingFrom(current, skeleton, blend);
else if (current.trackTime >= current.trackEnd && current.next == null) else if (current.trackTime >= current.trackEnd && current.next == null)
mix = 0; mix = 0;
var animationLast = current.animationLast, animationTime = current.getAnimationTime(); var animationLast = current.animationLast, animationTime = current.getAnimationTime();
var timelineCount = current.animation.timelines.length; var timelineCount = current.animation.timelines.length;
var timelines = current.animation.timelines; var timelines = current.animation.timelines;
if (mix == 1) { if (mix == 1 || blend == spine.MixBlend.add) {
for (var ii = 0; ii < timelineCount; ii++) for (var ii = 0; ii < timelineCount; ii++)
timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, spine.MixPose.setup, spine.MixDirection["in"]); timelines[ii].apply(skeleton, animationLast, animationTime, events, mix, blend, spine.MixDirection["in"]);
} }
else { else {
var timelineData = current.timelineData; var timelineData = current.timelineData;
@ -1259,12 +1379,12 @@ var spine;
var timelinesRotation = current.timelinesRotation; var timelinesRotation = current.timelinesRotation;
for (var ii = 0; ii < timelineCount; ii++) { for (var ii = 0; ii < timelineCount; ii++) {
var timeline = timelines[ii]; var timeline = timelines[ii];
var pose = timelineData[ii] >= AnimationState.FIRST ? spine.MixPose.setup : currentPose; var timelineBlend = timelineData[ii] == AnimationState.SUBSEQUENT ? blend : spine.MixBlend.setup;
if (timeline instanceof spine.RotateTimeline) { if (timeline instanceof spine.RotateTimeline) {
this.applyRotateTimeline(timeline, skeleton, animationTime, mix, pose, timelinesRotation, ii << 1, firstFrame); this.applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineBlend, timelinesRotation, ii << 1, firstFrame);
} }
else else
timeline.apply(skeleton, animationLast, animationTime, events, mix, pose, spine.MixDirection["in"]); timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineBlend, spine.MixDirection["in"]);
} }
} }
this.queueEvents(current, animationTime); this.queueEvents(current, animationTime);
@ -1275,65 +1395,74 @@ var spine;
this.queue.drain(); this.queue.drain();
return applied; return applied;
}; };
AnimationState.prototype.applyMixingFrom = function (to, skeleton, currentPose) { AnimationState.prototype.applyMixingFrom = function (to, skeleton, blend) {
var from = to.mixingFrom; var from = to.mixingFrom;
if (from.mixingFrom != null) if (from.mixingFrom != null)
this.applyMixingFrom(from, skeleton, currentPose); this.applyMixingFrom(from, skeleton, blend);
var mix = 0; var mix = 0;
if (to.mixDuration == 0) { if (to.mixDuration == 0) {
mix = 1; mix = 1;
currentPose = spine.MixPose.setup; if (blend == spine.MixBlend.first)
blend = spine.MixBlend.setup;
} }
else { else {
mix = to.mixTime / to.mixDuration; mix = to.mixTime / to.mixDuration;
if (mix > 1) if (mix > 1)
mix = 1; mix = 1;
if (blend != spine.MixBlend.first)
blend = from.mixBlend;
} }
var events = mix < from.eventThreshold ? this.events : null; var events = mix < from.eventThreshold ? this.events : null;
var attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold; var attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold;
var animationLast = from.animationLast, animationTime = from.getAnimationTime(); var animationLast = from.animationLast, animationTime = from.getAnimationTime();
var timelineCount = from.animation.timelines.length; var timelineCount = from.animation.timelines.length;
var timelines = from.animation.timelines; var timelines = from.animation.timelines;
var timelineData = from.timelineData; var alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix);
var timelineDipMix = from.timelineDipMix; if (blend == spine.MixBlend.add) {
var firstFrame = from.timelinesRotation.length == 0; for (var i = 0; i < timelineCount; i++)
if (firstFrame) timelines[i].apply(skeleton, animationLast, animationTime, events, alphaMix, blend, spine.MixDirection.out);
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null); }
var timelinesRotation = from.timelinesRotation; else {
var pose; var timelineData = from.timelineData;
var alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix), alpha = 0; var timelineDipMix = from.timelineDipMix;
from.totalAlpha = 0; var firstFrame = from.timelinesRotation.length == 0;
for (var i = 0; i < timelineCount; i++) { if (firstFrame)
var timeline = timelines[i]; spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
switch (timelineData[i]) { var timelinesRotation = from.timelinesRotation;
case AnimationState.SUBSEQUENT: from.totalAlpha = 0;
if (!attachments && timeline instanceof spine.AttachmentTimeline) for (var i = 0; i < timelineCount; i++) {
continue; var timeline = timelines[i];
if (!drawOrder && timeline instanceof spine.DrawOrderTimeline) var timelineBlend;
continue; var alpha = 0;
pose = currentPose; switch (timelineData[i]) {
alpha = alphaMix; case AnimationState.SUBSEQUENT:
break; if (!attachments && timeline instanceof spine.AttachmentTimeline)
case AnimationState.FIRST: continue;
pose = spine.MixPose.setup; if (!drawOrder && timeline instanceof spine.DrawOrderTimeline)
alpha = alphaMix; continue;
break; timelineBlend = blend;
case AnimationState.DIP: alpha = alphaMix;
pose = spine.MixPose.setup; break;
alpha = alphaDip; case AnimationState.FIRST:
break; timelineBlend = spine.MixBlend.setup;
default: alpha = alphaMix;
pose = spine.MixPose.setup; break;
alpha = alphaDip; case AnimationState.DIP:
var dipMix = timelineDipMix[i]; timelineBlend = spine.MixBlend.setup;
alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration); alpha = alphaDip;
break; break;
} default:
from.totalAlpha += alpha; timelineBlend = spine.MixBlend.setup;
if (timeline instanceof spine.RotateTimeline) var dipMix = timelineDipMix[i];
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame); alpha = alphaDip * Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
else { break;
timeline.apply(skeleton, animationLast, animationTime, events, alpha, pose, spine.MixDirection.out); }
from.totalAlpha += alpha;
if (timeline instanceof spine.RotateTimeline)
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, timelineBlend, timelinesRotation, i << 1, firstFrame);
else {
timeline.apply(skeleton, animationLast, animationTime, events, alpha, timelineBlend, spine.MixDirection.out);
}
} }
} }
if (to.mixDuration > 0) if (to.mixDuration > 0)
@ -1343,18 +1472,18 @@ var spine;
from.nextTrackLast = from.trackTime; from.nextTrackLast = from.trackTime;
return mix; return mix;
}; };
AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, pose, timelinesRotation, i, firstFrame) { AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, blend, timelinesRotation, i, firstFrame) {
if (firstFrame) if (firstFrame)
timelinesRotation[i] = 0; timelinesRotation[i] = 0;
if (alpha == 1) { if (alpha == 1) {
timeline.apply(skeleton, 0, time, null, 1, pose, spine.MixDirection["in"]); timeline.apply(skeleton, 0, time, null, 1, blend, spine.MixDirection["in"]);
return; return;
} }
var rotateTimeline = timeline; var rotateTimeline = timeline;
var frames = rotateTimeline.frames; var frames = rotateTimeline.frames;
var bone = skeleton.bones[rotateTimeline.boneIndex]; var bone = skeleton.bones[rotateTimeline.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
if (pose == spine.MixPose.setup) if (blend == spine.MixBlend.setup)
bone.rotation = bone.data.rotation; bone.rotation = bone.data.rotation;
return; return;
} }
@ -1371,7 +1500,7 @@ var spine;
r2 = prevRotation + r2 * percent + bone.data.rotation; r2 = prevRotation + r2 * percent + bone.data.rotation;
r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360; r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
} }
var r1 = pose == spine.MixPose.setup ? bone.data.rotation : bone.rotation; var r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation;
var total = 0, diff = r2 - r1; var total = 0, diff = r2 - r1;
if (diff == 0) { if (diff == 0) {
total = timelinesRotation[i]; total = timelinesRotation[i];
@ -1601,7 +1730,7 @@ var spine;
var mixingTo = this.mixingTo; var mixingTo = this.mixingTo;
for (var i = 0, n = this.tracks.length; i < n; i++) { for (var i = 0, n = this.tracks.length; i < n; i++) {
var entry = this.tracks[i]; var entry = this.tracks[i];
if (entry != null) if (entry != null && (i == 0 || entry.mixBlend != spine.MixBlend.add))
entry.setTimelineData(null, mixingTo, propertyIDs); entry.setTimelineData(null, mixingTo, propertyIDs);
} }
}; };
@ -1636,6 +1765,7 @@ var spine;
spine.AnimationState = AnimationState; spine.AnimationState = AnimationState;
var TrackEntry = (function () { var TrackEntry = (function () {
function TrackEntry() { function TrackEntry() {
this.mixBlend = spine.MixBlend.replace;
this.timelineData = new Array(); this.timelineData = new Array();
this.timelineDipMix = new Array(); this.timelineDipMix = new Array();
this.timelinesRotation = new Array(); this.timelinesRotation = new Array();

File diff suppressed because one or more lines are too long

View File

@ -20,7 +20,7 @@ var spine;
this.timelines = timelines; this.timelines = timelines;
this.duration = duration; this.duration = duration;
} }
Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, pose, direction) { Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, blend, direction) {
if (skeleton == null) if (skeleton == null)
throw new Error("skeleton cannot be null."); throw new Error("skeleton cannot be null.");
if (loop && this.duration != 0) { if (loop && this.duration != 0) {
@ -30,7 +30,7 @@ var spine;
} }
var timelines = this.timelines; var timelines = this.timelines;
for (var i = 0, n = timelines.length; i < n; i++) for (var i = 0, n = timelines.length; i < n; i++)
timelines[i].apply(skeleton, lastTime, time, events, alpha, pose, direction); timelines[i].apply(skeleton, lastTime, time, events, alpha, blend, direction);
}; };
Animation.binarySearch = function (values, target, step) { Animation.binarySearch = function (values, target, step) {
if (step === void 0) { step = 1; } if (step === void 0) { step = 1; }
@ -58,12 +58,13 @@ var spine;
return Animation; return Animation;
}()); }());
spine.Animation = Animation; spine.Animation = Animation;
var MixPose; var MixBlend;
(function (MixPose) { (function (MixBlend) {
MixPose[MixPose["setup"] = 0] = "setup"; MixBlend[MixBlend["setup"] = 0] = "setup";
MixPose[MixPose["current"] = 1] = "current"; MixBlend[MixBlend["first"] = 1] = "first";
MixPose[MixPose["currentLayered"] = 2] = "currentLayered"; MixBlend[MixBlend["replace"] = 2] = "replace";
})(MixPose = spine.MixPose || (spine.MixPose = {})); MixBlend[MixBlend["add"] = 3] = "add";
})(MixBlend = spine.MixBlend || (spine.MixBlend = {}));
var MixDirection; var MixDirection;
(function (MixDirection) { (function (MixDirection) {
MixDirection[MixDirection["in"] = 0] = "in"; MixDirection[MixDirection["in"] = 0] = "in";
@ -184,28 +185,32 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.frames[frameIndex + RotateTimeline.ROTATION] = degrees; this.frames[frameIndex + RotateTimeline.ROTATION] = degrees;
}; };
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.rotation = bone.data.rotation; bone.rotation = bone.data.rotation;
return; return;
case MixPose.current: case MixBlend.first:
var r_1 = bone.data.rotation - bone.rotation; var r_1 = bone.data.rotation - bone.rotation;
r_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360; bone.rotation += (r_1 - (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360) * alpha;
bone.rotation += r_1 * alpha;
} }
return; return;
} }
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) { if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
if (pose == MixPose.setup) var r = frames[frames.length + RotateTimeline.PREV_ROTATION];
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha; switch (blend) {
else { case MixBlend.setup:
var r_2 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation; bone.rotation = bone.data.rotation + r * alpha;
r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360; break;
bone.rotation += r_2 * alpha; case MixBlend.first:
case MixBlend.replace:
r += bone.data.rotation - bone.rotation;
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
case MixBlend.add:
bone.rotation += r * alpha;
} }
return; return;
} }
@ -213,17 +218,17 @@ var spine;
var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION]; var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION];
var frameTime = frames[frame]; var frameTime = frames[frame];
var percent = this.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime));
var r = frames[frame + RotateTimeline.ROTATION] - prevRotation; r = frames[frame + RotateTimeline.ROTATION] - prevRotation;
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; r = prevRotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * percent;
r = prevRotation + r * percent; switch (blend) {
if (pose == MixPose.setup) { case MixBlend.setup:
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; bone.rotation = bone.data.rotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha;
bone.rotation = bone.data.rotation + r * alpha; break;
} case MixBlend.first:
else { case MixBlend.replace:
r = bone.data.rotation + r - bone.rotation; r += bone.data.rotation - bone.rotation;
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; case MixBlend.add:
bone.rotation += r * alpha; bone.rotation += (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha;
} }
}; };
return RotateTimeline; return RotateTimeline;
@ -249,16 +254,16 @@ var spine;
this.frames[frameIndex + TranslateTimeline.X] = x; this.frames[frameIndex + TranslateTimeline.X] = x;
this.frames[frameIndex + TranslateTimeline.Y] = y; this.frames[frameIndex + TranslateTimeline.Y] = y;
}; };
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.x = bone.data.x; bone.x = bone.data.x;
bone.y = bone.data.y; bone.y = bone.data.y;
return; return;
case MixPose.current: case MixBlend.first:
bone.x += (bone.data.x - bone.x) * alpha; bone.x += (bone.data.x - bone.x) * alpha;
bone.y += (bone.data.y - bone.y) * alpha; bone.y += (bone.data.y - bone.y) * alpha;
} }
@ -278,13 +283,19 @@ var spine;
x += (frames[frame + TranslateTimeline.X] - x) * percent; x += (frames[frame + TranslateTimeline.X] - x) * percent;
y += (frames[frame + TranslateTimeline.Y] - y) * percent; y += (frames[frame + TranslateTimeline.Y] - y) * percent;
} }
if (pose == MixPose.setup) { switch (blend) {
bone.x = bone.data.x + x * alpha; case MixBlend.setup:
bone.y = bone.data.y + y * alpha; bone.x = bone.data.x + x * alpha;
} bone.y = bone.data.y + y * alpha;
else { break;
bone.x += (bone.data.x + x - bone.x) * alpha; case MixBlend.first:
bone.y += (bone.data.y + y - bone.y) * alpha; case MixBlend.replace:
bone.x += (bone.data.x + x - bone.x) * alpha;
bone.y += (bone.data.y + y - bone.y) * alpha;
break;
case MixBlend.add:
bone.x += x * alpha;
bone.y += y * alpha;
} }
}; };
return TranslateTimeline; return TranslateTimeline;
@ -304,16 +315,16 @@ var spine;
ScaleTimeline.prototype.getPropertyId = function () { ScaleTimeline.prototype.getPropertyId = function () {
return (TimelineType.scale << 24) + this.boneIndex; return (TimelineType.scale << 24) + this.boneIndex;
}; };
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.scaleX = bone.data.scaleX; bone.scaleX = bone.data.scaleX;
bone.scaleY = bone.data.scaleY; bone.scaleY = bone.data.scaleY;
return; return;
case MixPose.current: case MixBlend.first:
bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha; bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;
bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha; bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;
} }
@ -334,29 +345,61 @@ var spine;
y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY; y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY;
} }
if (alpha == 1) { if (alpha == 1) {
bone.scaleX = x; if (blend == MixBlend.add) {
bone.scaleY = y; bone.scaleX += x - bone.data.scaleX;
bone.scaleY += y - bone.data.scaleY;
}
else {
bone.scaleX = x;
bone.scaleY = y;
}
} }
else { else {
var bx = 0, by = 0; var bx = 0, by = 0;
if (pose == MixPose.setup) {
bx = bone.data.scaleX;
by = bone.data.scaleY;
}
else {
bx = bone.scaleX;
by = bone.scaleY;
}
if (direction == MixDirection.out) { if (direction == MixDirection.out) {
x = Math.abs(x) * spine.MathUtils.signum(bx); switch (blend) {
y = Math.abs(y) * spine.MathUtils.signum(by); case MixBlend.setup:
bx = bone.data.scaleX;
by = bone.data.scaleY;
bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bx) * alpha;
bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - by) * alpha;
break;
case MixBlend.first:
case MixBlend.replace:
bx = bone.scaleX;
by = bone.scaleY;
bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bx) * alpha;
bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - by) * alpha;
break;
case MixBlend.add:
bx = bone.scaleX;
by = bone.scaleY;
bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bone.data.scaleX) * alpha;
bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - bone.data.scaleY) * alpha;
}
} }
else { else {
bx = Math.abs(bx) * spine.MathUtils.signum(x); switch (blend) {
by = Math.abs(by) * spine.MathUtils.signum(y); case MixBlend.setup:
bx = Math.abs(bone.data.scaleX) * spine.MathUtils.signum(x);
by = Math.abs(bone.data.scaleY) * spine.MathUtils.signum(y);
bone.scaleX = bx + (x - bx) * alpha;
bone.scaleY = by + (y - by) * alpha;
break;
case MixBlend.first:
case MixBlend.replace:
bx = Math.abs(bone.scaleX) * spine.MathUtils.signum(x);
by = Math.abs(bone.scaleY) * spine.MathUtils.signum(y);
bone.scaleX = bx + (x - bx) * alpha;
bone.scaleY = by + (y - by) * alpha;
break;
case MixBlend.add:
bx = spine.MathUtils.signum(x);
by = spine.MathUtils.signum(y);
bone.scaleX = Math.abs(bone.scaleX) * bx + (x - Math.abs(bone.data.scaleX) * bx) * alpha;
bone.scaleY = Math.abs(bone.scaleY) * by + (y - Math.abs(bone.data.scaleY) * by) * alpha;
}
} }
bone.scaleX = bx + (x - bx) * alpha;
bone.scaleY = by + (y - by) * alpha;
} }
}; };
return ScaleTimeline; return ScaleTimeline;
@ -370,16 +413,16 @@ var spine;
ShearTimeline.prototype.getPropertyId = function () { ShearTimeline.prototype.getPropertyId = function () {
return (TimelineType.shear << 24) + this.boneIndex; return (TimelineType.shear << 24) + this.boneIndex;
}; };
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.shearX = bone.data.shearX; bone.shearX = bone.data.shearX;
bone.shearY = bone.data.shearY; bone.shearY = bone.data.shearY;
return; return;
case MixPose.current: case MixBlend.first:
bone.shearX += (bone.data.shearX - bone.shearX) * alpha; bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
bone.shearY += (bone.data.shearY - bone.shearY) * alpha; bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
} }
@ -399,13 +442,19 @@ var spine;
x = x + (frames[frame + ShearTimeline.X] - x) * percent; x = x + (frames[frame + ShearTimeline.X] - x) * percent;
y = y + (frames[frame + ShearTimeline.Y] - y) * percent; y = y + (frames[frame + ShearTimeline.Y] - y) * percent;
} }
if (pose == MixPose.setup) { switch (blend) {
bone.shearX = bone.data.shearX + x * alpha; case MixBlend.setup:
bone.shearY = bone.data.shearY + y * alpha; bone.shearX = bone.data.shearX + x * alpha;
} bone.shearY = bone.data.shearY + y * alpha;
else { break;
bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha; case MixBlend.first:
bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha; case MixBlend.replace:
bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha;
bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha;
break;
case MixBlend.add:
bone.shearX += x * alpha;
bone.shearY += y * alpha;
} }
}; };
return ShearTimeline; return ShearTimeline;
@ -429,15 +478,15 @@ var spine;
this.frames[frameIndex + ColorTimeline.B] = b; this.frames[frameIndex + ColorTimeline.B] = b;
this.frames[frameIndex + ColorTimeline.A] = a; this.frames[frameIndex + ColorTimeline.A] = a;
}; };
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
slot.color.setFromColor(slot.data.color); slot.color.setFromColor(slot.data.color);
return; return;
case MixPose.current: case MixBlend.first:
var color = slot.color, setup = slot.data.color; var color = slot.color, setup = slot.data.color;
color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha); color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha);
} }
@ -468,7 +517,7 @@ var spine;
slot.color.set(r, g, b, a); slot.color.set(r, g, b, a);
else { else {
var color = slot.color; var color = slot.color;
if (pose == MixPose.setup) if (blend == MixBlend.setup)
color.setFromColor(slot.data.color); color.setFromColor(slot.data.color);
color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha); color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
} }
@ -507,16 +556,16 @@ var spine;
this.frames[frameIndex + TwoColorTimeline.G2] = g2; this.frames[frameIndex + TwoColorTimeline.G2] = g2;
this.frames[frameIndex + TwoColorTimeline.B2] = b2; this.frames[frameIndex + TwoColorTimeline.B2] = b2;
}; };
TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
slot.color.setFromColor(slot.data.color); slot.color.setFromColor(slot.data.color);
slot.darkColor.setFromColor(slot.data.darkColor); slot.darkColor.setFromColor(slot.data.darkColor);
return; return;
case MixPose.current: case MixBlend.setup:
var light = slot.color, dark = slot.darkColor, setupLight = slot.data.color, setupDark = slot.data.darkColor; var light = slot.color, dark = slot.darkColor, setupLight = slot.data.color, setupDark = slot.data.darkColor;
light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha); light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha);
dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0); dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0);
@ -559,7 +608,7 @@ var spine;
} }
else { else {
var light = slot.color, dark = slot.darkColor; var light = slot.color, dark = slot.darkColor;
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
light.setFromColor(slot.data.color); light.setFromColor(slot.data.color);
dark.setFromColor(slot.data.darkColor); dark.setFromColor(slot.data.darkColor);
} }
@ -601,16 +650,16 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.attachmentNames[frameIndex] = attachmentName; this.attachmentNames[frameIndex] = attachmentName;
}; };
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
if (direction == MixDirection.out && pose == MixPose.setup) { if (direction == MixDirection.out && blend == MixBlend.setup) {
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 (pose == MixPose.setup) { if (blend == MixBlend.setup || blend == MixBlend.first) {
var attachmentName_2 = slot.data.attachmentName; var attachmentName_2 = slot.data.attachmentName;
slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2)); slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2));
} }
@ -646,24 +695,24 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.frameVertices[frameIndex] = vertices; this.frameVertices[frameIndex] = vertices;
}; };
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
var slotAttachment = slot.getAttachment(); var slotAttachment = slot.getAttachment();
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment)) if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
return; return;
var verticesArray = slot.attachmentVertices; var verticesArray = slot.attachmentVertices;
if (verticesArray.length == 0) if (verticesArray.length == 0)
alpha = 1; blend = MixBlend.setup;
var frameVertices = this.frameVertices; var frameVertices = this.frameVertices;
var vertexCount = frameVertices[0].length; var vertexCount = frameVertices[0].length;
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
var vertexAttachment = slotAttachment; var vertexAttachment = slotAttachment;
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
verticesArray.length = 0; verticesArray.length = 0;
return; return;
case MixPose.current: case MixBlend.first:
if (alpha == 1) { if (alpha == 1) {
verticesArray.length = 0; verticesArray.length = 0;
break; break;
@ -686,25 +735,57 @@ var spine;
if (time >= frames[frames.length - 1]) { if (time >= frames[frames.length - 1]) {
var lastVertices = frameVertices[frames.length - 1]; var lastVertices = frameVertices[frames.length - 1];
if (alpha == 1) { if (alpha == 1) {
spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount); if (blend == MixBlend.add) {
} var vertexAttachment = slotAttachment;
else if (pose == MixPose.setup) { if (vertexAttachment.bones == null) {
var vertexAttachment = slotAttachment; var setupVertices_1 = vertexAttachment.vertices;
if (vertexAttachment.bones == null) { for (var i_1 = 0; i_1 < vertexCount; i_1++) {
var setupVertices_1 = vertexAttachment.vertices; vertices[i_1] += lastVertices[i_1] - setupVertices_1[i_1];
for (var i_1 = 0; i_1 < vertexCount; i_1++) { }
var setup = setupVertices_1[i_1]; }
vertices[i_1] = setup + (lastVertices[i_1] - setup) * alpha; else {
for (var i_2 = 0; i_2 < vertexCount; i_2++)
vertices[i_2] += lastVertices[i_2];
} }
} }
else { else {
for (var i_2 = 0; i_2 < vertexCount; i_2++) spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount);
vertices[i_2] = lastVertices[i_2] * alpha;
} }
} }
else { else {
for (var i_3 = 0; i_3 < vertexCount; i_3++) switch (blend) {
vertices[i_3] += (lastVertices[i_3] - vertices[i_3]) * alpha; case MixBlend.setup: {
var vertexAttachment_1 = slotAttachment;
if (vertexAttachment_1.bones == null) {
var setupVertices_2 = vertexAttachment_1.vertices;
for (var i_3 = 0; i_3 < vertexCount; i_3++) {
var setup = setupVertices_2[i_3];
vertices[i_3] = setup + (lastVertices[i_3] - setup) * alpha;
}
}
else {
for (var i_4 = 0; i_4 < vertexCount; i_4++)
vertices[i_4] = lastVertices[i_4] * alpha;
}
break;
}
case MixBlend.first:
case MixBlend.replace:
for (var i_5 = 0; i_5 < vertexCount; i_5++)
vertices[i_5] += (lastVertices[i_5] - vertices[i_5]) * alpha;
case MixBlend.add:
var vertexAttachment = slotAttachment;
if (vertexAttachment.bones == null) {
var setupVertices_3 = vertexAttachment.vertices;
for (var i_6 = 0; i_6 < vertexCount; i_6++) {
vertices[i_6] += (lastVertices[i_6] - setupVertices_3[i_6]) * alpha;
}
}
else {
for (var i_7 = 0; i_7 < vertexCount; i_7++)
vertices[i_7] += lastVertices[i_7] * alpha;
}
}
} }
return; return;
} }
@ -714,31 +795,70 @@ var spine;
var frameTime = frames[frame]; var frameTime = frames[frame];
var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime)); var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime));
if (alpha == 1) { if (alpha == 1) {
for (var i_4 = 0; i_4 < vertexCount; i_4++) { if (blend == MixBlend.add) {
var prev = prevVertices[i_4]; var vertexAttachment = slotAttachment;
vertices[i_4] = prev + (nextVertices[i_4] - prev) * percent; if (vertexAttachment.bones == null) {
} var setupVertices_4 = vertexAttachment.vertices;
} for (var i_8 = 0; i_8 < vertexCount; i_8++) {
else if (pose == MixPose.setup) { var prev = prevVertices[i_8];
var vertexAttachment = slotAttachment; vertices[i_8] += prev + (nextVertices[i_8] - prev) * percent - setupVertices_4[i_8];
if (vertexAttachment.bones == null) { }
var setupVertices_2 = vertexAttachment.vertices; }
for (var i_5 = 0; i_5 < vertexCount; i_5++) { else {
var prev = prevVertices[i_5], setup = setupVertices_2[i_5]; for (var i_9 = 0; i_9 < vertexCount; i_9++) {
vertices[i_5] = setup + (prev + (nextVertices[i_5] - prev) * percent - setup) * alpha; var prev = prevVertices[i_9];
vertices[i_9] += prev + (nextVertices[i_9] - prev) * percent;
}
} }
} }
else { else {
for (var i_6 = 0; i_6 < vertexCount; i_6++) { for (var i_10 = 0; i_10 < vertexCount; i_10++) {
var prev = prevVertices[i_6]; var prev = prevVertices[i_10];
vertices[i_6] = (prev + (nextVertices[i_6] - prev) * percent) * alpha; vertices[i_10] = prev + (nextVertices[i_10] - prev) * percent;
} }
} }
} }
else { else {
for (var i_7 = 0; i_7 < vertexCount; i_7++) { switch (blend) {
var prev = prevVertices[i_7]; case MixBlend.setup: {
vertices[i_7] += (prev + (nextVertices[i_7] - prev) * percent - vertices[i_7]) * alpha; var vertexAttachment_2 = slotAttachment;
if (vertexAttachment_2.bones == null) {
var setupVertices_5 = vertexAttachment_2.vertices;
for (var i_11 = 0; i_11 < vertexCount; i_11++) {
var prev = prevVertices[i_11], setup = setupVertices_5[i_11];
vertices[i_11] = setup + (prev + (nextVertices[i_11] - prev) * percent - setup) * alpha;
}
}
else {
for (var i_12 = 0; i_12 < vertexCount; i_12++) {
var prev = prevVertices[i_12];
vertices[i_12] = (prev + (nextVertices[i_12] - prev) * percent) * alpha;
}
}
break;
}
case MixBlend.first:
case MixBlend.replace:
for (var i_13 = 0; i_13 < vertexCount; i_13++) {
var prev = prevVertices[i_13];
vertices[i_13] += (prev + (nextVertices[i_13] - prev) * percent - vertices[i_13]) * alpha;
}
break;
case MixBlend.add:
var vertexAttachment = slotAttachment;
if (vertexAttachment.bones == null) {
var setupVertices_6 = vertexAttachment.vertices;
for (var i_14 = 0; i_14 < vertexCount; i_14++) {
var prev = prevVertices[i_14];
vertices[i_14] += (prev + (nextVertices[i_14] - prev) * percent - setupVertices_6[i_14]) * alpha;
}
}
else {
for (var i_15 = 0; i_15 < vertexCount; i_15++) {
var prev = prevVertices[i_15];
vertices[i_15] += (prev + (nextVertices[i_15] - prev) * percent) * alpha;
}
}
} }
} }
}; };
@ -760,13 +880,13 @@ var spine;
this.frames[frameIndex] = event.time; this.frames[frameIndex] = event.time;
this.events[frameIndex] = event; this.events[frameIndex] = event;
}; };
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
if (firedEvents == null) if (firedEvents == null)
return; return;
var frames = this.frames; var frames = this.frames;
var frameCount = this.frames.length; var frameCount = this.frames.length;
if (lastTime > time) { if (lastTime > time) {
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, pose, direction); this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, blend, direction);
lastTime = -1; lastTime = -1;
} }
else if (lastTime >= frames[frameCount - 1]) else if (lastTime >= frames[frameCount - 1])
@ -806,16 +926,16 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.drawOrders[frameIndex] = drawOrder; this.drawOrders[frameIndex] = drawOrder;
}; };
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var drawOrder = skeleton.drawOrder; var drawOrder = skeleton.drawOrder;
var slots = skeleton.slots; var slots = skeleton.slots;
if (direction == MixDirection.out && pose == MixPose.setup) { if (direction == MixDirection.out && blend == MixBlend.setup) {
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
return; return;
} }
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
if (pose == MixPose.setup) if (blend == MixBlend.setup)
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
return; return;
} }
@ -851,23 +971,23 @@ var spine;
this.frames[frameIndex + IkConstraintTimeline.MIX] = mix; this.frames[frameIndex + IkConstraintTimeline.MIX] = mix;
this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection; this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection;
}; };
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.ikConstraints[this.ikConstraintIndex]; var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.mix = constraint.data.mix; constraint.mix = constraint.data.mix;
constraint.bendDirection = constraint.data.bendDirection; constraint.bendDirection = constraint.data.bendDirection;
return; return;
case MixPose.current: case MixBlend.first:
constraint.mix += (constraint.data.mix - constraint.mix) * alpha; constraint.mix += (constraint.data.mix - constraint.mix) * alpha;
constraint.bendDirection = constraint.data.bendDirection; constraint.bendDirection = constraint.data.bendDirection;
} }
return; return;
} }
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) { if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
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;
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection
: frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION]; : frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
@ -883,7 +1003,7 @@ var spine;
var mix = frames[frame + IkConstraintTimeline.PREV_MIX]; var mix = frames[frame + IkConstraintTimeline.PREV_MIX];
var frameTime = frames[frame]; var frameTime = frames[frame];
var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime));
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha; constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha;
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
} }
@ -920,19 +1040,19 @@ var spine;
this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix; this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix;
this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix; this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix;
}; };
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.transformConstraints[this.transformConstraintIndex]; var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
var data = constraint.data; var data = constraint.data;
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.rotateMix = data.rotateMix; constraint.rotateMix = data.rotateMix;
constraint.translateMix = data.translateMix; constraint.translateMix = data.translateMix;
constraint.scaleMix = data.scaleMix; constraint.scaleMix = data.scaleMix;
constraint.shearMix = data.shearMix; constraint.shearMix = data.shearMix;
return; return;
case MixPose.current: case MixBlend.setup:
constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha; constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha;
constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha; constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha;
constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha; constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha;
@ -961,7 +1081,7 @@ var spine;
scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent; scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent;
shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent; shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent;
} }
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
var data = constraint.data; var 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;
@ -1003,15 +1123,15 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value; this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value;
}; };
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.position = constraint.data.position; constraint.position = constraint.data.position;
return; return;
case MixPose.current: case MixBlend.first:
constraint.position += (constraint.data.position - constraint.position) * alpha; constraint.position += (constraint.data.position - constraint.position) * alpha;
} }
return; return;
@ -1026,7 +1146,7 @@ var spine;
var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime));
position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent; position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent;
} }
if (pose == MixPose.setup) if (blend == MixBlend.setup)
constraint.position = constraint.data.position + (position - constraint.data.position) * alpha; constraint.position = constraint.data.position + (position - constraint.data.position) * alpha;
else else
constraint.position += (position - constraint.position) * alpha; constraint.position += (position - constraint.position) * alpha;
@ -1046,15 +1166,15 @@ var spine;
PathConstraintSpacingTimeline.prototype.getPropertyId = function () { PathConstraintSpacingTimeline.prototype.getPropertyId = function () {
return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex; return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex;
}; };
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.spacing = constraint.data.spacing; constraint.spacing = constraint.data.spacing;
return; return;
case MixPose.current: case MixBlend.first:
constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha; constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha;
} }
return; return;
@ -1069,7 +1189,7 @@ var spine;
var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime));
spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent; spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent;
} }
if (pose == MixPose.setup) if (blend == MixBlend.setup)
constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha; constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;
else else
constraint.spacing += (spacing - constraint.spacing) * alpha; constraint.spacing += (spacing - constraint.spacing) * alpha;
@ -1093,16 +1213,16 @@ var spine;
this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix; this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix;
this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix; this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix;
}; };
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.rotateMix = constraint.data.rotateMix; constraint.rotateMix = constraint.data.rotateMix;
constraint.translateMix = constraint.data.translateMix; constraint.translateMix = constraint.data.translateMix;
return; return;
case MixPose.current: case MixBlend.first:
constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha; constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha;
constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha; constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha;
} }
@ -1122,7 +1242,7 @@ var spine;
rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent; rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent;
translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent; translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent;
} }
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha; constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha;
constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha; constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha;
} }
@ -1238,18 +1358,18 @@ var spine;
if (current == null || current.delay > 0) if (current == null || current.delay > 0)
continue; continue;
applied = true; applied = true;
var currentPose = i == 0 ? spine.MixPose.current : spine.MixPose.currentLayered; var blend = i == 0 ? spine.MixBlend.first : current.mixBlend;
var mix = current.alpha; var mix = current.alpha;
if (current.mixingFrom != null) if (current.mixingFrom != null)
mix *= this.applyMixingFrom(current, skeleton, currentPose); mix *= this.applyMixingFrom(current, skeleton, blend);
else if (current.trackTime >= current.trackEnd && current.next == null) else if (current.trackTime >= current.trackEnd && current.next == null)
mix = 0; mix = 0;
var animationLast = current.animationLast, animationTime = current.getAnimationTime(); var animationLast = current.animationLast, animationTime = current.getAnimationTime();
var timelineCount = current.animation.timelines.length; var timelineCount = current.animation.timelines.length;
var timelines = current.animation.timelines; var timelines = current.animation.timelines;
if (mix == 1) { if (mix == 1 || blend == spine.MixBlend.add) {
for (var ii = 0; ii < timelineCount; ii++) for (var ii = 0; ii < timelineCount; ii++)
timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, spine.MixPose.setup, spine.MixDirection["in"]); timelines[ii].apply(skeleton, animationLast, animationTime, events, mix, blend, spine.MixDirection["in"]);
} }
else { else {
var timelineData = current.timelineData; var timelineData = current.timelineData;
@ -1259,12 +1379,12 @@ var spine;
var timelinesRotation = current.timelinesRotation; var timelinesRotation = current.timelinesRotation;
for (var ii = 0; ii < timelineCount; ii++) { for (var ii = 0; ii < timelineCount; ii++) {
var timeline = timelines[ii]; var timeline = timelines[ii];
var pose = timelineData[ii] >= AnimationState.FIRST ? spine.MixPose.setup : currentPose; var timelineBlend = timelineData[ii] == AnimationState.SUBSEQUENT ? blend : spine.MixBlend.setup;
if (timeline instanceof spine.RotateTimeline) { if (timeline instanceof spine.RotateTimeline) {
this.applyRotateTimeline(timeline, skeleton, animationTime, mix, pose, timelinesRotation, ii << 1, firstFrame); this.applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineBlend, timelinesRotation, ii << 1, firstFrame);
} }
else else
timeline.apply(skeleton, animationLast, animationTime, events, mix, pose, spine.MixDirection["in"]); timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineBlend, spine.MixDirection["in"]);
} }
} }
this.queueEvents(current, animationTime); this.queueEvents(current, animationTime);
@ -1275,65 +1395,74 @@ var spine;
this.queue.drain(); this.queue.drain();
return applied; return applied;
}; };
AnimationState.prototype.applyMixingFrom = function (to, skeleton, currentPose) { AnimationState.prototype.applyMixingFrom = function (to, skeleton, blend) {
var from = to.mixingFrom; var from = to.mixingFrom;
if (from.mixingFrom != null) if (from.mixingFrom != null)
this.applyMixingFrom(from, skeleton, currentPose); this.applyMixingFrom(from, skeleton, blend);
var mix = 0; var mix = 0;
if (to.mixDuration == 0) { if (to.mixDuration == 0) {
mix = 1; mix = 1;
currentPose = spine.MixPose.setup; if (blend == spine.MixBlend.first)
blend = spine.MixBlend.setup;
} }
else { else {
mix = to.mixTime / to.mixDuration; mix = to.mixTime / to.mixDuration;
if (mix > 1) if (mix > 1)
mix = 1; mix = 1;
if (blend != spine.MixBlend.first)
blend = from.mixBlend;
} }
var events = mix < from.eventThreshold ? this.events : null; var events = mix < from.eventThreshold ? this.events : null;
var attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold; var attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold;
var animationLast = from.animationLast, animationTime = from.getAnimationTime(); var animationLast = from.animationLast, animationTime = from.getAnimationTime();
var timelineCount = from.animation.timelines.length; var timelineCount = from.animation.timelines.length;
var timelines = from.animation.timelines; var timelines = from.animation.timelines;
var timelineData = from.timelineData; var alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix);
var timelineDipMix = from.timelineDipMix; if (blend == spine.MixBlend.add) {
var firstFrame = from.timelinesRotation.length == 0; for (var i = 0; i < timelineCount; i++)
if (firstFrame) timelines[i].apply(skeleton, animationLast, animationTime, events, alphaMix, blend, spine.MixDirection.out);
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null); }
var timelinesRotation = from.timelinesRotation; else {
var pose; var timelineData = from.timelineData;
var alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix), alpha = 0; var timelineDipMix = from.timelineDipMix;
from.totalAlpha = 0; var firstFrame = from.timelinesRotation.length == 0;
for (var i = 0; i < timelineCount; i++) { if (firstFrame)
var timeline = timelines[i]; spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
switch (timelineData[i]) { var timelinesRotation = from.timelinesRotation;
case AnimationState.SUBSEQUENT: from.totalAlpha = 0;
if (!attachments && timeline instanceof spine.AttachmentTimeline) for (var i = 0; i < timelineCount; i++) {
continue; var timeline = timelines[i];
if (!drawOrder && timeline instanceof spine.DrawOrderTimeline) var timelineBlend;
continue; var alpha = 0;
pose = currentPose; switch (timelineData[i]) {
alpha = alphaMix; case AnimationState.SUBSEQUENT:
break; if (!attachments && timeline instanceof spine.AttachmentTimeline)
case AnimationState.FIRST: continue;
pose = spine.MixPose.setup; if (!drawOrder && timeline instanceof spine.DrawOrderTimeline)
alpha = alphaMix; continue;
break; timelineBlend = blend;
case AnimationState.DIP: alpha = alphaMix;
pose = spine.MixPose.setup; break;
alpha = alphaDip; case AnimationState.FIRST:
break; timelineBlend = spine.MixBlend.setup;
default: alpha = alphaMix;
pose = spine.MixPose.setup; break;
alpha = alphaDip; case AnimationState.DIP:
var dipMix = timelineDipMix[i]; timelineBlend = spine.MixBlend.setup;
alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration); alpha = alphaDip;
break; break;
} default:
from.totalAlpha += alpha; timelineBlend = spine.MixBlend.setup;
if (timeline instanceof spine.RotateTimeline) var dipMix = timelineDipMix[i];
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame); alpha = alphaDip * Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
else { break;
timeline.apply(skeleton, animationLast, animationTime, events, alpha, pose, spine.MixDirection.out); }
from.totalAlpha += alpha;
if (timeline instanceof spine.RotateTimeline)
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, timelineBlend, timelinesRotation, i << 1, firstFrame);
else {
timeline.apply(skeleton, animationLast, animationTime, events, alpha, timelineBlend, spine.MixDirection.out);
}
} }
} }
if (to.mixDuration > 0) if (to.mixDuration > 0)
@ -1343,18 +1472,18 @@ var spine;
from.nextTrackLast = from.trackTime; from.nextTrackLast = from.trackTime;
return mix; return mix;
}; };
AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, pose, timelinesRotation, i, firstFrame) { AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, blend, timelinesRotation, i, firstFrame) {
if (firstFrame) if (firstFrame)
timelinesRotation[i] = 0; timelinesRotation[i] = 0;
if (alpha == 1) { if (alpha == 1) {
timeline.apply(skeleton, 0, time, null, 1, pose, spine.MixDirection["in"]); timeline.apply(skeleton, 0, time, null, 1, blend, spine.MixDirection["in"]);
return; return;
} }
var rotateTimeline = timeline; var rotateTimeline = timeline;
var frames = rotateTimeline.frames; var frames = rotateTimeline.frames;
var bone = skeleton.bones[rotateTimeline.boneIndex]; var bone = skeleton.bones[rotateTimeline.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
if (pose == spine.MixPose.setup) if (blend == spine.MixBlend.setup)
bone.rotation = bone.data.rotation; bone.rotation = bone.data.rotation;
return; return;
} }
@ -1371,7 +1500,7 @@ var spine;
r2 = prevRotation + r2 * percent + bone.data.rotation; r2 = prevRotation + r2 * percent + bone.data.rotation;
r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360; r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
} }
var r1 = pose == spine.MixPose.setup ? bone.data.rotation : bone.rotation; var r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation;
var total = 0, diff = r2 - r1; var total = 0, diff = r2 - r1;
if (diff == 0) { if (diff == 0) {
total = timelinesRotation[i]; total = timelinesRotation[i];
@ -1601,7 +1730,7 @@ var spine;
var mixingTo = this.mixingTo; var mixingTo = this.mixingTo;
for (var i = 0, n = this.tracks.length; i < n; i++) { for (var i = 0, n = this.tracks.length; i < n; i++) {
var entry = this.tracks[i]; var entry = this.tracks[i];
if (entry != null) if (entry != null && (i == 0 || entry.mixBlend != spine.MixBlend.add))
entry.setTimelineData(null, mixingTo, propertyIDs); entry.setTimelineData(null, mixingTo, propertyIDs);
} }
}; };
@ -1636,6 +1765,7 @@ var spine;
spine.AnimationState = AnimationState; spine.AnimationState = AnimationState;
var TrackEntry = (function () { var TrackEntry = (function () {
function TrackEntry() { function TrackEntry() {
this.mixBlend = spine.MixBlend.replace;
this.timelineData = new Array(); this.timelineData = new Array();
this.timelineDipMix = new Array(); this.timelineDipMix = new Array();
this.timelinesRotation = new Array(); this.timelinesRotation = new Array();
@ -6800,8 +6930,8 @@ var spine;
break; break;
} }
var listeners = _this.listeners; var listeners = _this.listeners;
for (var i_8 = 0; i_8 < listeners.length; i_8++) { for (var i_16 = 0; i_16 < listeners.length; i_16++) {
listeners[i_8].down(_this.currTouch.x, _this.currTouch.y); listeners[i_16].down(_this.currTouch.x, _this.currTouch.y);
} }
console.log("Start " + _this.currTouch.x + ", " + _this.currTouch.y); console.log("Start " + _this.currTouch.x + ", " + _this.currTouch.y);
_this.lastX = _this.currTouch.x; _this.lastX = _this.currTouch.x;
@ -6819,8 +6949,8 @@ var spine;
var y = _this.currTouch.y = touch.clientY - rect.top; var y = _this.currTouch.y = touch.clientY - rect.top;
_this.touchesPool.free(_this.currTouch); _this.touchesPool.free(_this.currTouch);
var listeners = _this.listeners; var listeners = _this.listeners;
for (var i_9 = 0; i_9 < listeners.length; i_9++) { for (var i_17 = 0; i_17 < listeners.length; i_17++) {
listeners[i_9].up(x, y); listeners[i_17].up(x, y);
} }
console.log("End " + x + ", " + y); console.log("End " + x + ", " + y);
_this.lastX = x; _this.lastX = x;
@ -6842,8 +6972,8 @@ var spine;
var y = _this.currTouch.y = touch.clientY - rect.top; var y = _this.currTouch.y = touch.clientY - rect.top;
_this.touchesPool.free(_this.currTouch); _this.touchesPool.free(_this.currTouch);
var listeners = _this.listeners; var listeners = _this.listeners;
for (var i_10 = 0; i_10 < listeners.length; i_10++) { for (var i_18 = 0; i_18 < listeners.length; i_18++) {
listeners[i_10].up(x, y); listeners[i_18].up(x, y);
} }
console.log("End " + x + ", " + y); console.log("End " + x + ", " + y);
_this.lastX = x; _this.lastX = x;
@ -6866,8 +6996,8 @@ var spine;
var x = touch.clientX - rect.left; var x = touch.clientX - rect.left;
var y = touch.clientY - rect.top; var y = touch.clientY - rect.top;
var listeners = _this.listeners; var listeners = _this.listeners;
for (var i_11 = 0; i_11 < listeners.length; i_11++) { for (var i_19 = 0; i_19 < listeners.length; i_19++) {
listeners[i_11].dragged(x, y); listeners[i_19].dragged(x, y);
} }
console.log("Drag " + x + ", " + y); console.log("Drag " + x + ", " + y);
_this.lastX = _this.currTouch.x = x; _this.lastX = _this.currTouch.x = x;
@ -8715,11 +8845,11 @@ var spine;
var nn = clip.worldVerticesLength; var nn = clip.worldVerticesLength;
var world = this.temp = spine.Utils.setArraySize(this.temp, nn, 0); var world = this.temp = spine.Utils.setArraySize(this.temp, nn, 0);
clip.computeWorldVertices(slot, 0, nn, world, 0, 2); clip.computeWorldVertices(slot, 0, nn, world, 0, 2);
for (var i_12 = 0, n_2 = world.length; i_12 < n_2; i_12 += 2) { for (var i_20 = 0, n_2 = world.length; i_20 < n_2; i_20 += 2) {
var x = world[i_12]; var x = world[i_20];
var y = world[i_12 + 1]; var y = world[i_20 + 1];
var x2 = world[(i_12 + 2) % world.length]; var x2 = world[(i_20 + 2) % world.length];
var y2 = world[(i_12 + 3) % world.length]; var y2 = world[(i_20 + 3) % world.length];
shapes.line(x, y, x2, y2); shapes.line(x, y, x2, y2);
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -20,7 +20,7 @@ var spine;
this.timelines = timelines; this.timelines = timelines;
this.duration = duration; this.duration = duration;
} }
Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, pose, direction) { Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, blend, direction) {
if (skeleton == null) if (skeleton == null)
throw new Error("skeleton cannot be null."); throw new Error("skeleton cannot be null.");
if (loop && this.duration != 0) { if (loop && this.duration != 0) {
@ -30,7 +30,7 @@ var spine;
} }
var timelines = this.timelines; var timelines = this.timelines;
for (var i = 0, n = timelines.length; i < n; i++) for (var i = 0, n = timelines.length; i < n; i++)
timelines[i].apply(skeleton, lastTime, time, events, alpha, pose, direction); timelines[i].apply(skeleton, lastTime, time, events, alpha, blend, direction);
}; };
Animation.binarySearch = function (values, target, step) { Animation.binarySearch = function (values, target, step) {
if (step === void 0) { step = 1; } if (step === void 0) { step = 1; }
@ -58,12 +58,13 @@ var spine;
return Animation; return Animation;
}()); }());
spine.Animation = Animation; spine.Animation = Animation;
var MixPose; var MixBlend;
(function (MixPose) { (function (MixBlend) {
MixPose[MixPose["setup"] = 0] = "setup"; MixBlend[MixBlend["setup"] = 0] = "setup";
MixPose[MixPose["current"] = 1] = "current"; MixBlend[MixBlend["first"] = 1] = "first";
MixPose[MixPose["currentLayered"] = 2] = "currentLayered"; MixBlend[MixBlend["replace"] = 2] = "replace";
})(MixPose = spine.MixPose || (spine.MixPose = {})); MixBlend[MixBlend["add"] = 3] = "add";
})(MixBlend = spine.MixBlend || (spine.MixBlend = {}));
var MixDirection; var MixDirection;
(function (MixDirection) { (function (MixDirection) {
MixDirection[MixDirection["in"] = 0] = "in"; MixDirection[MixDirection["in"] = 0] = "in";
@ -184,28 +185,32 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.frames[frameIndex + RotateTimeline.ROTATION] = degrees; this.frames[frameIndex + RotateTimeline.ROTATION] = degrees;
}; };
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.rotation = bone.data.rotation; bone.rotation = bone.data.rotation;
return; return;
case MixPose.current: case MixBlend.first:
var r_1 = bone.data.rotation - bone.rotation; var r_1 = bone.data.rotation - bone.rotation;
r_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360; bone.rotation += (r_1 - (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360) * alpha;
bone.rotation += r_1 * alpha;
} }
return; return;
} }
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) { if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
if (pose == MixPose.setup) var r = frames[frames.length + RotateTimeline.PREV_ROTATION];
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha; switch (blend) {
else { case MixBlend.setup:
var r_2 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation; bone.rotation = bone.data.rotation + r * alpha;
r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360; break;
bone.rotation += r_2 * alpha; case MixBlend.first:
case MixBlend.replace:
r += bone.data.rotation - bone.rotation;
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
case MixBlend.add:
bone.rotation += r * alpha;
} }
return; return;
} }
@ -213,17 +218,17 @@ var spine;
var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION]; var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION];
var frameTime = frames[frame]; var frameTime = frames[frame];
var percent = this.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime));
var r = frames[frame + RotateTimeline.ROTATION] - prevRotation; r = frames[frame + RotateTimeline.ROTATION] - prevRotation;
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; r = prevRotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * percent;
r = prevRotation + r * percent; switch (blend) {
if (pose == MixPose.setup) { case MixBlend.setup:
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; bone.rotation = bone.data.rotation + (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha;
bone.rotation = bone.data.rotation + r * alpha; break;
} case MixBlend.first:
else { case MixBlend.replace:
r = bone.data.rotation + r - bone.rotation; r += bone.data.rotation - bone.rotation;
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; case MixBlend.add:
bone.rotation += r * alpha; bone.rotation += (r - (16384 - ((16384.499999999996 - r / 360) | 0)) * 360) * alpha;
} }
}; };
return RotateTimeline; return RotateTimeline;
@ -249,16 +254,16 @@ var spine;
this.frames[frameIndex + TranslateTimeline.X] = x; this.frames[frameIndex + TranslateTimeline.X] = x;
this.frames[frameIndex + TranslateTimeline.Y] = y; this.frames[frameIndex + TranslateTimeline.Y] = y;
}; };
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.x = bone.data.x; bone.x = bone.data.x;
bone.y = bone.data.y; bone.y = bone.data.y;
return; return;
case MixPose.current: case MixBlend.first:
bone.x += (bone.data.x - bone.x) * alpha; bone.x += (bone.data.x - bone.x) * alpha;
bone.y += (bone.data.y - bone.y) * alpha; bone.y += (bone.data.y - bone.y) * alpha;
} }
@ -278,13 +283,19 @@ var spine;
x += (frames[frame + TranslateTimeline.X] - x) * percent; x += (frames[frame + TranslateTimeline.X] - x) * percent;
y += (frames[frame + TranslateTimeline.Y] - y) * percent; y += (frames[frame + TranslateTimeline.Y] - y) * percent;
} }
if (pose == MixPose.setup) { switch (blend) {
bone.x = bone.data.x + x * alpha; case MixBlend.setup:
bone.y = bone.data.y + y * alpha; bone.x = bone.data.x + x * alpha;
} bone.y = bone.data.y + y * alpha;
else { break;
bone.x += (bone.data.x + x - bone.x) * alpha; case MixBlend.first:
bone.y += (bone.data.y + y - bone.y) * alpha; case MixBlend.replace:
bone.x += (bone.data.x + x - bone.x) * alpha;
bone.y += (bone.data.y + y - bone.y) * alpha;
break;
case MixBlend.add:
bone.x += x * alpha;
bone.y += y * alpha;
} }
}; };
return TranslateTimeline; return TranslateTimeline;
@ -304,16 +315,16 @@ var spine;
ScaleTimeline.prototype.getPropertyId = function () { ScaleTimeline.prototype.getPropertyId = function () {
return (TimelineType.scale << 24) + this.boneIndex; return (TimelineType.scale << 24) + this.boneIndex;
}; };
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.scaleX = bone.data.scaleX; bone.scaleX = bone.data.scaleX;
bone.scaleY = bone.data.scaleY; bone.scaleY = bone.data.scaleY;
return; return;
case MixPose.current: case MixBlend.first:
bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha; bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;
bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha; bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;
} }
@ -334,29 +345,61 @@ var spine;
y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY; y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY;
} }
if (alpha == 1) { if (alpha == 1) {
bone.scaleX = x; if (blend == MixBlend.add) {
bone.scaleY = y; bone.scaleX += x - bone.data.scaleX;
bone.scaleY += y - bone.data.scaleY;
}
else {
bone.scaleX = x;
bone.scaleY = y;
}
} }
else { else {
var bx = 0, by = 0; var bx = 0, by = 0;
if (pose == MixPose.setup) {
bx = bone.data.scaleX;
by = bone.data.scaleY;
}
else {
bx = bone.scaleX;
by = bone.scaleY;
}
if (direction == MixDirection.out) { if (direction == MixDirection.out) {
x = Math.abs(x) * spine.MathUtils.signum(bx); switch (blend) {
y = Math.abs(y) * spine.MathUtils.signum(by); case MixBlend.setup:
bx = bone.data.scaleX;
by = bone.data.scaleY;
bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bx) * alpha;
bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - by) * alpha;
break;
case MixBlend.first:
case MixBlend.replace:
bx = bone.scaleX;
by = bone.scaleY;
bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bx) * alpha;
bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - by) * alpha;
break;
case MixBlend.add:
bx = bone.scaleX;
by = bone.scaleY;
bone.scaleX = bx + (Math.abs(x) * spine.MathUtils.signum(bx) - bone.data.scaleX) * alpha;
bone.scaleY = by + (Math.abs(y) * spine.MathUtils.signum(by) - bone.data.scaleY) * alpha;
}
} }
else { else {
bx = Math.abs(bx) * spine.MathUtils.signum(x); switch (blend) {
by = Math.abs(by) * spine.MathUtils.signum(y); case MixBlend.setup:
bx = Math.abs(bone.data.scaleX) * spine.MathUtils.signum(x);
by = Math.abs(bone.data.scaleY) * spine.MathUtils.signum(y);
bone.scaleX = bx + (x - bx) * alpha;
bone.scaleY = by + (y - by) * alpha;
break;
case MixBlend.first:
case MixBlend.replace:
bx = Math.abs(bone.scaleX) * spine.MathUtils.signum(x);
by = Math.abs(bone.scaleY) * spine.MathUtils.signum(y);
bone.scaleX = bx + (x - bx) * alpha;
bone.scaleY = by + (y - by) * alpha;
break;
case MixBlend.add:
bx = spine.MathUtils.signum(x);
by = spine.MathUtils.signum(y);
bone.scaleX = Math.abs(bone.scaleX) * bx + (x - Math.abs(bone.data.scaleX) * bx) * alpha;
bone.scaleY = Math.abs(bone.scaleY) * by + (y - Math.abs(bone.data.scaleY) * by) * alpha;
}
} }
bone.scaleX = bx + (x - bx) * alpha;
bone.scaleY = by + (y - by) * alpha;
} }
}; };
return ScaleTimeline; return ScaleTimeline;
@ -370,16 +413,16 @@ var spine;
ShearTimeline.prototype.getPropertyId = function () { ShearTimeline.prototype.getPropertyId = function () {
return (TimelineType.shear << 24) + this.boneIndex; return (TimelineType.shear << 24) + this.boneIndex;
}; };
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var bone = skeleton.bones[this.boneIndex]; var bone = skeleton.bones[this.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
bone.shearX = bone.data.shearX; bone.shearX = bone.data.shearX;
bone.shearY = bone.data.shearY; bone.shearY = bone.data.shearY;
return; return;
case MixPose.current: case MixBlend.first:
bone.shearX += (bone.data.shearX - bone.shearX) * alpha; bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
bone.shearY += (bone.data.shearY - bone.shearY) * alpha; bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
} }
@ -399,13 +442,19 @@ var spine;
x = x + (frames[frame + ShearTimeline.X] - x) * percent; x = x + (frames[frame + ShearTimeline.X] - x) * percent;
y = y + (frames[frame + ShearTimeline.Y] - y) * percent; y = y + (frames[frame + ShearTimeline.Y] - y) * percent;
} }
if (pose == MixPose.setup) { switch (blend) {
bone.shearX = bone.data.shearX + x * alpha; case MixBlend.setup:
bone.shearY = bone.data.shearY + y * alpha; bone.shearX = bone.data.shearX + x * alpha;
} bone.shearY = bone.data.shearY + y * alpha;
else { break;
bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha; case MixBlend.first:
bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha; case MixBlend.replace:
bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha;
bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha;
break;
case MixBlend.add:
bone.shearX += x * alpha;
bone.shearY += y * alpha;
} }
}; };
return ShearTimeline; return ShearTimeline;
@ -429,15 +478,15 @@ var spine;
this.frames[frameIndex + ColorTimeline.B] = b; this.frames[frameIndex + ColorTimeline.B] = b;
this.frames[frameIndex + ColorTimeline.A] = a; this.frames[frameIndex + ColorTimeline.A] = a;
}; };
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
slot.color.setFromColor(slot.data.color); slot.color.setFromColor(slot.data.color);
return; return;
case MixPose.current: case MixBlend.first:
var color = slot.color, setup = slot.data.color; var color = slot.color, setup = slot.data.color;
color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha); color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha);
} }
@ -468,7 +517,7 @@ var spine;
slot.color.set(r, g, b, a); slot.color.set(r, g, b, a);
else { else {
var color = slot.color; var color = slot.color;
if (pose == MixPose.setup) if (blend == MixBlend.setup)
color.setFromColor(slot.data.color); color.setFromColor(slot.data.color);
color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha); color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
} }
@ -507,16 +556,16 @@ var spine;
this.frames[frameIndex + TwoColorTimeline.G2] = g2; this.frames[frameIndex + TwoColorTimeline.G2] = g2;
this.frames[frameIndex + TwoColorTimeline.B2] = b2; this.frames[frameIndex + TwoColorTimeline.B2] = b2;
}; };
TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
slot.color.setFromColor(slot.data.color); slot.color.setFromColor(slot.data.color);
slot.darkColor.setFromColor(slot.data.darkColor); slot.darkColor.setFromColor(slot.data.darkColor);
return; return;
case MixPose.current: case MixBlend.setup:
var light = slot.color, dark = slot.darkColor, setupLight = slot.data.color, setupDark = slot.data.darkColor; var light = slot.color, dark = slot.darkColor, setupLight = slot.data.color, setupDark = slot.data.darkColor;
light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha); light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha);
dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0); dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0);
@ -559,7 +608,7 @@ var spine;
} }
else { else {
var light = slot.color, dark = slot.darkColor; var light = slot.color, dark = slot.darkColor;
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
light.setFromColor(slot.data.color); light.setFromColor(slot.data.color);
dark.setFromColor(slot.data.darkColor); dark.setFromColor(slot.data.darkColor);
} }
@ -601,16 +650,16 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.attachmentNames[frameIndex] = attachmentName; this.attachmentNames[frameIndex] = attachmentName;
}; };
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
if (direction == MixDirection.out && pose == MixPose.setup) { if (direction == MixDirection.out && blend == MixBlend.setup) {
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 (pose == MixPose.setup) { if (blend == MixBlend.setup || blend == MixBlend.first) {
var attachmentName_2 = slot.data.attachmentName; var attachmentName_2 = slot.data.attachmentName;
slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2)); slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2));
} }
@ -646,24 +695,24 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.frameVertices[frameIndex] = vertices; this.frameVertices[frameIndex] = vertices;
}; };
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
var slotAttachment = slot.getAttachment(); var slotAttachment = slot.getAttachment();
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment)) if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
return; return;
var verticesArray = slot.attachmentVertices; var verticesArray = slot.attachmentVertices;
if (verticesArray.length == 0) if (verticesArray.length == 0)
alpha = 1; blend = MixBlend.setup;
var frameVertices = this.frameVertices; var frameVertices = this.frameVertices;
var vertexCount = frameVertices[0].length; var vertexCount = frameVertices[0].length;
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
var vertexAttachment = slotAttachment; var vertexAttachment = slotAttachment;
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
verticesArray.length = 0; verticesArray.length = 0;
return; return;
case MixPose.current: case MixBlend.first:
if (alpha == 1) { if (alpha == 1) {
verticesArray.length = 0; verticesArray.length = 0;
break; break;
@ -686,25 +735,57 @@ var spine;
if (time >= frames[frames.length - 1]) { if (time >= frames[frames.length - 1]) {
var lastVertices = frameVertices[frames.length - 1]; var lastVertices = frameVertices[frames.length - 1];
if (alpha == 1) { if (alpha == 1) {
spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount); if (blend == MixBlend.add) {
} var vertexAttachment = slotAttachment;
else if (pose == MixPose.setup) { if (vertexAttachment.bones == null) {
var vertexAttachment = slotAttachment; var setupVertices_1 = vertexAttachment.vertices;
if (vertexAttachment.bones == null) { for (var i_1 = 0; i_1 < vertexCount; i_1++) {
var setupVertices_1 = vertexAttachment.vertices; vertices[i_1] += lastVertices[i_1] - setupVertices_1[i_1];
for (var i_1 = 0; i_1 < vertexCount; i_1++) { }
var setup = setupVertices_1[i_1]; }
vertices[i_1] = setup + (lastVertices[i_1] - setup) * alpha; else {
for (var i_2 = 0; i_2 < vertexCount; i_2++)
vertices[i_2] += lastVertices[i_2];
} }
} }
else { else {
for (var i_2 = 0; i_2 < vertexCount; i_2++) spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount);
vertices[i_2] = lastVertices[i_2] * alpha;
} }
} }
else { else {
for (var i_3 = 0; i_3 < vertexCount; i_3++) switch (blend) {
vertices[i_3] += (lastVertices[i_3] - vertices[i_3]) * alpha; case MixBlend.setup: {
var vertexAttachment_1 = slotAttachment;
if (vertexAttachment_1.bones == null) {
var setupVertices_2 = vertexAttachment_1.vertices;
for (var i_3 = 0; i_3 < vertexCount; i_3++) {
var setup = setupVertices_2[i_3];
vertices[i_3] = setup + (lastVertices[i_3] - setup) * alpha;
}
}
else {
for (var i_4 = 0; i_4 < vertexCount; i_4++)
vertices[i_4] = lastVertices[i_4] * alpha;
}
break;
}
case MixBlend.first:
case MixBlend.replace:
for (var i_5 = 0; i_5 < vertexCount; i_5++)
vertices[i_5] += (lastVertices[i_5] - vertices[i_5]) * alpha;
case MixBlend.add:
var vertexAttachment = slotAttachment;
if (vertexAttachment.bones == null) {
var setupVertices_3 = vertexAttachment.vertices;
for (var i_6 = 0; i_6 < vertexCount; i_6++) {
vertices[i_6] += (lastVertices[i_6] - setupVertices_3[i_6]) * alpha;
}
}
else {
for (var i_7 = 0; i_7 < vertexCount; i_7++)
vertices[i_7] += lastVertices[i_7] * alpha;
}
}
} }
return; return;
} }
@ -714,31 +795,70 @@ var spine;
var frameTime = frames[frame]; var frameTime = frames[frame];
var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime)); var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime));
if (alpha == 1) { if (alpha == 1) {
for (var i_4 = 0; i_4 < vertexCount; i_4++) { if (blend == MixBlend.add) {
var prev = prevVertices[i_4]; var vertexAttachment = slotAttachment;
vertices[i_4] = prev + (nextVertices[i_4] - prev) * percent; if (vertexAttachment.bones == null) {
} var setupVertices_4 = vertexAttachment.vertices;
} for (var i_8 = 0; i_8 < vertexCount; i_8++) {
else if (pose == MixPose.setup) { var prev = prevVertices[i_8];
var vertexAttachment = slotAttachment; vertices[i_8] += prev + (nextVertices[i_8] - prev) * percent - setupVertices_4[i_8];
if (vertexAttachment.bones == null) { }
var setupVertices_2 = vertexAttachment.vertices; }
for (var i_5 = 0; i_5 < vertexCount; i_5++) { else {
var prev = prevVertices[i_5], setup = setupVertices_2[i_5]; for (var i_9 = 0; i_9 < vertexCount; i_9++) {
vertices[i_5] = setup + (prev + (nextVertices[i_5] - prev) * percent - setup) * alpha; var prev = prevVertices[i_9];
vertices[i_9] += prev + (nextVertices[i_9] - prev) * percent;
}
} }
} }
else { else {
for (var i_6 = 0; i_6 < vertexCount; i_6++) { for (var i_10 = 0; i_10 < vertexCount; i_10++) {
var prev = prevVertices[i_6]; var prev = prevVertices[i_10];
vertices[i_6] = (prev + (nextVertices[i_6] - prev) * percent) * alpha; vertices[i_10] = prev + (nextVertices[i_10] - prev) * percent;
} }
} }
} }
else { else {
for (var i_7 = 0; i_7 < vertexCount; i_7++) { switch (blend) {
var prev = prevVertices[i_7]; case MixBlend.setup: {
vertices[i_7] += (prev + (nextVertices[i_7] - prev) * percent - vertices[i_7]) * alpha; var vertexAttachment_2 = slotAttachment;
if (vertexAttachment_2.bones == null) {
var setupVertices_5 = vertexAttachment_2.vertices;
for (var i_11 = 0; i_11 < vertexCount; i_11++) {
var prev = prevVertices[i_11], setup = setupVertices_5[i_11];
vertices[i_11] = setup + (prev + (nextVertices[i_11] - prev) * percent - setup) * alpha;
}
}
else {
for (var i_12 = 0; i_12 < vertexCount; i_12++) {
var prev = prevVertices[i_12];
vertices[i_12] = (prev + (nextVertices[i_12] - prev) * percent) * alpha;
}
}
break;
}
case MixBlend.first:
case MixBlend.replace:
for (var i_13 = 0; i_13 < vertexCount; i_13++) {
var prev = prevVertices[i_13];
vertices[i_13] += (prev + (nextVertices[i_13] - prev) * percent - vertices[i_13]) * alpha;
}
break;
case MixBlend.add:
var vertexAttachment = slotAttachment;
if (vertexAttachment.bones == null) {
var setupVertices_6 = vertexAttachment.vertices;
for (var i_14 = 0; i_14 < vertexCount; i_14++) {
var prev = prevVertices[i_14];
vertices[i_14] += (prev + (nextVertices[i_14] - prev) * percent - setupVertices_6[i_14]) * alpha;
}
}
else {
for (var i_15 = 0; i_15 < vertexCount; i_15++) {
var prev = prevVertices[i_15];
vertices[i_15] += (prev + (nextVertices[i_15] - prev) * percent) * alpha;
}
}
} }
} }
}; };
@ -760,13 +880,13 @@ var spine;
this.frames[frameIndex] = event.time; this.frames[frameIndex] = event.time;
this.events[frameIndex] = event; this.events[frameIndex] = event;
}; };
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
if (firedEvents == null) if (firedEvents == null)
return; return;
var frames = this.frames; var frames = this.frames;
var frameCount = this.frames.length; var frameCount = this.frames.length;
if (lastTime > time) { if (lastTime > time) {
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, pose, direction); this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, blend, direction);
lastTime = -1; lastTime = -1;
} }
else if (lastTime >= frames[frameCount - 1]) else if (lastTime >= frames[frameCount - 1])
@ -806,16 +926,16 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.drawOrders[frameIndex] = drawOrder; this.drawOrders[frameIndex] = drawOrder;
}; };
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var drawOrder = skeleton.drawOrder; var drawOrder = skeleton.drawOrder;
var slots = skeleton.slots; var slots = skeleton.slots;
if (direction == MixDirection.out && pose == MixPose.setup) { if (direction == MixDirection.out && blend == MixBlend.setup) {
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
return; return;
} }
var frames = this.frames; var frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
if (pose == MixPose.setup) if (blend == MixBlend.setup)
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
return; return;
} }
@ -851,23 +971,23 @@ var spine;
this.frames[frameIndex + IkConstraintTimeline.MIX] = mix; this.frames[frameIndex + IkConstraintTimeline.MIX] = mix;
this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection; this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection;
}; };
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.ikConstraints[this.ikConstraintIndex]; var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.mix = constraint.data.mix; constraint.mix = constraint.data.mix;
constraint.bendDirection = constraint.data.bendDirection; constraint.bendDirection = constraint.data.bendDirection;
return; return;
case MixPose.current: case MixBlend.first:
constraint.mix += (constraint.data.mix - constraint.mix) * alpha; constraint.mix += (constraint.data.mix - constraint.mix) * alpha;
constraint.bendDirection = constraint.data.bendDirection; constraint.bendDirection = constraint.data.bendDirection;
} }
return; return;
} }
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) { if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
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;
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection
: frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION]; : frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
@ -883,7 +1003,7 @@ var spine;
var mix = frames[frame + IkConstraintTimeline.PREV_MIX]; var mix = frames[frame + IkConstraintTimeline.PREV_MIX];
var frameTime = frames[frame]; var frameTime = frames[frame];
var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime));
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha; constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha;
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
} }
@ -920,19 +1040,19 @@ var spine;
this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix; this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix;
this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix; this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix;
}; };
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.transformConstraints[this.transformConstraintIndex]; var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
var data = constraint.data; var data = constraint.data;
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.rotateMix = data.rotateMix; constraint.rotateMix = data.rotateMix;
constraint.translateMix = data.translateMix; constraint.translateMix = data.translateMix;
constraint.scaleMix = data.scaleMix; constraint.scaleMix = data.scaleMix;
constraint.shearMix = data.shearMix; constraint.shearMix = data.shearMix;
return; return;
case MixPose.current: case MixBlend.setup:
constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha; constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha;
constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha; constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha;
constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha; constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha;
@ -961,7 +1081,7 @@ var spine;
scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent; scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent;
shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent; shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent;
} }
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
var data = constraint.data; var 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;
@ -1003,15 +1123,15 @@ var spine;
this.frames[frameIndex] = time; this.frames[frameIndex] = time;
this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value; this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value;
}; };
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.position = constraint.data.position; constraint.position = constraint.data.position;
return; return;
case MixPose.current: case MixBlend.first:
constraint.position += (constraint.data.position - constraint.position) * alpha; constraint.position += (constraint.data.position - constraint.position) * alpha;
} }
return; return;
@ -1026,7 +1146,7 @@ var spine;
var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime));
position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent; position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent;
} }
if (pose == MixPose.setup) if (blend == MixBlend.setup)
constraint.position = constraint.data.position + (position - constraint.data.position) * alpha; constraint.position = constraint.data.position + (position - constraint.data.position) * alpha;
else else
constraint.position += (position - constraint.position) * alpha; constraint.position += (position - constraint.position) * alpha;
@ -1046,15 +1166,15 @@ var spine;
PathConstraintSpacingTimeline.prototype.getPropertyId = function () { PathConstraintSpacingTimeline.prototype.getPropertyId = function () {
return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex; return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex;
}; };
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.spacing = constraint.data.spacing; constraint.spacing = constraint.data.spacing;
return; return;
case MixPose.current: case MixBlend.first:
constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha; constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha;
} }
return; return;
@ -1069,7 +1189,7 @@ var spine;
var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime)); var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime));
spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent; spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent;
} }
if (pose == MixPose.setup) if (blend == MixBlend.setup)
constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha; constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;
else else
constraint.spacing += (spacing - constraint.spacing) * alpha; constraint.spacing += (spacing - constraint.spacing) * alpha;
@ -1093,16 +1213,16 @@ var spine;
this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix; this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix;
this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix; this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix;
}; };
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, blend, direction) {
var frames = this.frames; var frames = this.frames;
var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
if (time < frames[0]) { if (time < frames[0]) {
switch (pose) { switch (blend) {
case MixPose.setup: case MixBlend.setup:
constraint.rotateMix = constraint.data.rotateMix; constraint.rotateMix = constraint.data.rotateMix;
constraint.translateMix = constraint.data.translateMix; constraint.translateMix = constraint.data.translateMix;
return; return;
case MixPose.current: case MixBlend.first:
constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha; constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha;
constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha; constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha;
} }
@ -1122,7 +1242,7 @@ var spine;
rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent; rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent;
translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent; translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent;
} }
if (pose == MixPose.setup) { if (blend == MixBlend.setup) {
constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha; constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha;
constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha; constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha;
} }
@ -1238,18 +1358,18 @@ var spine;
if (current == null || current.delay > 0) if (current == null || current.delay > 0)
continue; continue;
applied = true; applied = true;
var currentPose = i == 0 ? spine.MixPose.current : spine.MixPose.currentLayered; var blend = i == 0 ? spine.MixBlend.first : current.mixBlend;
var mix = current.alpha; var mix = current.alpha;
if (current.mixingFrom != null) if (current.mixingFrom != null)
mix *= this.applyMixingFrom(current, skeleton, currentPose); mix *= this.applyMixingFrom(current, skeleton, blend);
else if (current.trackTime >= current.trackEnd && current.next == null) else if (current.trackTime >= current.trackEnd && current.next == null)
mix = 0; mix = 0;
var animationLast = current.animationLast, animationTime = current.getAnimationTime(); var animationLast = current.animationLast, animationTime = current.getAnimationTime();
var timelineCount = current.animation.timelines.length; var timelineCount = current.animation.timelines.length;
var timelines = current.animation.timelines; var timelines = current.animation.timelines;
if (mix == 1) { if (mix == 1 || blend == spine.MixBlend.add) {
for (var ii = 0; ii < timelineCount; ii++) for (var ii = 0; ii < timelineCount; ii++)
timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, spine.MixPose.setup, spine.MixDirection["in"]); timelines[ii].apply(skeleton, animationLast, animationTime, events, mix, blend, spine.MixDirection["in"]);
} }
else { else {
var timelineData = current.timelineData; var timelineData = current.timelineData;
@ -1259,12 +1379,12 @@ var spine;
var timelinesRotation = current.timelinesRotation; var timelinesRotation = current.timelinesRotation;
for (var ii = 0; ii < timelineCount; ii++) { for (var ii = 0; ii < timelineCount; ii++) {
var timeline = timelines[ii]; var timeline = timelines[ii];
var pose = timelineData[ii] >= AnimationState.FIRST ? spine.MixPose.setup : currentPose; var timelineBlend = timelineData[ii] == AnimationState.SUBSEQUENT ? blend : spine.MixBlend.setup;
if (timeline instanceof spine.RotateTimeline) { if (timeline instanceof spine.RotateTimeline) {
this.applyRotateTimeline(timeline, skeleton, animationTime, mix, pose, timelinesRotation, ii << 1, firstFrame); this.applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineBlend, timelinesRotation, ii << 1, firstFrame);
} }
else else
timeline.apply(skeleton, animationLast, animationTime, events, mix, pose, spine.MixDirection["in"]); timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineBlend, spine.MixDirection["in"]);
} }
} }
this.queueEvents(current, animationTime); this.queueEvents(current, animationTime);
@ -1275,65 +1395,74 @@ var spine;
this.queue.drain(); this.queue.drain();
return applied; return applied;
}; };
AnimationState.prototype.applyMixingFrom = function (to, skeleton, currentPose) { AnimationState.prototype.applyMixingFrom = function (to, skeleton, blend) {
var from = to.mixingFrom; var from = to.mixingFrom;
if (from.mixingFrom != null) if (from.mixingFrom != null)
this.applyMixingFrom(from, skeleton, currentPose); this.applyMixingFrom(from, skeleton, blend);
var mix = 0; var mix = 0;
if (to.mixDuration == 0) { if (to.mixDuration == 0) {
mix = 1; mix = 1;
currentPose = spine.MixPose.setup; if (blend == spine.MixBlend.first)
blend = spine.MixBlend.setup;
} }
else { else {
mix = to.mixTime / to.mixDuration; mix = to.mixTime / to.mixDuration;
if (mix > 1) if (mix > 1)
mix = 1; mix = 1;
if (blend != spine.MixBlend.first)
blend = from.mixBlend;
} }
var events = mix < from.eventThreshold ? this.events : null; var events = mix < from.eventThreshold ? this.events : null;
var attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold; var attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold;
var animationLast = from.animationLast, animationTime = from.getAnimationTime(); var animationLast = from.animationLast, animationTime = from.getAnimationTime();
var timelineCount = from.animation.timelines.length; var timelineCount = from.animation.timelines.length;
var timelines = from.animation.timelines; var timelines = from.animation.timelines;
var timelineData = from.timelineData; var alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix);
var timelineDipMix = from.timelineDipMix; if (blend == spine.MixBlend.add) {
var firstFrame = from.timelinesRotation.length == 0; for (var i = 0; i < timelineCount; i++)
if (firstFrame) timelines[i].apply(skeleton, animationLast, animationTime, events, alphaMix, blend, spine.MixDirection.out);
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null); }
var timelinesRotation = from.timelinesRotation; else {
var pose; var timelineData = from.timelineData;
var alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix), alpha = 0; var timelineDipMix = from.timelineDipMix;
from.totalAlpha = 0; var firstFrame = from.timelinesRotation.length == 0;
for (var i = 0; i < timelineCount; i++) { if (firstFrame)
var timeline = timelines[i]; spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
switch (timelineData[i]) { var timelinesRotation = from.timelinesRotation;
case AnimationState.SUBSEQUENT: from.totalAlpha = 0;
if (!attachments && timeline instanceof spine.AttachmentTimeline) for (var i = 0; i < timelineCount; i++) {
continue; var timeline = timelines[i];
if (!drawOrder && timeline instanceof spine.DrawOrderTimeline) var timelineBlend;
continue; var alpha = 0;
pose = currentPose; switch (timelineData[i]) {
alpha = alphaMix; case AnimationState.SUBSEQUENT:
break; if (!attachments && timeline instanceof spine.AttachmentTimeline)
case AnimationState.FIRST: continue;
pose = spine.MixPose.setup; if (!drawOrder && timeline instanceof spine.DrawOrderTimeline)
alpha = alphaMix; continue;
break; timelineBlend = blend;
case AnimationState.DIP: alpha = alphaMix;
pose = spine.MixPose.setup; break;
alpha = alphaDip; case AnimationState.FIRST:
break; timelineBlend = spine.MixBlend.setup;
default: alpha = alphaMix;
pose = spine.MixPose.setup; break;
alpha = alphaDip; case AnimationState.DIP:
var dipMix = timelineDipMix[i]; timelineBlend = spine.MixBlend.setup;
alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration); alpha = alphaDip;
break; break;
} default:
from.totalAlpha += alpha; timelineBlend = spine.MixBlend.setup;
if (timeline instanceof spine.RotateTimeline) var dipMix = timelineDipMix[i];
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame); alpha = alphaDip * Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
else { break;
timeline.apply(skeleton, animationLast, animationTime, events, alpha, pose, spine.MixDirection.out); }
from.totalAlpha += alpha;
if (timeline instanceof spine.RotateTimeline)
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, timelineBlend, timelinesRotation, i << 1, firstFrame);
else {
timeline.apply(skeleton, animationLast, animationTime, events, alpha, timelineBlend, spine.MixDirection.out);
}
} }
} }
if (to.mixDuration > 0) if (to.mixDuration > 0)
@ -1343,18 +1472,18 @@ var spine;
from.nextTrackLast = from.trackTime; from.nextTrackLast = from.trackTime;
return mix; return mix;
}; };
AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, pose, timelinesRotation, i, firstFrame) { AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, blend, timelinesRotation, i, firstFrame) {
if (firstFrame) if (firstFrame)
timelinesRotation[i] = 0; timelinesRotation[i] = 0;
if (alpha == 1) { if (alpha == 1) {
timeline.apply(skeleton, 0, time, null, 1, pose, spine.MixDirection["in"]); timeline.apply(skeleton, 0, time, null, 1, blend, spine.MixDirection["in"]);
return; return;
} }
var rotateTimeline = timeline; var rotateTimeline = timeline;
var frames = rotateTimeline.frames; var frames = rotateTimeline.frames;
var bone = skeleton.bones[rotateTimeline.boneIndex]; var bone = skeleton.bones[rotateTimeline.boneIndex];
if (time < frames[0]) { if (time < frames[0]) {
if (pose == spine.MixPose.setup) if (blend == spine.MixBlend.setup)
bone.rotation = bone.data.rotation; bone.rotation = bone.data.rotation;
return; return;
} }
@ -1371,7 +1500,7 @@ var spine;
r2 = prevRotation + r2 * percent + bone.data.rotation; r2 = prevRotation + r2 * percent + bone.data.rotation;
r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360; r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
} }
var r1 = pose == spine.MixPose.setup ? bone.data.rotation : bone.rotation; var r1 = blend == spine.MixBlend.setup ? bone.data.rotation : bone.rotation;
var total = 0, diff = r2 - r1; var total = 0, diff = r2 - r1;
if (diff == 0) { if (diff == 0) {
total = timelinesRotation[i]; total = timelinesRotation[i];
@ -1601,7 +1730,7 @@ var spine;
var mixingTo = this.mixingTo; var mixingTo = this.mixingTo;
for (var i = 0, n = this.tracks.length; i < n; i++) { for (var i = 0, n = this.tracks.length; i < n; i++) {
var entry = this.tracks[i]; var entry = this.tracks[i];
if (entry != null) if (entry != null && (i == 0 || entry.mixBlend != spine.MixBlend.add))
entry.setTimelineData(null, mixingTo, propertyIDs); entry.setTimelineData(null, mixingTo, propertyIDs);
} }
}; };
@ -1636,6 +1765,7 @@ var spine;
spine.AnimationState = AnimationState; spine.AnimationState = AnimationState;
var TrackEntry = (function () { var TrackEntry = (function () {
function TrackEntry() { function TrackEntry() {
this.mixBlend = spine.MixBlend.replace;
this.timelineData = new Array(); this.timelineData = new Array();
this.timelineDipMix = new Array(); this.timelineDipMix = new Array();
this.timelinesRotation = new Array(); this.timelinesRotation = new Array();
@ -6800,8 +6930,8 @@ var spine;
break; break;
} }
var listeners = _this.listeners; var listeners = _this.listeners;
for (var i_8 = 0; i_8 < listeners.length; i_8++) { for (var i_16 = 0; i_16 < listeners.length; i_16++) {
listeners[i_8].down(_this.currTouch.x, _this.currTouch.y); listeners[i_16].down(_this.currTouch.x, _this.currTouch.y);
} }
console.log("Start " + _this.currTouch.x + ", " + _this.currTouch.y); console.log("Start " + _this.currTouch.x + ", " + _this.currTouch.y);
_this.lastX = _this.currTouch.x; _this.lastX = _this.currTouch.x;
@ -6819,8 +6949,8 @@ var spine;
var y = _this.currTouch.y = touch.clientY - rect.top; var y = _this.currTouch.y = touch.clientY - rect.top;
_this.touchesPool.free(_this.currTouch); _this.touchesPool.free(_this.currTouch);
var listeners = _this.listeners; var listeners = _this.listeners;
for (var i_9 = 0; i_9 < listeners.length; i_9++) { for (var i_17 = 0; i_17 < listeners.length; i_17++) {
listeners[i_9].up(x, y); listeners[i_17].up(x, y);
} }
console.log("End " + x + ", " + y); console.log("End " + x + ", " + y);
_this.lastX = x; _this.lastX = x;
@ -6842,8 +6972,8 @@ var spine;
var y = _this.currTouch.y = touch.clientY - rect.top; var y = _this.currTouch.y = touch.clientY - rect.top;
_this.touchesPool.free(_this.currTouch); _this.touchesPool.free(_this.currTouch);
var listeners = _this.listeners; var listeners = _this.listeners;
for (var i_10 = 0; i_10 < listeners.length; i_10++) { for (var i_18 = 0; i_18 < listeners.length; i_18++) {
listeners[i_10].up(x, y); listeners[i_18].up(x, y);
} }
console.log("End " + x + ", " + y); console.log("End " + x + ", " + y);
_this.lastX = x; _this.lastX = x;
@ -6866,8 +6996,8 @@ var spine;
var x = touch.clientX - rect.left; var x = touch.clientX - rect.left;
var y = touch.clientY - rect.top; var y = touch.clientY - rect.top;
var listeners = _this.listeners; var listeners = _this.listeners;
for (var i_11 = 0; i_11 < listeners.length; i_11++) { for (var i_19 = 0; i_19 < listeners.length; i_19++) {
listeners[i_11].dragged(x, y); listeners[i_19].dragged(x, y);
} }
console.log("Drag " + x + ", " + y); console.log("Drag " + x + ", " + y);
_this.lastX = _this.currTouch.x = x; _this.lastX = _this.currTouch.x = x;
@ -8715,11 +8845,11 @@ var spine;
var nn = clip.worldVerticesLength; var nn = clip.worldVerticesLength;
var world = this.temp = spine.Utils.setArraySize(this.temp, nn, 0); var world = this.temp = spine.Utils.setArraySize(this.temp, nn, 0);
clip.computeWorldVertices(slot, 0, nn, world, 0, 2); clip.computeWorldVertices(slot, 0, nn, world, 0, 2);
for (var i_12 = 0, n_2 = world.length; i_12 < n_2; i_12 += 2) { for (var i_20 = 0, n_2 = world.length; i_20 < n_2; i_20 += 2) {
var x = world[i_12]; var x = world[i_20];
var y = world[i_12 + 1]; var y = world[i_20 + 1];
var x2 = world[(i_12 + 2) % world.length]; var x2 = world[(i_20 + 2) % world.length];
var y2 = world[(i_12 + 3) % world.length]; var y2 = world[(i_20 + 3) % world.length];
shapes.line(x, y, x2, y2); shapes.line(x, y, x2, y2);
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -709,7 +709,7 @@ module spine {
let frames = this.frames; let frames = this.frames;
if (time < frames[0]) { if (time < frames[0]) {
if (blend == MixBlend.setup) { if (blend == MixBlend.setup || blend == MixBlend.first) {
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));
} }