mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 14:24:53 +08:00
[ts] Ported VertexAttachment id and Timeline/Animation#apply changes
This commit is contained in:
parent
ef6f181267
commit
f158e9e996
@ -178,6 +178,8 @@
|
||||
* Added `ClippingAttachment`, additional method `newClippingAttachment` in `AttachmentLoader` interface.
|
||||
* Added `SkeletonClipper` and `Triangulator`, used to implement software clipping of attachments.
|
||||
* `AnimationState#apply` returns boolean indicating if any timeline was applied or not.
|
||||
* `Animation#apply` and `Timeline#apply`` now take enums `MixPose` and `MixDirection` instead of booleans
|
||||
|
||||
|
||||
### WebGL backend
|
||||
* Fixed WebGL context loss
|
||||
|
||||
51
spine-ts/build/spine-all.d.ts
vendored
51
spine-ts/build/spine-all.d.ts
vendored
@ -98,14 +98,23 @@ declare module spine {
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
static binarySearch(values: ArrayLike<number>, target: number, step?: number): number;
|
||||
static linearSearch(values: ArrayLike<number>, target: number, step: number): number;
|
||||
}
|
||||
interface Timeline {
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
getPropertyId(): number;
|
||||
}
|
||||
enum MixPose {
|
||||
setup = 0,
|
||||
current = 1,
|
||||
currentLayered = 2,
|
||||
}
|
||||
enum MixDirection {
|
||||
in = 0,
|
||||
out = 1,
|
||||
}
|
||||
enum TimelineType {
|
||||
rotate = 0,
|
||||
translate = 1,
|
||||
@ -137,7 +146,7 @@ declare module spine {
|
||||
getCurveType(frameIndex: number): number;
|
||||
setCurve(frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void;
|
||||
getCurvePercent(frameIndex: number, percent: number): number;
|
||||
abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class RotateTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -149,7 +158,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, degrees: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class TranslateTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -163,17 +172,17 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, x: number, y: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class ScaleTimeline extends TranslateTimeline {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class ShearTimeline extends TranslateTimeline {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class ColorTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -191,7 +200,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class TwoColorTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -215,7 +224,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class AttachmentTimeline implements Timeline {
|
||||
slotIndex: number;
|
||||
@ -225,7 +234,7 @@ declare module spine {
|
||||
getPropertyId(): number;
|
||||
getFrameCount(): number;
|
||||
setFrame(frameIndex: number, time: number, attachmentName: string): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class DeformTimeline extends CurveTimeline {
|
||||
slotIndex: number;
|
||||
@ -235,7 +244,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class EventTimeline implements Timeline {
|
||||
frames: ArrayLike<number>;
|
||||
@ -244,7 +253,7 @@ declare module spine {
|
||||
getPropertyId(): number;
|
||||
getFrameCount(): number;
|
||||
setFrame(frameIndex: number, event: Event): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class DrawOrderTimeline implements Timeline {
|
||||
frames: ArrayLike<number>;
|
||||
@ -253,7 +262,7 @@ declare module spine {
|
||||
getPropertyId(): number;
|
||||
getFrameCount(): number;
|
||||
setFrame(frameIndex: number, time: number, drawOrder: Array<number>): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class IkConstraintTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -267,7 +276,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, mix: number, bendDirection: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class TransformConstraintTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -285,7 +294,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class PathConstraintPositionTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -297,12 +306,12 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, value: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class PathConstraintSpacingTimeline extends PathConstraintPositionTimeline {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class PathConstraintMixTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -316,7 +325,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
@ -340,8 +349,8 @@ declare module spine {
|
||||
update(delta: number): void;
|
||||
updateMixingFrom(to: TrackEntry, delta: number): boolean;
|
||||
apply(skeleton: Skeleton): boolean;
|
||||
applyMixingFrom(to: TrackEntry, skeleton: Skeleton): number;
|
||||
applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, setupPose: boolean, timelinesRotation: Array<number>, i: number, firstFrame: boolean): void;
|
||||
applyMixingFrom(to: TrackEntry, skeleton: Skeleton, currentPose: MixPose): number;
|
||||
applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, pose: MixPose, timelinesRotation: Array<number>, i: number, firstFrame: boolean): void;
|
||||
queueEvents(entry: TrackEntry, animationTime: number): void;
|
||||
clearTracks(): void;
|
||||
clearTrack(trackIndex: number): void;
|
||||
@ -467,6 +476,8 @@ declare module spine {
|
||||
constructor(name: string);
|
||||
}
|
||||
abstract class VertexAttachment extends Attachment {
|
||||
private static nextID;
|
||||
id: number;
|
||||
bones: Array<number>;
|
||||
vertices: ArrayLike<number>;
|
||||
worldVerticesLength: number;
|
||||
|
||||
@ -463,7 +463,7 @@ var spine;
|
||||
this.timelines = timelines;
|
||||
this.duration = duration;
|
||||
}
|
||||
Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, setupPose, mixingOut) {
|
||||
Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, pose, direction) {
|
||||
if (skeleton == null)
|
||||
throw new Error("skeleton cannot be null.");
|
||||
if (loop && this.duration != 0) {
|
||||
@ -473,7 +473,7 @@ var spine;
|
||||
}
|
||||
var timelines = this.timelines;
|
||||
for (var i = 0, n = timelines.length; i < n; i++)
|
||||
timelines[i].apply(skeleton, lastTime, time, events, alpha, setupPose, mixingOut);
|
||||
timelines[i].apply(skeleton, lastTime, time, events, alpha, pose, direction);
|
||||
};
|
||||
Animation.binarySearch = function (values, target, step) {
|
||||
if (step === void 0) { step = 1; }
|
||||
@ -501,6 +501,17 @@ var spine;
|
||||
return Animation;
|
||||
}());
|
||||
spine.Animation = Animation;
|
||||
(function (MixPose) {
|
||||
MixPose[MixPose["setup"] = 0] = "setup";
|
||||
MixPose[MixPose["current"] = 1] = "current";
|
||||
MixPose[MixPose["currentLayered"] = 2] = "currentLayered";
|
||||
})(spine.MixPose || (spine.MixPose = {}));
|
||||
var MixPose = spine.MixPose;
|
||||
(function (MixDirection) {
|
||||
MixDirection[MixDirection["in"] = 0] = "in";
|
||||
MixDirection[MixDirection["out"] = 1] = "out";
|
||||
})(spine.MixDirection || (spine.MixDirection = {}));
|
||||
var MixDirection = spine.MixDirection;
|
||||
(function (TimelineType) {
|
||||
TimelineType[TimelineType["rotate"] = 0] = "rotate";
|
||||
TimelineType[TimelineType["translate"] = 1] = "translate";
|
||||
@ -615,21 +626,28 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.frames[frameIndex + RotateTimeline.ROTATION] = degrees;
|
||||
};
|
||||
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
bone.rotation = bone.data.rotation;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.rotation = bone.data.rotation;
|
||||
return;
|
||||
case MixPose.current:
|
||||
var r_1 = bone.data.rotation - bone.rotation;
|
||||
r_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360;
|
||||
bone.rotation += r_1 * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha;
|
||||
else {
|
||||
var r_1 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation;
|
||||
r_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360;
|
||||
bone.rotation += r_1 * alpha;
|
||||
var r_2 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation;
|
||||
r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360;
|
||||
bone.rotation += r_2 * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -640,7 +658,7 @@ var spine;
|
||||
var r = frames[frame + RotateTimeline.ROTATION] - prevRotation;
|
||||
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
|
||||
r = prevRotation + r * percent;
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
|
||||
bone.rotation = bone.data.rotation + r * alpha;
|
||||
}
|
||||
@ -672,13 +690,18 @@ var spine;
|
||||
this.frames[frameIndex + TranslateTimeline.X] = x;
|
||||
this.frames[frameIndex + TranslateTimeline.Y] = y;
|
||||
};
|
||||
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
bone.x = bone.data.x;
|
||||
bone.y = bone.data.y;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.x = bone.data.x;
|
||||
bone.y = bone.data.y;
|
||||
return;
|
||||
case MixPose.current:
|
||||
bone.x += (bone.data.x - bone.x) * alpha;
|
||||
bone.y += (bone.data.y - bone.y) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -696,7 +719,7 @@ var spine;
|
||||
x += (frames[frame + TranslateTimeline.X] - x) * percent;
|
||||
y += (frames[frame + TranslateTimeline.Y] - y) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
bone.x = bone.data.x + x * alpha;
|
||||
bone.y = bone.data.y + y * alpha;
|
||||
}
|
||||
@ -722,13 +745,18 @@ var spine;
|
||||
ScaleTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.scale << 24) + this.boneIndex;
|
||||
};
|
||||
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
bone.scaleX = bone.data.scaleX;
|
||||
bone.scaleY = bone.data.scaleY;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.scaleX = bone.data.scaleX;
|
||||
bone.scaleY = bone.data.scaleY;
|
||||
return;
|
||||
case MixPose.current:
|
||||
bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;
|
||||
bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -752,7 +780,7 @@ var spine;
|
||||
}
|
||||
else {
|
||||
var bx = 0, by = 0;
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
bx = bone.data.scaleX;
|
||||
by = bone.data.scaleY;
|
||||
}
|
||||
@ -760,7 +788,7 @@ var spine;
|
||||
bx = bone.scaleX;
|
||||
by = bone.scaleY;
|
||||
}
|
||||
if (mixingOut) {
|
||||
if (direction == MixDirection.out) {
|
||||
x = Math.abs(x) * spine.MathUtils.signum(bx);
|
||||
y = Math.abs(y) * spine.MathUtils.signum(by);
|
||||
}
|
||||
@ -783,13 +811,18 @@ var spine;
|
||||
ShearTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.shear << 24) + this.boneIndex;
|
||||
};
|
||||
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
bone.shearX = bone.data.shearX;
|
||||
bone.shearY = bone.data.shearY;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.shearX = bone.data.shearX;
|
||||
bone.shearY = bone.data.shearY;
|
||||
return;
|
||||
case MixPose.current:
|
||||
bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
|
||||
bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -807,7 +840,7 @@ var spine;
|
||||
x = x + (frames[frame + ShearTimeline.X] - x) * percent;
|
||||
y = y + (frames[frame + ShearTimeline.Y] - y) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
bone.shearX = bone.data.shearX + x * alpha;
|
||||
bone.shearY = bone.data.shearY + y * alpha;
|
||||
}
|
||||
@ -836,12 +869,18 @@ var spine;
|
||||
this.frames[frameIndex + ColorTimeline.B] = b;
|
||||
this.frames[frameIndex + ColorTimeline.A] = a;
|
||||
};
|
||||
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
return;
|
||||
case MixPose.current:
|
||||
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);
|
||||
}
|
||||
return;
|
||||
}
|
||||
var r = 0, g = 0, b = 0, a = 0;
|
||||
@ -869,7 +908,7 @@ var spine;
|
||||
slot.color.set(r, g, b, a);
|
||||
else {
|
||||
var color = slot.color;
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
color.setFromColor(slot.data.color);
|
||||
color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
|
||||
}
|
||||
@ -907,13 +946,19 @@ var spine;
|
||||
this.frames[frameIndex + TwoColorTimeline.G2] = g2;
|
||||
this.frames[frameIndex + TwoColorTimeline.B2] = b2;
|
||||
};
|
||||
TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
slot.darkColor.setFromColor(slot.data.darkColor);
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
slot.darkColor.setFromColor(slot.data.darkColor);
|
||||
return;
|
||||
case MixPose.current:
|
||||
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);
|
||||
dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -952,9 +997,8 @@ var spine;
|
||||
slot.darkColor.set(r2, g2, b2, 1);
|
||||
}
|
||||
else {
|
||||
var light = slot.color;
|
||||
var dark = slot.darkColor;
|
||||
if (setupPose) {
|
||||
var light = slot.color, dark = slot.darkColor;
|
||||
if (pose == MixPose.setup) {
|
||||
light.setFromColor(slot.data.color);
|
||||
dark.setFromColor(slot.data.darkColor);
|
||||
}
|
||||
@ -996,16 +1040,16 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.attachmentNames[frameIndex] = attachmentName;
|
||||
};
|
||||
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
if (mixingOut && setupPose) {
|
||||
if (direction == MixDirection.out && pose == MixPose.setup) {
|
||||
var attachmentName_1 = slot.data.attachmentName;
|
||||
slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1));
|
||||
return;
|
||||
}
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
var attachmentName_2 = slot.data.attachmentName;
|
||||
slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2));
|
||||
}
|
||||
@ -1031,35 +1075,42 @@ var spine;
|
||||
this.frameVertices = new Array(frameCount);
|
||||
}
|
||||
DeformTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.deform << 24) + this.slotIndex;
|
||||
return (TimelineType.deform << 27) + +this.attachment.id + this.slotIndex;
|
||||
};
|
||||
DeformTimeline.prototype.setFrame = function (frameIndex, time, vertices) {
|
||||
this.frames[frameIndex] = time;
|
||||
this.frameVertices[frameIndex] = vertices;
|
||||
};
|
||||
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var slotAttachment = slot.getAttachment();
|
||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
||||
return;
|
||||
var frames = this.frames;
|
||||
var verticesArray = slot.attachmentVertices;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
spine.Utils.setArraySize(verticesArray, 0);
|
||||
return;
|
||||
}
|
||||
var frameVertices = this.frameVertices;
|
||||
var vertexCount = frameVertices[0].length;
|
||||
if (verticesArray.length != vertexCount && !setupPose)
|
||||
if (verticesArray.length != vertexCount && pose != MixPose.setup)
|
||||
alpha = 1;
|
||||
var vertices = spine.Utils.setArraySize(verticesArray, vertexCount);
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
verticesArray.length = 0;
|
||||
return;
|
||||
case MixPose.current:
|
||||
alpha = 1 - alpha;
|
||||
for (var i = 0; i < vertexCount; i++)
|
||||
vertices[i] *= alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (time >= frames[frames.length - 1]) {
|
||||
var lastVertices = frameVertices[frames.length - 1];
|
||||
if (alpha == 1) {
|
||||
spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount);
|
||||
}
|
||||
else if (setupPose) {
|
||||
else if (pose == MixPose.setup) {
|
||||
var vertexAttachment = slotAttachment;
|
||||
if (vertexAttachment.bones == null) {
|
||||
var setupVertices = vertexAttachment.vertices;
|
||||
@ -1090,7 +1141,7 @@ var spine;
|
||||
vertices[i] = prev + (nextVertices[i] - prev) * percent;
|
||||
}
|
||||
}
|
||||
else if (setupPose) {
|
||||
else if (pose == MixPose.setup) {
|
||||
var vertexAttachment = slotAttachment;
|
||||
if (vertexAttachment.bones == null) {
|
||||
var setupVertices = vertexAttachment.vertices;
|
||||
@ -1131,13 +1182,13 @@ var spine;
|
||||
this.frames[frameIndex] = event.time;
|
||||
this.events[frameIndex] = event;
|
||||
};
|
||||
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
if (firedEvents == null)
|
||||
return;
|
||||
var frames = this.frames;
|
||||
var frameCount = this.frames.length;
|
||||
if (lastTime > time) {
|
||||
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, setupPose, mixingOut);
|
||||
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, pose, direction);
|
||||
lastTime = -1;
|
||||
}
|
||||
else if (lastTime >= frames[frameCount - 1])
|
||||
@ -1177,16 +1228,16 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.drawOrders[frameIndex] = drawOrder;
|
||||
};
|
||||
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var drawOrder = skeleton.drawOrder;
|
||||
var slots = skeleton.slots;
|
||||
if (mixingOut && setupPose) {
|
||||
if (direction == MixDirection.out && pose == MixPose.setup) {
|
||||
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||
return;
|
||||
}
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||
return;
|
||||
}
|
||||
@ -1221,25 +1272,30 @@ var spine;
|
||||
this.frames[frameIndex + IkConstraintTimeline.MIX] = mix;
|
||||
this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection;
|
||||
};
|
||||
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
constraint.mix = constraint.data.mix;
|
||||
constraint.bendDirection = constraint.data.bendDirection;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.mix = constraint.data.mix;
|
||||
constraint.bendDirection = constraint.data.bendDirection;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.mix += (constraint.data.mix - constraint.mix) * alpha;
|
||||
constraint.bendDirection = constraint.data.bendDirection;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
|
||||
constraint.bendDirection = mixingOut ? constraint.data.bendDirection
|
||||
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection
|
||||
: frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
else {
|
||||
constraint.mix += (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.mix) * alpha;
|
||||
if (!mixingOut)
|
||||
if (direction == MixDirection.in)
|
||||
constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
return;
|
||||
@ -1248,13 +1304,13 @@ var spine;
|
||||
var mix = frames[frame + IkConstraintTimeline.PREV_MIX];
|
||||
var frameTime = frames[frame];
|
||||
var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime));
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha;
|
||||
constraint.bendDirection = mixingOut ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
else {
|
||||
constraint.mix += (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.mix) * alpha;
|
||||
if (!mixingOut)
|
||||
if (direction == MixDirection.in)
|
||||
constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
};
|
||||
@ -1284,16 +1340,23 @@ var spine;
|
||||
this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix;
|
||||
this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix;
|
||||
};
|
||||
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
var data = constraint.data;
|
||||
constraint.rotateMix = data.rotateMix;
|
||||
constraint.translateMix = data.rotateMix;
|
||||
constraint.scaleMix = data.scaleMix;
|
||||
constraint.shearMix = data.shearMix;
|
||||
var data = constraint.data;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.rotateMix = data.rotateMix;
|
||||
constraint.translateMix = data.translateMix;
|
||||
constraint.scaleMix = data.scaleMix;
|
||||
constraint.shearMix = data.shearMix;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha;
|
||||
constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha;
|
||||
constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha;
|
||||
constraint.shearMix += (data.shearMix - constraint.shearMix) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1318,7 +1381,7 @@ var spine;
|
||||
scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent;
|
||||
shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
var data = constraint.data;
|
||||
constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha;
|
||||
constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha;
|
||||
@ -1359,12 +1422,17 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value;
|
||||
};
|
||||
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
constraint.position = constraint.data.position;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.position = constraint.data.position;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.position += (constraint.data.position - constraint.position) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
var position = 0;
|
||||
@ -1377,7 +1445,7 @@ var spine;
|
||||
var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime));
|
||||
position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent;
|
||||
}
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
constraint.position = constraint.data.position + (position - constraint.data.position) * alpha;
|
||||
else
|
||||
constraint.position += (position - constraint.position) * alpha;
|
||||
@ -1397,12 +1465,17 @@ var spine;
|
||||
PathConstraintSpacingTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex;
|
||||
};
|
||||
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
constraint.spacing = constraint.data.spacing;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.spacing = constraint.data.spacing;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
var spacing = 0;
|
||||
@ -1415,7 +1488,7 @@ var spine;
|
||||
var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime));
|
||||
spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent;
|
||||
}
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;
|
||||
else
|
||||
constraint.spacing += (spacing - constraint.spacing) * alpha;
|
||||
@ -1438,13 +1511,18 @@ var spine;
|
||||
this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix;
|
||||
this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix;
|
||||
};
|
||||
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
constraint.rotateMix = constraint.data.rotateMix;
|
||||
constraint.translateMix = constraint.data.translateMix;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.rotateMix = constraint.data.rotateMix;
|
||||
constraint.translateMix = constraint.data.translateMix;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha;
|
||||
constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1462,7 +1540,7 @@ var spine;
|
||||
rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent;
|
||||
translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha;
|
||||
constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha;
|
||||
}
|
||||
@ -1578,9 +1656,10 @@ var spine;
|
||||
if (current == null || current.delay > 0)
|
||||
continue;
|
||||
applied = true;
|
||||
var currentPose = i == 0 ? spine.MixPose.current : spine.MixPose.currentLayered;
|
||||
var mix = current.alpha;
|
||||
if (current.mixingFrom != null)
|
||||
mix *= this.applyMixingFrom(current, skeleton);
|
||||
mix *= this.applyMixingFrom(current, skeleton, currentPose);
|
||||
else if (current.trackTime >= current.trackEnd && current.next == null)
|
||||
mix = 0;
|
||||
var animationLast = current.animationLast, animationTime = current.getAnimationTime();
|
||||
@ -1588,7 +1667,7 @@ var spine;
|
||||
var timelines = current.animation.timelines;
|
||||
if (mix == 1) {
|
||||
for (var ii = 0; ii < timelineCount; ii++)
|
||||
timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, true, false);
|
||||
timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, spine.MixPose.setup, spine.MixDirection.in);
|
||||
}
|
||||
else {
|
||||
var timelineData = current.timelineData;
|
||||
@ -1598,11 +1677,12 @@ var spine;
|
||||
var timelinesRotation = current.timelinesRotation;
|
||||
for (var ii = 0; ii < timelineCount; ii++) {
|
||||
var timeline = timelines[ii];
|
||||
var pose = timelineData[ii] >= AnimationState.FIRST ? spine.MixPose.setup : currentPose;
|
||||
if (timeline instanceof spine.RotateTimeline) {
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineData[ii] >= AnimationState.FIRST, timelinesRotation, ii << 1, firstFrame);
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, mix, pose, timelinesRotation, ii << 1, firstFrame);
|
||||
}
|
||||
else
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineData[ii] >= AnimationState.FIRST, false);
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, mix, pose, spine.MixDirection.in);
|
||||
}
|
||||
}
|
||||
this.queueEvents(current, animationTime);
|
||||
@ -1613,10 +1693,10 @@ var spine;
|
||||
this.queue.drain();
|
||||
return applied;
|
||||
};
|
||||
AnimationState.prototype.applyMixingFrom = function (to, skeleton) {
|
||||
AnimationState.prototype.applyMixingFrom = function (to, skeleton, currentPose) {
|
||||
var from = to.mixingFrom;
|
||||
if (from.mixingFrom != null)
|
||||
this.applyMixingFrom(from, skeleton);
|
||||
this.applyMixingFrom(from, skeleton, currentPose);
|
||||
var mix = 0;
|
||||
if (to.mixDuration == 0)
|
||||
mix = 1;
|
||||
@ -1636,26 +1716,30 @@ var spine;
|
||||
if (firstFrame)
|
||||
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
|
||||
var timelinesRotation = from.timelinesRotation;
|
||||
var first = false;
|
||||
var pose;
|
||||
var alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix), alpha = 0;
|
||||
from.totalAlpha = 0;
|
||||
for (var i = 0; i < timelineCount; i++) {
|
||||
var timeline = timelines[i];
|
||||
switch (timelineData[i]) {
|
||||
case AnimationState.SUBSEQUENT:
|
||||
first = false;
|
||||
if (!attachments && timeline instanceof spine.AttachmentTimeline)
|
||||
continue;
|
||||
if (!drawOrder && timeline instanceof spine.DrawOrderTimeline)
|
||||
continue;
|
||||
pose = currentPose;
|
||||
alpha = alphaMix;
|
||||
break;
|
||||
case AnimationState.FIRST:
|
||||
first = true;
|
||||
pose = spine.MixPose.setup;
|
||||
alpha = alphaMix;
|
||||
break;
|
||||
case AnimationState.DIP:
|
||||
first = true;
|
||||
pose = spine.MixPose.setup;
|
||||
alpha = alphaDip;
|
||||
break;
|
||||
default:
|
||||
first = true;
|
||||
pose = spine.MixPose.setup;
|
||||
alpha = alphaDip;
|
||||
var dipMix = timelineDipMix[i];
|
||||
alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
|
||||
@ -1663,15 +1747,9 @@ var spine;
|
||||
}
|
||||
from.totalAlpha += alpha;
|
||||
if (timeline instanceof spine.RotateTimeline)
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, first, timelinesRotation, i << 1, firstFrame);
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame);
|
||||
else {
|
||||
if (!first) {
|
||||
if (!attachments && timeline instanceof spine.AttachmentTimeline)
|
||||
continue;
|
||||
if (!drawOrder && timeline instanceof spine.DrawOrderTimeline)
|
||||
continue;
|
||||
}
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, alpha, first, true);
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, alpha, pose, spine.MixDirection.out);
|
||||
}
|
||||
}
|
||||
if (to.mixDuration > 0)
|
||||
@ -1681,18 +1759,18 @@ var spine;
|
||||
from.nextTrackLast = from.trackTime;
|
||||
return mix;
|
||||
};
|
||||
AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, setupPose, timelinesRotation, i, firstFrame) {
|
||||
AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, pose, timelinesRotation, i, firstFrame) {
|
||||
if (firstFrame)
|
||||
timelinesRotation[i] = 0;
|
||||
if (alpha == 1) {
|
||||
timeline.apply(skeleton, 0, time, null, 1, setupPose, false);
|
||||
timeline.apply(skeleton, 0, time, null, 1, pose, spine.MixDirection.in);
|
||||
return;
|
||||
}
|
||||
var rotateTimeline = timeline;
|
||||
var frames = rotateTimeline.frames;
|
||||
var bone = skeleton.bones[rotateTimeline.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
if (pose == spine.MixPose.setup)
|
||||
bone.rotation = bone.data.rotation;
|
||||
return;
|
||||
}
|
||||
@ -1709,7 +1787,7 @@ var spine;
|
||||
r2 = prevRotation + r2 * percent + bone.data.rotation;
|
||||
r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
|
||||
}
|
||||
var r1 = setupPose ? bone.data.rotation : bone.rotation;
|
||||
var r1 = pose == spine.MixPose.setup ? bone.data.rotation : bone.rotation;
|
||||
var total = 0, diff = r2 - r1;
|
||||
if (diff == 0) {
|
||||
total = timelinesRotation[i];
|
||||
@ -2270,6 +2348,7 @@ var spine;
|
||||
__extends(VertexAttachment, _super);
|
||||
function VertexAttachment(name) {
|
||||
_super.call(this, name);
|
||||
this.id = (VertexAttachment.nextID++ & 65535) << 11;
|
||||
this.worldVerticesLength = 0;
|
||||
}
|
||||
VertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) {
|
||||
@ -2334,6 +2413,7 @@ var spine;
|
||||
VertexAttachment.prototype.applyDeform = function (sourceAttachment) {
|
||||
return this == sourceAttachment;
|
||||
};
|
||||
VertexAttachment.nextID = 0;
|
||||
return VertexAttachment;
|
||||
}(Attachment));
|
||||
spine.VertexAttachment = VertexAttachment;
|
||||
|
||||
File diff suppressed because one or more lines are too long
51
spine-ts/build/spine-canvas.d.ts
vendored
51
spine-ts/build/spine-canvas.d.ts
vendored
@ -98,14 +98,23 @@ declare module spine {
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
static binarySearch(values: ArrayLike<number>, target: number, step?: number): number;
|
||||
static linearSearch(values: ArrayLike<number>, target: number, step: number): number;
|
||||
}
|
||||
interface Timeline {
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
getPropertyId(): number;
|
||||
}
|
||||
enum MixPose {
|
||||
setup = 0,
|
||||
current = 1,
|
||||
currentLayered = 2,
|
||||
}
|
||||
enum MixDirection {
|
||||
in = 0,
|
||||
out = 1,
|
||||
}
|
||||
enum TimelineType {
|
||||
rotate = 0,
|
||||
translate = 1,
|
||||
@ -137,7 +146,7 @@ declare module spine {
|
||||
getCurveType(frameIndex: number): number;
|
||||
setCurve(frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void;
|
||||
getCurvePercent(frameIndex: number, percent: number): number;
|
||||
abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class RotateTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -149,7 +158,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, degrees: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class TranslateTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -163,17 +172,17 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, x: number, y: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class ScaleTimeline extends TranslateTimeline {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class ShearTimeline extends TranslateTimeline {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class ColorTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -191,7 +200,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class TwoColorTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -215,7 +224,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class AttachmentTimeline implements Timeline {
|
||||
slotIndex: number;
|
||||
@ -225,7 +234,7 @@ declare module spine {
|
||||
getPropertyId(): number;
|
||||
getFrameCount(): number;
|
||||
setFrame(frameIndex: number, time: number, attachmentName: string): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class DeformTimeline extends CurveTimeline {
|
||||
slotIndex: number;
|
||||
@ -235,7 +244,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class EventTimeline implements Timeline {
|
||||
frames: ArrayLike<number>;
|
||||
@ -244,7 +253,7 @@ declare module spine {
|
||||
getPropertyId(): number;
|
||||
getFrameCount(): number;
|
||||
setFrame(frameIndex: number, event: Event): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class DrawOrderTimeline implements Timeline {
|
||||
frames: ArrayLike<number>;
|
||||
@ -253,7 +262,7 @@ declare module spine {
|
||||
getPropertyId(): number;
|
||||
getFrameCount(): number;
|
||||
setFrame(frameIndex: number, time: number, drawOrder: Array<number>): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class IkConstraintTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -267,7 +276,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, mix: number, bendDirection: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class TransformConstraintTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -285,7 +294,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class PathConstraintPositionTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -297,12 +306,12 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, value: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class PathConstraintSpacingTimeline extends PathConstraintPositionTimeline {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class PathConstraintMixTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -316,7 +325,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
@ -340,8 +349,8 @@ declare module spine {
|
||||
update(delta: number): void;
|
||||
updateMixingFrom(to: TrackEntry, delta: number): boolean;
|
||||
apply(skeleton: Skeleton): boolean;
|
||||
applyMixingFrom(to: TrackEntry, skeleton: Skeleton): number;
|
||||
applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, setupPose: boolean, timelinesRotation: Array<number>, i: number, firstFrame: boolean): void;
|
||||
applyMixingFrom(to: TrackEntry, skeleton: Skeleton, currentPose: MixPose): number;
|
||||
applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, pose: MixPose, timelinesRotation: Array<number>, i: number, firstFrame: boolean): void;
|
||||
queueEvents(entry: TrackEntry, animationTime: number): void;
|
||||
clearTracks(): void;
|
||||
clearTrack(trackIndex: number): void;
|
||||
@ -467,6 +476,8 @@ declare module spine {
|
||||
constructor(name: string);
|
||||
}
|
||||
abstract class VertexAttachment extends Attachment {
|
||||
private static nextID;
|
||||
id: number;
|
||||
bones: Array<number>;
|
||||
vertices: ArrayLike<number>;
|
||||
worldVerticesLength: number;
|
||||
|
||||
@ -463,7 +463,7 @@ var spine;
|
||||
this.timelines = timelines;
|
||||
this.duration = duration;
|
||||
}
|
||||
Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, setupPose, mixingOut) {
|
||||
Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, pose, direction) {
|
||||
if (skeleton == null)
|
||||
throw new Error("skeleton cannot be null.");
|
||||
if (loop && this.duration != 0) {
|
||||
@ -473,7 +473,7 @@ var spine;
|
||||
}
|
||||
var timelines = this.timelines;
|
||||
for (var i = 0, n = timelines.length; i < n; i++)
|
||||
timelines[i].apply(skeleton, lastTime, time, events, alpha, setupPose, mixingOut);
|
||||
timelines[i].apply(skeleton, lastTime, time, events, alpha, pose, direction);
|
||||
};
|
||||
Animation.binarySearch = function (values, target, step) {
|
||||
if (step === void 0) { step = 1; }
|
||||
@ -501,6 +501,17 @@ var spine;
|
||||
return Animation;
|
||||
}());
|
||||
spine.Animation = Animation;
|
||||
(function (MixPose) {
|
||||
MixPose[MixPose["setup"] = 0] = "setup";
|
||||
MixPose[MixPose["current"] = 1] = "current";
|
||||
MixPose[MixPose["currentLayered"] = 2] = "currentLayered";
|
||||
})(spine.MixPose || (spine.MixPose = {}));
|
||||
var MixPose = spine.MixPose;
|
||||
(function (MixDirection) {
|
||||
MixDirection[MixDirection["in"] = 0] = "in";
|
||||
MixDirection[MixDirection["out"] = 1] = "out";
|
||||
})(spine.MixDirection || (spine.MixDirection = {}));
|
||||
var MixDirection = spine.MixDirection;
|
||||
(function (TimelineType) {
|
||||
TimelineType[TimelineType["rotate"] = 0] = "rotate";
|
||||
TimelineType[TimelineType["translate"] = 1] = "translate";
|
||||
@ -615,21 +626,28 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.frames[frameIndex + RotateTimeline.ROTATION] = degrees;
|
||||
};
|
||||
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
bone.rotation = bone.data.rotation;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.rotation = bone.data.rotation;
|
||||
return;
|
||||
case MixPose.current:
|
||||
var r_1 = bone.data.rotation - bone.rotation;
|
||||
r_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360;
|
||||
bone.rotation += r_1 * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha;
|
||||
else {
|
||||
var r_1 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation;
|
||||
r_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360;
|
||||
bone.rotation += r_1 * alpha;
|
||||
var r_2 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation;
|
||||
r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360;
|
||||
bone.rotation += r_2 * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -640,7 +658,7 @@ var spine;
|
||||
var r = frames[frame + RotateTimeline.ROTATION] - prevRotation;
|
||||
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
|
||||
r = prevRotation + r * percent;
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
|
||||
bone.rotation = bone.data.rotation + r * alpha;
|
||||
}
|
||||
@ -672,13 +690,18 @@ var spine;
|
||||
this.frames[frameIndex + TranslateTimeline.X] = x;
|
||||
this.frames[frameIndex + TranslateTimeline.Y] = y;
|
||||
};
|
||||
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
bone.x = bone.data.x;
|
||||
bone.y = bone.data.y;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.x = bone.data.x;
|
||||
bone.y = bone.data.y;
|
||||
return;
|
||||
case MixPose.current:
|
||||
bone.x += (bone.data.x - bone.x) * alpha;
|
||||
bone.y += (bone.data.y - bone.y) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -696,7 +719,7 @@ var spine;
|
||||
x += (frames[frame + TranslateTimeline.X] - x) * percent;
|
||||
y += (frames[frame + TranslateTimeline.Y] - y) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
bone.x = bone.data.x + x * alpha;
|
||||
bone.y = bone.data.y + y * alpha;
|
||||
}
|
||||
@ -722,13 +745,18 @@ var spine;
|
||||
ScaleTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.scale << 24) + this.boneIndex;
|
||||
};
|
||||
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
bone.scaleX = bone.data.scaleX;
|
||||
bone.scaleY = bone.data.scaleY;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.scaleX = bone.data.scaleX;
|
||||
bone.scaleY = bone.data.scaleY;
|
||||
return;
|
||||
case MixPose.current:
|
||||
bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;
|
||||
bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -752,7 +780,7 @@ var spine;
|
||||
}
|
||||
else {
|
||||
var bx = 0, by = 0;
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
bx = bone.data.scaleX;
|
||||
by = bone.data.scaleY;
|
||||
}
|
||||
@ -760,7 +788,7 @@ var spine;
|
||||
bx = bone.scaleX;
|
||||
by = bone.scaleY;
|
||||
}
|
||||
if (mixingOut) {
|
||||
if (direction == MixDirection.out) {
|
||||
x = Math.abs(x) * spine.MathUtils.signum(bx);
|
||||
y = Math.abs(y) * spine.MathUtils.signum(by);
|
||||
}
|
||||
@ -783,13 +811,18 @@ var spine;
|
||||
ShearTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.shear << 24) + this.boneIndex;
|
||||
};
|
||||
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
bone.shearX = bone.data.shearX;
|
||||
bone.shearY = bone.data.shearY;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.shearX = bone.data.shearX;
|
||||
bone.shearY = bone.data.shearY;
|
||||
return;
|
||||
case MixPose.current:
|
||||
bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
|
||||
bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -807,7 +840,7 @@ var spine;
|
||||
x = x + (frames[frame + ShearTimeline.X] - x) * percent;
|
||||
y = y + (frames[frame + ShearTimeline.Y] - y) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
bone.shearX = bone.data.shearX + x * alpha;
|
||||
bone.shearY = bone.data.shearY + y * alpha;
|
||||
}
|
||||
@ -836,12 +869,18 @@ var spine;
|
||||
this.frames[frameIndex + ColorTimeline.B] = b;
|
||||
this.frames[frameIndex + ColorTimeline.A] = a;
|
||||
};
|
||||
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
return;
|
||||
case MixPose.current:
|
||||
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);
|
||||
}
|
||||
return;
|
||||
}
|
||||
var r = 0, g = 0, b = 0, a = 0;
|
||||
@ -869,7 +908,7 @@ var spine;
|
||||
slot.color.set(r, g, b, a);
|
||||
else {
|
||||
var color = slot.color;
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
color.setFromColor(slot.data.color);
|
||||
color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
|
||||
}
|
||||
@ -907,13 +946,19 @@ var spine;
|
||||
this.frames[frameIndex + TwoColorTimeline.G2] = g2;
|
||||
this.frames[frameIndex + TwoColorTimeline.B2] = b2;
|
||||
};
|
||||
TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
slot.darkColor.setFromColor(slot.data.darkColor);
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
slot.darkColor.setFromColor(slot.data.darkColor);
|
||||
return;
|
||||
case MixPose.current:
|
||||
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);
|
||||
dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -952,9 +997,8 @@ var spine;
|
||||
slot.darkColor.set(r2, g2, b2, 1);
|
||||
}
|
||||
else {
|
||||
var light = slot.color;
|
||||
var dark = slot.darkColor;
|
||||
if (setupPose) {
|
||||
var light = slot.color, dark = slot.darkColor;
|
||||
if (pose == MixPose.setup) {
|
||||
light.setFromColor(slot.data.color);
|
||||
dark.setFromColor(slot.data.darkColor);
|
||||
}
|
||||
@ -996,16 +1040,16 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.attachmentNames[frameIndex] = attachmentName;
|
||||
};
|
||||
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
if (mixingOut && setupPose) {
|
||||
if (direction == MixDirection.out && pose == MixPose.setup) {
|
||||
var attachmentName_1 = slot.data.attachmentName;
|
||||
slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1));
|
||||
return;
|
||||
}
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
var attachmentName_2 = slot.data.attachmentName;
|
||||
slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2));
|
||||
}
|
||||
@ -1031,35 +1075,42 @@ var spine;
|
||||
this.frameVertices = new Array(frameCount);
|
||||
}
|
||||
DeformTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.deform << 24) + this.slotIndex;
|
||||
return (TimelineType.deform << 27) + +this.attachment.id + this.slotIndex;
|
||||
};
|
||||
DeformTimeline.prototype.setFrame = function (frameIndex, time, vertices) {
|
||||
this.frames[frameIndex] = time;
|
||||
this.frameVertices[frameIndex] = vertices;
|
||||
};
|
||||
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var slotAttachment = slot.getAttachment();
|
||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
||||
return;
|
||||
var frames = this.frames;
|
||||
var verticesArray = slot.attachmentVertices;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
spine.Utils.setArraySize(verticesArray, 0);
|
||||
return;
|
||||
}
|
||||
var frameVertices = this.frameVertices;
|
||||
var vertexCount = frameVertices[0].length;
|
||||
if (verticesArray.length != vertexCount && !setupPose)
|
||||
if (verticesArray.length != vertexCount && pose != MixPose.setup)
|
||||
alpha = 1;
|
||||
var vertices = spine.Utils.setArraySize(verticesArray, vertexCount);
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
verticesArray.length = 0;
|
||||
return;
|
||||
case MixPose.current:
|
||||
alpha = 1 - alpha;
|
||||
for (var i = 0; i < vertexCount; i++)
|
||||
vertices[i] *= alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (time >= frames[frames.length - 1]) {
|
||||
var lastVertices = frameVertices[frames.length - 1];
|
||||
if (alpha == 1) {
|
||||
spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount);
|
||||
}
|
||||
else if (setupPose) {
|
||||
else if (pose == MixPose.setup) {
|
||||
var vertexAttachment = slotAttachment;
|
||||
if (vertexAttachment.bones == null) {
|
||||
var setupVertices = vertexAttachment.vertices;
|
||||
@ -1090,7 +1141,7 @@ var spine;
|
||||
vertices[i] = prev + (nextVertices[i] - prev) * percent;
|
||||
}
|
||||
}
|
||||
else if (setupPose) {
|
||||
else if (pose == MixPose.setup) {
|
||||
var vertexAttachment = slotAttachment;
|
||||
if (vertexAttachment.bones == null) {
|
||||
var setupVertices = vertexAttachment.vertices;
|
||||
@ -1131,13 +1182,13 @@ var spine;
|
||||
this.frames[frameIndex] = event.time;
|
||||
this.events[frameIndex] = event;
|
||||
};
|
||||
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
if (firedEvents == null)
|
||||
return;
|
||||
var frames = this.frames;
|
||||
var frameCount = this.frames.length;
|
||||
if (lastTime > time) {
|
||||
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, setupPose, mixingOut);
|
||||
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, pose, direction);
|
||||
lastTime = -1;
|
||||
}
|
||||
else if (lastTime >= frames[frameCount - 1])
|
||||
@ -1177,16 +1228,16 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.drawOrders[frameIndex] = drawOrder;
|
||||
};
|
||||
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var drawOrder = skeleton.drawOrder;
|
||||
var slots = skeleton.slots;
|
||||
if (mixingOut && setupPose) {
|
||||
if (direction == MixDirection.out && pose == MixPose.setup) {
|
||||
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||
return;
|
||||
}
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||
return;
|
||||
}
|
||||
@ -1221,25 +1272,30 @@ var spine;
|
||||
this.frames[frameIndex + IkConstraintTimeline.MIX] = mix;
|
||||
this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection;
|
||||
};
|
||||
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
constraint.mix = constraint.data.mix;
|
||||
constraint.bendDirection = constraint.data.bendDirection;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.mix = constraint.data.mix;
|
||||
constraint.bendDirection = constraint.data.bendDirection;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.mix += (constraint.data.mix - constraint.mix) * alpha;
|
||||
constraint.bendDirection = constraint.data.bendDirection;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
|
||||
constraint.bendDirection = mixingOut ? constraint.data.bendDirection
|
||||
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection
|
||||
: frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
else {
|
||||
constraint.mix += (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.mix) * alpha;
|
||||
if (!mixingOut)
|
||||
if (direction == MixDirection.in)
|
||||
constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
return;
|
||||
@ -1248,13 +1304,13 @@ var spine;
|
||||
var mix = frames[frame + IkConstraintTimeline.PREV_MIX];
|
||||
var frameTime = frames[frame];
|
||||
var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime));
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha;
|
||||
constraint.bendDirection = mixingOut ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
else {
|
||||
constraint.mix += (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.mix) * alpha;
|
||||
if (!mixingOut)
|
||||
if (direction == MixDirection.in)
|
||||
constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
};
|
||||
@ -1284,16 +1340,23 @@ var spine;
|
||||
this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix;
|
||||
this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix;
|
||||
};
|
||||
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
var data = constraint.data;
|
||||
constraint.rotateMix = data.rotateMix;
|
||||
constraint.translateMix = data.rotateMix;
|
||||
constraint.scaleMix = data.scaleMix;
|
||||
constraint.shearMix = data.shearMix;
|
||||
var data = constraint.data;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.rotateMix = data.rotateMix;
|
||||
constraint.translateMix = data.translateMix;
|
||||
constraint.scaleMix = data.scaleMix;
|
||||
constraint.shearMix = data.shearMix;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha;
|
||||
constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha;
|
||||
constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha;
|
||||
constraint.shearMix += (data.shearMix - constraint.shearMix) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1318,7 +1381,7 @@ var spine;
|
||||
scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent;
|
||||
shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
var data = constraint.data;
|
||||
constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha;
|
||||
constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha;
|
||||
@ -1359,12 +1422,17 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value;
|
||||
};
|
||||
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
constraint.position = constraint.data.position;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.position = constraint.data.position;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.position += (constraint.data.position - constraint.position) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
var position = 0;
|
||||
@ -1377,7 +1445,7 @@ var spine;
|
||||
var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime));
|
||||
position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent;
|
||||
}
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
constraint.position = constraint.data.position + (position - constraint.data.position) * alpha;
|
||||
else
|
||||
constraint.position += (position - constraint.position) * alpha;
|
||||
@ -1397,12 +1465,17 @@ var spine;
|
||||
PathConstraintSpacingTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex;
|
||||
};
|
||||
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
constraint.spacing = constraint.data.spacing;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.spacing = constraint.data.spacing;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
var spacing = 0;
|
||||
@ -1415,7 +1488,7 @@ var spine;
|
||||
var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime));
|
||||
spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent;
|
||||
}
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;
|
||||
else
|
||||
constraint.spacing += (spacing - constraint.spacing) * alpha;
|
||||
@ -1438,13 +1511,18 @@ var spine;
|
||||
this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix;
|
||||
this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix;
|
||||
};
|
||||
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
constraint.rotateMix = constraint.data.rotateMix;
|
||||
constraint.translateMix = constraint.data.translateMix;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.rotateMix = constraint.data.rotateMix;
|
||||
constraint.translateMix = constraint.data.translateMix;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha;
|
||||
constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1462,7 +1540,7 @@ var spine;
|
||||
rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent;
|
||||
translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha;
|
||||
constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha;
|
||||
}
|
||||
@ -1578,9 +1656,10 @@ var spine;
|
||||
if (current == null || current.delay > 0)
|
||||
continue;
|
||||
applied = true;
|
||||
var currentPose = i == 0 ? spine.MixPose.current : spine.MixPose.currentLayered;
|
||||
var mix = current.alpha;
|
||||
if (current.mixingFrom != null)
|
||||
mix *= this.applyMixingFrom(current, skeleton);
|
||||
mix *= this.applyMixingFrom(current, skeleton, currentPose);
|
||||
else if (current.trackTime >= current.trackEnd && current.next == null)
|
||||
mix = 0;
|
||||
var animationLast = current.animationLast, animationTime = current.getAnimationTime();
|
||||
@ -1588,7 +1667,7 @@ var spine;
|
||||
var timelines = current.animation.timelines;
|
||||
if (mix == 1) {
|
||||
for (var ii = 0; ii < timelineCount; ii++)
|
||||
timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, true, false);
|
||||
timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, spine.MixPose.setup, spine.MixDirection.in);
|
||||
}
|
||||
else {
|
||||
var timelineData = current.timelineData;
|
||||
@ -1598,11 +1677,12 @@ var spine;
|
||||
var timelinesRotation = current.timelinesRotation;
|
||||
for (var ii = 0; ii < timelineCount; ii++) {
|
||||
var timeline = timelines[ii];
|
||||
var pose = timelineData[ii] >= AnimationState.FIRST ? spine.MixPose.setup : currentPose;
|
||||
if (timeline instanceof spine.RotateTimeline) {
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineData[ii] >= AnimationState.FIRST, timelinesRotation, ii << 1, firstFrame);
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, mix, pose, timelinesRotation, ii << 1, firstFrame);
|
||||
}
|
||||
else
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineData[ii] >= AnimationState.FIRST, false);
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, mix, pose, spine.MixDirection.in);
|
||||
}
|
||||
}
|
||||
this.queueEvents(current, animationTime);
|
||||
@ -1613,10 +1693,10 @@ var spine;
|
||||
this.queue.drain();
|
||||
return applied;
|
||||
};
|
||||
AnimationState.prototype.applyMixingFrom = function (to, skeleton) {
|
||||
AnimationState.prototype.applyMixingFrom = function (to, skeleton, currentPose) {
|
||||
var from = to.mixingFrom;
|
||||
if (from.mixingFrom != null)
|
||||
this.applyMixingFrom(from, skeleton);
|
||||
this.applyMixingFrom(from, skeleton, currentPose);
|
||||
var mix = 0;
|
||||
if (to.mixDuration == 0)
|
||||
mix = 1;
|
||||
@ -1636,26 +1716,30 @@ var spine;
|
||||
if (firstFrame)
|
||||
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
|
||||
var timelinesRotation = from.timelinesRotation;
|
||||
var first = false;
|
||||
var pose;
|
||||
var alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix), alpha = 0;
|
||||
from.totalAlpha = 0;
|
||||
for (var i = 0; i < timelineCount; i++) {
|
||||
var timeline = timelines[i];
|
||||
switch (timelineData[i]) {
|
||||
case AnimationState.SUBSEQUENT:
|
||||
first = false;
|
||||
if (!attachments && timeline instanceof spine.AttachmentTimeline)
|
||||
continue;
|
||||
if (!drawOrder && timeline instanceof spine.DrawOrderTimeline)
|
||||
continue;
|
||||
pose = currentPose;
|
||||
alpha = alphaMix;
|
||||
break;
|
||||
case AnimationState.FIRST:
|
||||
first = true;
|
||||
pose = spine.MixPose.setup;
|
||||
alpha = alphaMix;
|
||||
break;
|
||||
case AnimationState.DIP:
|
||||
first = true;
|
||||
pose = spine.MixPose.setup;
|
||||
alpha = alphaDip;
|
||||
break;
|
||||
default:
|
||||
first = true;
|
||||
pose = spine.MixPose.setup;
|
||||
alpha = alphaDip;
|
||||
var dipMix = timelineDipMix[i];
|
||||
alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
|
||||
@ -1663,15 +1747,9 @@ var spine;
|
||||
}
|
||||
from.totalAlpha += alpha;
|
||||
if (timeline instanceof spine.RotateTimeline)
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, first, timelinesRotation, i << 1, firstFrame);
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame);
|
||||
else {
|
||||
if (!first) {
|
||||
if (!attachments && timeline instanceof spine.AttachmentTimeline)
|
||||
continue;
|
||||
if (!drawOrder && timeline instanceof spine.DrawOrderTimeline)
|
||||
continue;
|
||||
}
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, alpha, first, true);
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, alpha, pose, spine.MixDirection.out);
|
||||
}
|
||||
}
|
||||
if (to.mixDuration > 0)
|
||||
@ -1681,18 +1759,18 @@ var spine;
|
||||
from.nextTrackLast = from.trackTime;
|
||||
return mix;
|
||||
};
|
||||
AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, setupPose, timelinesRotation, i, firstFrame) {
|
||||
AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, pose, timelinesRotation, i, firstFrame) {
|
||||
if (firstFrame)
|
||||
timelinesRotation[i] = 0;
|
||||
if (alpha == 1) {
|
||||
timeline.apply(skeleton, 0, time, null, 1, setupPose, false);
|
||||
timeline.apply(skeleton, 0, time, null, 1, pose, spine.MixDirection.in);
|
||||
return;
|
||||
}
|
||||
var rotateTimeline = timeline;
|
||||
var frames = rotateTimeline.frames;
|
||||
var bone = skeleton.bones[rotateTimeline.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
if (pose == spine.MixPose.setup)
|
||||
bone.rotation = bone.data.rotation;
|
||||
return;
|
||||
}
|
||||
@ -1709,7 +1787,7 @@ var spine;
|
||||
r2 = prevRotation + r2 * percent + bone.data.rotation;
|
||||
r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
|
||||
}
|
||||
var r1 = setupPose ? bone.data.rotation : bone.rotation;
|
||||
var r1 = pose == spine.MixPose.setup ? bone.data.rotation : bone.rotation;
|
||||
var total = 0, diff = r2 - r1;
|
||||
if (diff == 0) {
|
||||
total = timelinesRotation[i];
|
||||
@ -2270,6 +2348,7 @@ var spine;
|
||||
__extends(VertexAttachment, _super);
|
||||
function VertexAttachment(name) {
|
||||
_super.call(this, name);
|
||||
this.id = (VertexAttachment.nextID++ & 65535) << 11;
|
||||
this.worldVerticesLength = 0;
|
||||
}
|
||||
VertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) {
|
||||
@ -2334,6 +2413,7 @@ var spine;
|
||||
VertexAttachment.prototype.applyDeform = function (sourceAttachment) {
|
||||
return this == sourceAttachment;
|
||||
};
|
||||
VertexAttachment.nextID = 0;
|
||||
return VertexAttachment;
|
||||
}(Attachment));
|
||||
spine.VertexAttachment = VertexAttachment;
|
||||
|
||||
File diff suppressed because one or more lines are too long
51
spine-ts/build/spine-core.d.ts
vendored
51
spine-ts/build/spine-core.d.ts
vendored
@ -4,14 +4,23 @@ declare module spine {
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
static binarySearch(values: ArrayLike<number>, target: number, step?: number): number;
|
||||
static linearSearch(values: ArrayLike<number>, target: number, step: number): number;
|
||||
}
|
||||
interface Timeline {
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
getPropertyId(): number;
|
||||
}
|
||||
enum MixPose {
|
||||
setup = 0,
|
||||
current = 1,
|
||||
currentLayered = 2,
|
||||
}
|
||||
enum MixDirection {
|
||||
in = 0,
|
||||
out = 1,
|
||||
}
|
||||
enum TimelineType {
|
||||
rotate = 0,
|
||||
translate = 1,
|
||||
@ -43,7 +52,7 @@ declare module spine {
|
||||
getCurveType(frameIndex: number): number;
|
||||
setCurve(frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void;
|
||||
getCurvePercent(frameIndex: number, percent: number): number;
|
||||
abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class RotateTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -55,7 +64,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, degrees: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class TranslateTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -69,17 +78,17 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, x: number, y: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class ScaleTimeline extends TranslateTimeline {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class ShearTimeline extends TranslateTimeline {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class ColorTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -97,7 +106,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class TwoColorTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -121,7 +130,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class AttachmentTimeline implements Timeline {
|
||||
slotIndex: number;
|
||||
@ -131,7 +140,7 @@ declare module spine {
|
||||
getPropertyId(): number;
|
||||
getFrameCount(): number;
|
||||
setFrame(frameIndex: number, time: number, attachmentName: string): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class DeformTimeline extends CurveTimeline {
|
||||
slotIndex: number;
|
||||
@ -141,7 +150,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class EventTimeline implements Timeline {
|
||||
frames: ArrayLike<number>;
|
||||
@ -150,7 +159,7 @@ declare module spine {
|
||||
getPropertyId(): number;
|
||||
getFrameCount(): number;
|
||||
setFrame(frameIndex: number, event: Event): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class DrawOrderTimeline implements Timeline {
|
||||
frames: ArrayLike<number>;
|
||||
@ -159,7 +168,7 @@ declare module spine {
|
||||
getPropertyId(): number;
|
||||
getFrameCount(): number;
|
||||
setFrame(frameIndex: number, time: number, drawOrder: Array<number>): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class IkConstraintTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -173,7 +182,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, mix: number, bendDirection: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class TransformConstraintTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -191,7 +200,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class PathConstraintPositionTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -203,12 +212,12 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, value: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class PathConstraintSpacingTimeline extends PathConstraintPositionTimeline {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class PathConstraintMixTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -222,7 +231,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
@ -246,8 +255,8 @@ declare module spine {
|
||||
update(delta: number): void;
|
||||
updateMixingFrom(to: TrackEntry, delta: number): boolean;
|
||||
apply(skeleton: Skeleton): boolean;
|
||||
applyMixingFrom(to: TrackEntry, skeleton: Skeleton): number;
|
||||
applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, setupPose: boolean, timelinesRotation: Array<number>, i: number, firstFrame: boolean): void;
|
||||
applyMixingFrom(to: TrackEntry, skeleton: Skeleton, currentPose: MixPose): number;
|
||||
applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, pose: MixPose, timelinesRotation: Array<number>, i: number, firstFrame: boolean): void;
|
||||
queueEvents(entry: TrackEntry, animationTime: number): void;
|
||||
clearTracks(): void;
|
||||
clearTrack(trackIndex: number): void;
|
||||
@ -396,6 +405,8 @@ declare module spine {
|
||||
constructor(name: string);
|
||||
}
|
||||
abstract class VertexAttachment extends Attachment {
|
||||
private static nextID;
|
||||
id: number;
|
||||
bones: Array<number>;
|
||||
vertices: ArrayLike<number>;
|
||||
worldVerticesLength: number;
|
||||
|
||||
@ -15,7 +15,7 @@ var spine;
|
||||
this.timelines = timelines;
|
||||
this.duration = duration;
|
||||
}
|
||||
Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, setupPose, mixingOut) {
|
||||
Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, pose, direction) {
|
||||
if (skeleton == null)
|
||||
throw new Error("skeleton cannot be null.");
|
||||
if (loop && this.duration != 0) {
|
||||
@ -25,7 +25,7 @@ var spine;
|
||||
}
|
||||
var timelines = this.timelines;
|
||||
for (var i = 0, n = timelines.length; i < n; i++)
|
||||
timelines[i].apply(skeleton, lastTime, time, events, alpha, setupPose, mixingOut);
|
||||
timelines[i].apply(skeleton, lastTime, time, events, alpha, pose, direction);
|
||||
};
|
||||
Animation.binarySearch = function (values, target, step) {
|
||||
if (step === void 0) { step = 1; }
|
||||
@ -53,6 +53,17 @@ var spine;
|
||||
return Animation;
|
||||
}());
|
||||
spine.Animation = Animation;
|
||||
(function (MixPose) {
|
||||
MixPose[MixPose["setup"] = 0] = "setup";
|
||||
MixPose[MixPose["current"] = 1] = "current";
|
||||
MixPose[MixPose["currentLayered"] = 2] = "currentLayered";
|
||||
})(spine.MixPose || (spine.MixPose = {}));
|
||||
var MixPose = spine.MixPose;
|
||||
(function (MixDirection) {
|
||||
MixDirection[MixDirection["in"] = 0] = "in";
|
||||
MixDirection[MixDirection["out"] = 1] = "out";
|
||||
})(spine.MixDirection || (spine.MixDirection = {}));
|
||||
var MixDirection = spine.MixDirection;
|
||||
(function (TimelineType) {
|
||||
TimelineType[TimelineType["rotate"] = 0] = "rotate";
|
||||
TimelineType[TimelineType["translate"] = 1] = "translate";
|
||||
@ -167,21 +178,28 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.frames[frameIndex + RotateTimeline.ROTATION] = degrees;
|
||||
};
|
||||
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
bone.rotation = bone.data.rotation;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.rotation = bone.data.rotation;
|
||||
return;
|
||||
case MixPose.current:
|
||||
var r_1 = bone.data.rotation - bone.rotation;
|
||||
r_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360;
|
||||
bone.rotation += r_1 * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha;
|
||||
else {
|
||||
var r_1 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation;
|
||||
r_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360;
|
||||
bone.rotation += r_1 * alpha;
|
||||
var r_2 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation;
|
||||
r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360;
|
||||
bone.rotation += r_2 * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -192,7 +210,7 @@ var spine;
|
||||
var r = frames[frame + RotateTimeline.ROTATION] - prevRotation;
|
||||
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
|
||||
r = prevRotation + r * percent;
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
|
||||
bone.rotation = bone.data.rotation + r * alpha;
|
||||
}
|
||||
@ -224,13 +242,18 @@ var spine;
|
||||
this.frames[frameIndex + TranslateTimeline.X] = x;
|
||||
this.frames[frameIndex + TranslateTimeline.Y] = y;
|
||||
};
|
||||
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
bone.x = bone.data.x;
|
||||
bone.y = bone.data.y;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.x = bone.data.x;
|
||||
bone.y = bone.data.y;
|
||||
return;
|
||||
case MixPose.current:
|
||||
bone.x += (bone.data.x - bone.x) * alpha;
|
||||
bone.y += (bone.data.y - bone.y) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -248,7 +271,7 @@ var spine;
|
||||
x += (frames[frame + TranslateTimeline.X] - x) * percent;
|
||||
y += (frames[frame + TranslateTimeline.Y] - y) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
bone.x = bone.data.x + x * alpha;
|
||||
bone.y = bone.data.y + y * alpha;
|
||||
}
|
||||
@ -274,13 +297,18 @@ var spine;
|
||||
ScaleTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.scale << 24) + this.boneIndex;
|
||||
};
|
||||
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
bone.scaleX = bone.data.scaleX;
|
||||
bone.scaleY = bone.data.scaleY;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.scaleX = bone.data.scaleX;
|
||||
bone.scaleY = bone.data.scaleY;
|
||||
return;
|
||||
case MixPose.current:
|
||||
bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;
|
||||
bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -304,7 +332,7 @@ var spine;
|
||||
}
|
||||
else {
|
||||
var bx = 0, by = 0;
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
bx = bone.data.scaleX;
|
||||
by = bone.data.scaleY;
|
||||
}
|
||||
@ -312,7 +340,7 @@ var spine;
|
||||
bx = bone.scaleX;
|
||||
by = bone.scaleY;
|
||||
}
|
||||
if (mixingOut) {
|
||||
if (direction == MixDirection.out) {
|
||||
x = Math.abs(x) * spine.MathUtils.signum(bx);
|
||||
y = Math.abs(y) * spine.MathUtils.signum(by);
|
||||
}
|
||||
@ -335,13 +363,18 @@ var spine;
|
||||
ShearTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.shear << 24) + this.boneIndex;
|
||||
};
|
||||
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
bone.shearX = bone.data.shearX;
|
||||
bone.shearY = bone.data.shearY;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.shearX = bone.data.shearX;
|
||||
bone.shearY = bone.data.shearY;
|
||||
return;
|
||||
case MixPose.current:
|
||||
bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
|
||||
bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -359,7 +392,7 @@ var spine;
|
||||
x = x + (frames[frame + ShearTimeline.X] - x) * percent;
|
||||
y = y + (frames[frame + ShearTimeline.Y] - y) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
bone.shearX = bone.data.shearX + x * alpha;
|
||||
bone.shearY = bone.data.shearY + y * alpha;
|
||||
}
|
||||
@ -388,12 +421,18 @@ var spine;
|
||||
this.frames[frameIndex + ColorTimeline.B] = b;
|
||||
this.frames[frameIndex + ColorTimeline.A] = a;
|
||||
};
|
||||
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
return;
|
||||
case MixPose.current:
|
||||
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);
|
||||
}
|
||||
return;
|
||||
}
|
||||
var r = 0, g = 0, b = 0, a = 0;
|
||||
@ -421,7 +460,7 @@ var spine;
|
||||
slot.color.set(r, g, b, a);
|
||||
else {
|
||||
var color = slot.color;
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
color.setFromColor(slot.data.color);
|
||||
color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
|
||||
}
|
||||
@ -459,13 +498,19 @@ var spine;
|
||||
this.frames[frameIndex + TwoColorTimeline.G2] = g2;
|
||||
this.frames[frameIndex + TwoColorTimeline.B2] = b2;
|
||||
};
|
||||
TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
slot.darkColor.setFromColor(slot.data.darkColor);
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
slot.darkColor.setFromColor(slot.data.darkColor);
|
||||
return;
|
||||
case MixPose.current:
|
||||
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);
|
||||
dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -504,9 +549,8 @@ var spine;
|
||||
slot.darkColor.set(r2, g2, b2, 1);
|
||||
}
|
||||
else {
|
||||
var light = slot.color;
|
||||
var dark = slot.darkColor;
|
||||
if (setupPose) {
|
||||
var light = slot.color, dark = slot.darkColor;
|
||||
if (pose == MixPose.setup) {
|
||||
light.setFromColor(slot.data.color);
|
||||
dark.setFromColor(slot.data.darkColor);
|
||||
}
|
||||
@ -548,16 +592,16 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.attachmentNames[frameIndex] = attachmentName;
|
||||
};
|
||||
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
if (mixingOut && setupPose) {
|
||||
if (direction == MixDirection.out && pose == MixPose.setup) {
|
||||
var attachmentName_1 = slot.data.attachmentName;
|
||||
slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1));
|
||||
return;
|
||||
}
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
var attachmentName_2 = slot.data.attachmentName;
|
||||
slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2));
|
||||
}
|
||||
@ -583,35 +627,42 @@ var spine;
|
||||
this.frameVertices = new Array(frameCount);
|
||||
}
|
||||
DeformTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.deform << 24) + this.slotIndex;
|
||||
return (TimelineType.deform << 27) + +this.attachment.id + this.slotIndex;
|
||||
};
|
||||
DeformTimeline.prototype.setFrame = function (frameIndex, time, vertices) {
|
||||
this.frames[frameIndex] = time;
|
||||
this.frameVertices[frameIndex] = vertices;
|
||||
};
|
||||
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var slotAttachment = slot.getAttachment();
|
||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
||||
return;
|
||||
var frames = this.frames;
|
||||
var verticesArray = slot.attachmentVertices;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
spine.Utils.setArraySize(verticesArray, 0);
|
||||
return;
|
||||
}
|
||||
var frameVertices = this.frameVertices;
|
||||
var vertexCount = frameVertices[0].length;
|
||||
if (verticesArray.length != vertexCount && !setupPose)
|
||||
if (verticesArray.length != vertexCount && pose != MixPose.setup)
|
||||
alpha = 1;
|
||||
var vertices = spine.Utils.setArraySize(verticesArray, vertexCount);
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
verticesArray.length = 0;
|
||||
return;
|
||||
case MixPose.current:
|
||||
alpha = 1 - alpha;
|
||||
for (var i = 0; i < vertexCount; i++)
|
||||
vertices[i] *= alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (time >= frames[frames.length - 1]) {
|
||||
var lastVertices = frameVertices[frames.length - 1];
|
||||
if (alpha == 1) {
|
||||
spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount);
|
||||
}
|
||||
else if (setupPose) {
|
||||
else if (pose == MixPose.setup) {
|
||||
var vertexAttachment = slotAttachment;
|
||||
if (vertexAttachment.bones == null) {
|
||||
var setupVertices = vertexAttachment.vertices;
|
||||
@ -642,7 +693,7 @@ var spine;
|
||||
vertices[i] = prev + (nextVertices[i] - prev) * percent;
|
||||
}
|
||||
}
|
||||
else if (setupPose) {
|
||||
else if (pose == MixPose.setup) {
|
||||
var vertexAttachment = slotAttachment;
|
||||
if (vertexAttachment.bones == null) {
|
||||
var setupVertices = vertexAttachment.vertices;
|
||||
@ -683,13 +734,13 @@ var spine;
|
||||
this.frames[frameIndex] = event.time;
|
||||
this.events[frameIndex] = event;
|
||||
};
|
||||
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
if (firedEvents == null)
|
||||
return;
|
||||
var frames = this.frames;
|
||||
var frameCount = this.frames.length;
|
||||
if (lastTime > time) {
|
||||
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, setupPose, mixingOut);
|
||||
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, pose, direction);
|
||||
lastTime = -1;
|
||||
}
|
||||
else if (lastTime >= frames[frameCount - 1])
|
||||
@ -729,16 +780,16 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.drawOrders[frameIndex] = drawOrder;
|
||||
};
|
||||
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var drawOrder = skeleton.drawOrder;
|
||||
var slots = skeleton.slots;
|
||||
if (mixingOut && setupPose) {
|
||||
if (direction == MixDirection.out && pose == MixPose.setup) {
|
||||
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||
return;
|
||||
}
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||
return;
|
||||
}
|
||||
@ -773,25 +824,30 @@ var spine;
|
||||
this.frames[frameIndex + IkConstraintTimeline.MIX] = mix;
|
||||
this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection;
|
||||
};
|
||||
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
constraint.mix = constraint.data.mix;
|
||||
constraint.bendDirection = constraint.data.bendDirection;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.mix = constraint.data.mix;
|
||||
constraint.bendDirection = constraint.data.bendDirection;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.mix += (constraint.data.mix - constraint.mix) * alpha;
|
||||
constraint.bendDirection = constraint.data.bendDirection;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
|
||||
constraint.bendDirection = mixingOut ? constraint.data.bendDirection
|
||||
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection
|
||||
: frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
else {
|
||||
constraint.mix += (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.mix) * alpha;
|
||||
if (!mixingOut)
|
||||
if (direction == MixDirection.in)
|
||||
constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
return;
|
||||
@ -800,13 +856,13 @@ var spine;
|
||||
var mix = frames[frame + IkConstraintTimeline.PREV_MIX];
|
||||
var frameTime = frames[frame];
|
||||
var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime));
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha;
|
||||
constraint.bendDirection = mixingOut ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
else {
|
||||
constraint.mix += (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.mix) * alpha;
|
||||
if (!mixingOut)
|
||||
if (direction == MixDirection.in)
|
||||
constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
};
|
||||
@ -836,16 +892,23 @@ var spine;
|
||||
this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix;
|
||||
this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix;
|
||||
};
|
||||
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
var data = constraint.data;
|
||||
constraint.rotateMix = data.rotateMix;
|
||||
constraint.translateMix = data.rotateMix;
|
||||
constraint.scaleMix = data.scaleMix;
|
||||
constraint.shearMix = data.shearMix;
|
||||
var data = constraint.data;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.rotateMix = data.rotateMix;
|
||||
constraint.translateMix = data.translateMix;
|
||||
constraint.scaleMix = data.scaleMix;
|
||||
constraint.shearMix = data.shearMix;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha;
|
||||
constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha;
|
||||
constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha;
|
||||
constraint.shearMix += (data.shearMix - constraint.shearMix) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -870,7 +933,7 @@ var spine;
|
||||
scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent;
|
||||
shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
var data = constraint.data;
|
||||
constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha;
|
||||
constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha;
|
||||
@ -911,12 +974,17 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value;
|
||||
};
|
||||
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
constraint.position = constraint.data.position;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.position = constraint.data.position;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.position += (constraint.data.position - constraint.position) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
var position = 0;
|
||||
@ -929,7 +997,7 @@ var spine;
|
||||
var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime));
|
||||
position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent;
|
||||
}
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
constraint.position = constraint.data.position + (position - constraint.data.position) * alpha;
|
||||
else
|
||||
constraint.position += (position - constraint.position) * alpha;
|
||||
@ -949,12 +1017,17 @@ var spine;
|
||||
PathConstraintSpacingTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex;
|
||||
};
|
||||
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
constraint.spacing = constraint.data.spacing;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.spacing = constraint.data.spacing;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
var spacing = 0;
|
||||
@ -967,7 +1040,7 @@ var spine;
|
||||
var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime));
|
||||
spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent;
|
||||
}
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;
|
||||
else
|
||||
constraint.spacing += (spacing - constraint.spacing) * alpha;
|
||||
@ -990,13 +1063,18 @@ var spine;
|
||||
this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix;
|
||||
this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix;
|
||||
};
|
||||
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
constraint.rotateMix = constraint.data.rotateMix;
|
||||
constraint.translateMix = constraint.data.translateMix;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.rotateMix = constraint.data.rotateMix;
|
||||
constraint.translateMix = constraint.data.translateMix;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha;
|
||||
constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1014,7 +1092,7 @@ var spine;
|
||||
rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent;
|
||||
translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha;
|
||||
constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha;
|
||||
}
|
||||
@ -1130,9 +1208,10 @@ var spine;
|
||||
if (current == null || current.delay > 0)
|
||||
continue;
|
||||
applied = true;
|
||||
var currentPose = i == 0 ? spine.MixPose.current : spine.MixPose.currentLayered;
|
||||
var mix = current.alpha;
|
||||
if (current.mixingFrom != null)
|
||||
mix *= this.applyMixingFrom(current, skeleton);
|
||||
mix *= this.applyMixingFrom(current, skeleton, currentPose);
|
||||
else if (current.trackTime >= current.trackEnd && current.next == null)
|
||||
mix = 0;
|
||||
var animationLast = current.animationLast, animationTime = current.getAnimationTime();
|
||||
@ -1140,7 +1219,7 @@ var spine;
|
||||
var timelines = current.animation.timelines;
|
||||
if (mix == 1) {
|
||||
for (var ii = 0; ii < timelineCount; ii++)
|
||||
timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, true, false);
|
||||
timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, spine.MixPose.setup, spine.MixDirection.in);
|
||||
}
|
||||
else {
|
||||
var timelineData = current.timelineData;
|
||||
@ -1150,11 +1229,12 @@ var spine;
|
||||
var timelinesRotation = current.timelinesRotation;
|
||||
for (var ii = 0; ii < timelineCount; ii++) {
|
||||
var timeline = timelines[ii];
|
||||
var pose = timelineData[ii] >= AnimationState.FIRST ? spine.MixPose.setup : currentPose;
|
||||
if (timeline instanceof spine.RotateTimeline) {
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineData[ii] >= AnimationState.FIRST, timelinesRotation, ii << 1, firstFrame);
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, mix, pose, timelinesRotation, ii << 1, firstFrame);
|
||||
}
|
||||
else
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineData[ii] >= AnimationState.FIRST, false);
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, mix, pose, spine.MixDirection.in);
|
||||
}
|
||||
}
|
||||
this.queueEvents(current, animationTime);
|
||||
@ -1165,10 +1245,10 @@ var spine;
|
||||
this.queue.drain();
|
||||
return applied;
|
||||
};
|
||||
AnimationState.prototype.applyMixingFrom = function (to, skeleton) {
|
||||
AnimationState.prototype.applyMixingFrom = function (to, skeleton, currentPose) {
|
||||
var from = to.mixingFrom;
|
||||
if (from.mixingFrom != null)
|
||||
this.applyMixingFrom(from, skeleton);
|
||||
this.applyMixingFrom(from, skeleton, currentPose);
|
||||
var mix = 0;
|
||||
if (to.mixDuration == 0)
|
||||
mix = 1;
|
||||
@ -1188,26 +1268,30 @@ var spine;
|
||||
if (firstFrame)
|
||||
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
|
||||
var timelinesRotation = from.timelinesRotation;
|
||||
var first = false;
|
||||
var pose;
|
||||
var alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix), alpha = 0;
|
||||
from.totalAlpha = 0;
|
||||
for (var i = 0; i < timelineCount; i++) {
|
||||
var timeline = timelines[i];
|
||||
switch (timelineData[i]) {
|
||||
case AnimationState.SUBSEQUENT:
|
||||
first = false;
|
||||
if (!attachments && timeline instanceof spine.AttachmentTimeline)
|
||||
continue;
|
||||
if (!drawOrder && timeline instanceof spine.DrawOrderTimeline)
|
||||
continue;
|
||||
pose = currentPose;
|
||||
alpha = alphaMix;
|
||||
break;
|
||||
case AnimationState.FIRST:
|
||||
first = true;
|
||||
pose = spine.MixPose.setup;
|
||||
alpha = alphaMix;
|
||||
break;
|
||||
case AnimationState.DIP:
|
||||
first = true;
|
||||
pose = spine.MixPose.setup;
|
||||
alpha = alphaDip;
|
||||
break;
|
||||
default:
|
||||
first = true;
|
||||
pose = spine.MixPose.setup;
|
||||
alpha = alphaDip;
|
||||
var dipMix = timelineDipMix[i];
|
||||
alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
|
||||
@ -1215,15 +1299,9 @@ var spine;
|
||||
}
|
||||
from.totalAlpha += alpha;
|
||||
if (timeline instanceof spine.RotateTimeline)
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, first, timelinesRotation, i << 1, firstFrame);
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame);
|
||||
else {
|
||||
if (!first) {
|
||||
if (!attachments && timeline instanceof spine.AttachmentTimeline)
|
||||
continue;
|
||||
if (!drawOrder && timeline instanceof spine.DrawOrderTimeline)
|
||||
continue;
|
||||
}
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, alpha, first, true);
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, alpha, pose, spine.MixDirection.out);
|
||||
}
|
||||
}
|
||||
if (to.mixDuration > 0)
|
||||
@ -1233,18 +1311,18 @@ var spine;
|
||||
from.nextTrackLast = from.trackTime;
|
||||
return mix;
|
||||
};
|
||||
AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, setupPose, timelinesRotation, i, firstFrame) {
|
||||
AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, pose, timelinesRotation, i, firstFrame) {
|
||||
if (firstFrame)
|
||||
timelinesRotation[i] = 0;
|
||||
if (alpha == 1) {
|
||||
timeline.apply(skeleton, 0, time, null, 1, setupPose, false);
|
||||
timeline.apply(skeleton, 0, time, null, 1, pose, spine.MixDirection.in);
|
||||
return;
|
||||
}
|
||||
var rotateTimeline = timeline;
|
||||
var frames = rotateTimeline.frames;
|
||||
var bone = skeleton.bones[rotateTimeline.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
if (pose == spine.MixPose.setup)
|
||||
bone.rotation = bone.data.rotation;
|
||||
return;
|
||||
}
|
||||
@ -1261,7 +1339,7 @@ var spine;
|
||||
r2 = prevRotation + r2 * percent + bone.data.rotation;
|
||||
r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
|
||||
}
|
||||
var r1 = setupPose ? bone.data.rotation : bone.rotation;
|
||||
var r1 = pose == spine.MixPose.setup ? bone.data.rotation : bone.rotation;
|
||||
var total = 0, diff = r2 - r1;
|
||||
if (diff == 0) {
|
||||
total = timelinesRotation[i];
|
||||
@ -1950,6 +2028,7 @@ var spine;
|
||||
__extends(VertexAttachment, _super);
|
||||
function VertexAttachment(name) {
|
||||
_super.call(this, name);
|
||||
this.id = (VertexAttachment.nextID++ & 65535) << 11;
|
||||
this.worldVerticesLength = 0;
|
||||
}
|
||||
VertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) {
|
||||
@ -2014,6 +2093,7 @@ var spine;
|
||||
VertexAttachment.prototype.applyDeform = function (sourceAttachment) {
|
||||
return this == sourceAttachment;
|
||||
};
|
||||
VertexAttachment.nextID = 0;
|
||||
return VertexAttachment;
|
||||
}(Attachment));
|
||||
spine.VertexAttachment = VertexAttachment;
|
||||
|
||||
File diff suppressed because one or more lines are too long
51
spine-ts/build/spine-threejs.d.ts
vendored
51
spine-ts/build/spine-threejs.d.ts
vendored
@ -4,14 +4,23 @@ declare module spine {
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
static binarySearch(values: ArrayLike<number>, target: number, step?: number): number;
|
||||
static linearSearch(values: ArrayLike<number>, target: number, step: number): number;
|
||||
}
|
||||
interface Timeline {
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
getPropertyId(): number;
|
||||
}
|
||||
enum MixPose {
|
||||
setup = 0,
|
||||
current = 1,
|
||||
currentLayered = 2,
|
||||
}
|
||||
enum MixDirection {
|
||||
in = 0,
|
||||
out = 1,
|
||||
}
|
||||
enum TimelineType {
|
||||
rotate = 0,
|
||||
translate = 1,
|
||||
@ -43,7 +52,7 @@ declare module spine {
|
||||
getCurveType(frameIndex: number): number;
|
||||
setCurve(frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void;
|
||||
getCurvePercent(frameIndex: number, percent: number): number;
|
||||
abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class RotateTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -55,7 +64,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, degrees: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class TranslateTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -69,17 +78,17 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, x: number, y: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class ScaleTimeline extends TranslateTimeline {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class ShearTimeline extends TranslateTimeline {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class ColorTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -97,7 +106,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class TwoColorTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -121,7 +130,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class AttachmentTimeline implements Timeline {
|
||||
slotIndex: number;
|
||||
@ -131,7 +140,7 @@ declare module spine {
|
||||
getPropertyId(): number;
|
||||
getFrameCount(): number;
|
||||
setFrame(frameIndex: number, time: number, attachmentName: string): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class DeformTimeline extends CurveTimeline {
|
||||
slotIndex: number;
|
||||
@ -141,7 +150,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class EventTimeline implements Timeline {
|
||||
frames: ArrayLike<number>;
|
||||
@ -150,7 +159,7 @@ declare module spine {
|
||||
getPropertyId(): number;
|
||||
getFrameCount(): number;
|
||||
setFrame(frameIndex: number, event: Event): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class DrawOrderTimeline implements Timeline {
|
||||
frames: ArrayLike<number>;
|
||||
@ -159,7 +168,7 @@ declare module spine {
|
||||
getPropertyId(): number;
|
||||
getFrameCount(): number;
|
||||
setFrame(frameIndex: number, time: number, drawOrder: Array<number>): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class IkConstraintTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -173,7 +182,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, mix: number, bendDirection: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class TransformConstraintTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -191,7 +200,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class PathConstraintPositionTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -203,12 +212,12 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, value: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class PathConstraintSpacingTimeline extends PathConstraintPositionTimeline {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class PathConstraintMixTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -222,7 +231,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
@ -246,8 +255,8 @@ declare module spine {
|
||||
update(delta: number): void;
|
||||
updateMixingFrom(to: TrackEntry, delta: number): boolean;
|
||||
apply(skeleton: Skeleton): boolean;
|
||||
applyMixingFrom(to: TrackEntry, skeleton: Skeleton): number;
|
||||
applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, setupPose: boolean, timelinesRotation: Array<number>, i: number, firstFrame: boolean): void;
|
||||
applyMixingFrom(to: TrackEntry, skeleton: Skeleton, currentPose: MixPose): number;
|
||||
applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, pose: MixPose, timelinesRotation: Array<number>, i: number, firstFrame: boolean): void;
|
||||
queueEvents(entry: TrackEntry, animationTime: number): void;
|
||||
clearTracks(): void;
|
||||
clearTrack(trackIndex: number): void;
|
||||
@ -396,6 +405,8 @@ declare module spine {
|
||||
constructor(name: string);
|
||||
}
|
||||
abstract class VertexAttachment extends Attachment {
|
||||
private static nextID;
|
||||
id: number;
|
||||
bones: Array<number>;
|
||||
vertices: ArrayLike<number>;
|
||||
worldVerticesLength: number;
|
||||
|
||||
@ -15,7 +15,7 @@ var spine;
|
||||
this.timelines = timelines;
|
||||
this.duration = duration;
|
||||
}
|
||||
Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, setupPose, mixingOut) {
|
||||
Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, pose, direction) {
|
||||
if (skeleton == null)
|
||||
throw new Error("skeleton cannot be null.");
|
||||
if (loop && this.duration != 0) {
|
||||
@ -25,7 +25,7 @@ var spine;
|
||||
}
|
||||
var timelines = this.timelines;
|
||||
for (var i = 0, n = timelines.length; i < n; i++)
|
||||
timelines[i].apply(skeleton, lastTime, time, events, alpha, setupPose, mixingOut);
|
||||
timelines[i].apply(skeleton, lastTime, time, events, alpha, pose, direction);
|
||||
};
|
||||
Animation.binarySearch = function (values, target, step) {
|
||||
if (step === void 0) { step = 1; }
|
||||
@ -53,6 +53,17 @@ var spine;
|
||||
return Animation;
|
||||
}());
|
||||
spine.Animation = Animation;
|
||||
(function (MixPose) {
|
||||
MixPose[MixPose["setup"] = 0] = "setup";
|
||||
MixPose[MixPose["current"] = 1] = "current";
|
||||
MixPose[MixPose["currentLayered"] = 2] = "currentLayered";
|
||||
})(spine.MixPose || (spine.MixPose = {}));
|
||||
var MixPose = spine.MixPose;
|
||||
(function (MixDirection) {
|
||||
MixDirection[MixDirection["in"] = 0] = "in";
|
||||
MixDirection[MixDirection["out"] = 1] = "out";
|
||||
})(spine.MixDirection || (spine.MixDirection = {}));
|
||||
var MixDirection = spine.MixDirection;
|
||||
(function (TimelineType) {
|
||||
TimelineType[TimelineType["rotate"] = 0] = "rotate";
|
||||
TimelineType[TimelineType["translate"] = 1] = "translate";
|
||||
@ -167,21 +178,28 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.frames[frameIndex + RotateTimeline.ROTATION] = degrees;
|
||||
};
|
||||
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
bone.rotation = bone.data.rotation;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.rotation = bone.data.rotation;
|
||||
return;
|
||||
case MixPose.current:
|
||||
var r_1 = bone.data.rotation - bone.rotation;
|
||||
r_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360;
|
||||
bone.rotation += r_1 * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha;
|
||||
else {
|
||||
var r_1 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation;
|
||||
r_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360;
|
||||
bone.rotation += r_1 * alpha;
|
||||
var r_2 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation;
|
||||
r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360;
|
||||
bone.rotation += r_2 * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -192,7 +210,7 @@ var spine;
|
||||
var r = frames[frame + RotateTimeline.ROTATION] - prevRotation;
|
||||
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
|
||||
r = prevRotation + r * percent;
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
|
||||
bone.rotation = bone.data.rotation + r * alpha;
|
||||
}
|
||||
@ -224,13 +242,18 @@ var spine;
|
||||
this.frames[frameIndex + TranslateTimeline.X] = x;
|
||||
this.frames[frameIndex + TranslateTimeline.Y] = y;
|
||||
};
|
||||
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
bone.x = bone.data.x;
|
||||
bone.y = bone.data.y;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.x = bone.data.x;
|
||||
bone.y = bone.data.y;
|
||||
return;
|
||||
case MixPose.current:
|
||||
bone.x += (bone.data.x - bone.x) * alpha;
|
||||
bone.y += (bone.data.y - bone.y) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -248,7 +271,7 @@ var spine;
|
||||
x += (frames[frame + TranslateTimeline.X] - x) * percent;
|
||||
y += (frames[frame + TranslateTimeline.Y] - y) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
bone.x = bone.data.x + x * alpha;
|
||||
bone.y = bone.data.y + y * alpha;
|
||||
}
|
||||
@ -274,13 +297,18 @@ var spine;
|
||||
ScaleTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.scale << 24) + this.boneIndex;
|
||||
};
|
||||
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
bone.scaleX = bone.data.scaleX;
|
||||
bone.scaleY = bone.data.scaleY;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.scaleX = bone.data.scaleX;
|
||||
bone.scaleY = bone.data.scaleY;
|
||||
return;
|
||||
case MixPose.current:
|
||||
bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;
|
||||
bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -304,7 +332,7 @@ var spine;
|
||||
}
|
||||
else {
|
||||
var bx = 0, by = 0;
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
bx = bone.data.scaleX;
|
||||
by = bone.data.scaleY;
|
||||
}
|
||||
@ -312,7 +340,7 @@ var spine;
|
||||
bx = bone.scaleX;
|
||||
by = bone.scaleY;
|
||||
}
|
||||
if (mixingOut) {
|
||||
if (direction == MixDirection.out) {
|
||||
x = Math.abs(x) * spine.MathUtils.signum(bx);
|
||||
y = Math.abs(y) * spine.MathUtils.signum(by);
|
||||
}
|
||||
@ -335,13 +363,18 @@ var spine;
|
||||
ShearTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.shear << 24) + this.boneIndex;
|
||||
};
|
||||
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
bone.shearX = bone.data.shearX;
|
||||
bone.shearY = bone.data.shearY;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.shearX = bone.data.shearX;
|
||||
bone.shearY = bone.data.shearY;
|
||||
return;
|
||||
case MixPose.current:
|
||||
bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
|
||||
bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -359,7 +392,7 @@ var spine;
|
||||
x = x + (frames[frame + ShearTimeline.X] - x) * percent;
|
||||
y = y + (frames[frame + ShearTimeline.Y] - y) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
bone.shearX = bone.data.shearX + x * alpha;
|
||||
bone.shearY = bone.data.shearY + y * alpha;
|
||||
}
|
||||
@ -388,12 +421,18 @@ var spine;
|
||||
this.frames[frameIndex + ColorTimeline.B] = b;
|
||||
this.frames[frameIndex + ColorTimeline.A] = a;
|
||||
};
|
||||
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
return;
|
||||
case MixPose.current:
|
||||
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);
|
||||
}
|
||||
return;
|
||||
}
|
||||
var r = 0, g = 0, b = 0, a = 0;
|
||||
@ -421,7 +460,7 @@ var spine;
|
||||
slot.color.set(r, g, b, a);
|
||||
else {
|
||||
var color = slot.color;
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
color.setFromColor(slot.data.color);
|
||||
color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
|
||||
}
|
||||
@ -459,13 +498,19 @@ var spine;
|
||||
this.frames[frameIndex + TwoColorTimeline.G2] = g2;
|
||||
this.frames[frameIndex + TwoColorTimeline.B2] = b2;
|
||||
};
|
||||
TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
slot.darkColor.setFromColor(slot.data.darkColor);
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
slot.darkColor.setFromColor(slot.data.darkColor);
|
||||
return;
|
||||
case MixPose.current:
|
||||
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);
|
||||
dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -504,9 +549,8 @@ var spine;
|
||||
slot.darkColor.set(r2, g2, b2, 1);
|
||||
}
|
||||
else {
|
||||
var light = slot.color;
|
||||
var dark = slot.darkColor;
|
||||
if (setupPose) {
|
||||
var light = slot.color, dark = slot.darkColor;
|
||||
if (pose == MixPose.setup) {
|
||||
light.setFromColor(slot.data.color);
|
||||
dark.setFromColor(slot.data.darkColor);
|
||||
}
|
||||
@ -548,16 +592,16 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.attachmentNames[frameIndex] = attachmentName;
|
||||
};
|
||||
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
if (mixingOut && setupPose) {
|
||||
if (direction == MixDirection.out && pose == MixPose.setup) {
|
||||
var attachmentName_1 = slot.data.attachmentName;
|
||||
slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1));
|
||||
return;
|
||||
}
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
var attachmentName_2 = slot.data.attachmentName;
|
||||
slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2));
|
||||
}
|
||||
@ -583,35 +627,42 @@ var spine;
|
||||
this.frameVertices = new Array(frameCount);
|
||||
}
|
||||
DeformTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.deform << 24) + this.slotIndex;
|
||||
return (TimelineType.deform << 27) + +this.attachment.id + this.slotIndex;
|
||||
};
|
||||
DeformTimeline.prototype.setFrame = function (frameIndex, time, vertices) {
|
||||
this.frames[frameIndex] = time;
|
||||
this.frameVertices[frameIndex] = vertices;
|
||||
};
|
||||
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var slotAttachment = slot.getAttachment();
|
||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
||||
return;
|
||||
var frames = this.frames;
|
||||
var verticesArray = slot.attachmentVertices;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
spine.Utils.setArraySize(verticesArray, 0);
|
||||
return;
|
||||
}
|
||||
var frameVertices = this.frameVertices;
|
||||
var vertexCount = frameVertices[0].length;
|
||||
if (verticesArray.length != vertexCount && !setupPose)
|
||||
if (verticesArray.length != vertexCount && pose != MixPose.setup)
|
||||
alpha = 1;
|
||||
var vertices = spine.Utils.setArraySize(verticesArray, vertexCount);
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
verticesArray.length = 0;
|
||||
return;
|
||||
case MixPose.current:
|
||||
alpha = 1 - alpha;
|
||||
for (var i = 0; i < vertexCount; i++)
|
||||
vertices[i] *= alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (time >= frames[frames.length - 1]) {
|
||||
var lastVertices = frameVertices[frames.length - 1];
|
||||
if (alpha == 1) {
|
||||
spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount);
|
||||
}
|
||||
else if (setupPose) {
|
||||
else if (pose == MixPose.setup) {
|
||||
var vertexAttachment = slotAttachment;
|
||||
if (vertexAttachment.bones == null) {
|
||||
var setupVertices = vertexAttachment.vertices;
|
||||
@ -642,7 +693,7 @@ var spine;
|
||||
vertices[i] = prev + (nextVertices[i] - prev) * percent;
|
||||
}
|
||||
}
|
||||
else if (setupPose) {
|
||||
else if (pose == MixPose.setup) {
|
||||
var vertexAttachment = slotAttachment;
|
||||
if (vertexAttachment.bones == null) {
|
||||
var setupVertices = vertexAttachment.vertices;
|
||||
@ -683,13 +734,13 @@ var spine;
|
||||
this.frames[frameIndex] = event.time;
|
||||
this.events[frameIndex] = event;
|
||||
};
|
||||
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
if (firedEvents == null)
|
||||
return;
|
||||
var frames = this.frames;
|
||||
var frameCount = this.frames.length;
|
||||
if (lastTime > time) {
|
||||
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, setupPose, mixingOut);
|
||||
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, pose, direction);
|
||||
lastTime = -1;
|
||||
}
|
||||
else if (lastTime >= frames[frameCount - 1])
|
||||
@ -729,16 +780,16 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.drawOrders[frameIndex] = drawOrder;
|
||||
};
|
||||
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var drawOrder = skeleton.drawOrder;
|
||||
var slots = skeleton.slots;
|
||||
if (mixingOut && setupPose) {
|
||||
if (direction == MixDirection.out && pose == MixPose.setup) {
|
||||
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||
return;
|
||||
}
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||
return;
|
||||
}
|
||||
@ -773,25 +824,30 @@ var spine;
|
||||
this.frames[frameIndex + IkConstraintTimeline.MIX] = mix;
|
||||
this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection;
|
||||
};
|
||||
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
constraint.mix = constraint.data.mix;
|
||||
constraint.bendDirection = constraint.data.bendDirection;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.mix = constraint.data.mix;
|
||||
constraint.bendDirection = constraint.data.bendDirection;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.mix += (constraint.data.mix - constraint.mix) * alpha;
|
||||
constraint.bendDirection = constraint.data.bendDirection;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
|
||||
constraint.bendDirection = mixingOut ? constraint.data.bendDirection
|
||||
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection
|
||||
: frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
else {
|
||||
constraint.mix += (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.mix) * alpha;
|
||||
if (!mixingOut)
|
||||
if (direction == MixDirection.in)
|
||||
constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
return;
|
||||
@ -800,13 +856,13 @@ var spine;
|
||||
var mix = frames[frame + IkConstraintTimeline.PREV_MIX];
|
||||
var frameTime = frames[frame];
|
||||
var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime));
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha;
|
||||
constraint.bendDirection = mixingOut ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
else {
|
||||
constraint.mix += (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.mix) * alpha;
|
||||
if (!mixingOut)
|
||||
if (direction == MixDirection.in)
|
||||
constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
};
|
||||
@ -836,16 +892,23 @@ var spine;
|
||||
this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix;
|
||||
this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix;
|
||||
};
|
||||
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
var data = constraint.data;
|
||||
constraint.rotateMix = data.rotateMix;
|
||||
constraint.translateMix = data.rotateMix;
|
||||
constraint.scaleMix = data.scaleMix;
|
||||
constraint.shearMix = data.shearMix;
|
||||
var data = constraint.data;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.rotateMix = data.rotateMix;
|
||||
constraint.translateMix = data.translateMix;
|
||||
constraint.scaleMix = data.scaleMix;
|
||||
constraint.shearMix = data.shearMix;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha;
|
||||
constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha;
|
||||
constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha;
|
||||
constraint.shearMix += (data.shearMix - constraint.shearMix) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -870,7 +933,7 @@ var spine;
|
||||
scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent;
|
||||
shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
var data = constraint.data;
|
||||
constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha;
|
||||
constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha;
|
||||
@ -911,12 +974,17 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value;
|
||||
};
|
||||
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
constraint.position = constraint.data.position;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.position = constraint.data.position;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.position += (constraint.data.position - constraint.position) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
var position = 0;
|
||||
@ -929,7 +997,7 @@ var spine;
|
||||
var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime));
|
||||
position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent;
|
||||
}
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
constraint.position = constraint.data.position + (position - constraint.data.position) * alpha;
|
||||
else
|
||||
constraint.position += (position - constraint.position) * alpha;
|
||||
@ -949,12 +1017,17 @@ var spine;
|
||||
PathConstraintSpacingTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex;
|
||||
};
|
||||
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
constraint.spacing = constraint.data.spacing;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.spacing = constraint.data.spacing;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
var spacing = 0;
|
||||
@ -967,7 +1040,7 @@ var spine;
|
||||
var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime));
|
||||
spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent;
|
||||
}
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;
|
||||
else
|
||||
constraint.spacing += (spacing - constraint.spacing) * alpha;
|
||||
@ -990,13 +1063,18 @@ var spine;
|
||||
this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix;
|
||||
this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix;
|
||||
};
|
||||
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
constraint.rotateMix = constraint.data.rotateMix;
|
||||
constraint.translateMix = constraint.data.translateMix;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.rotateMix = constraint.data.rotateMix;
|
||||
constraint.translateMix = constraint.data.translateMix;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha;
|
||||
constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1014,7 +1092,7 @@ var spine;
|
||||
rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent;
|
||||
translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha;
|
||||
constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha;
|
||||
}
|
||||
@ -1130,9 +1208,10 @@ var spine;
|
||||
if (current == null || current.delay > 0)
|
||||
continue;
|
||||
applied = true;
|
||||
var currentPose = i == 0 ? spine.MixPose.current : spine.MixPose.currentLayered;
|
||||
var mix = current.alpha;
|
||||
if (current.mixingFrom != null)
|
||||
mix *= this.applyMixingFrom(current, skeleton);
|
||||
mix *= this.applyMixingFrom(current, skeleton, currentPose);
|
||||
else if (current.trackTime >= current.trackEnd && current.next == null)
|
||||
mix = 0;
|
||||
var animationLast = current.animationLast, animationTime = current.getAnimationTime();
|
||||
@ -1140,7 +1219,7 @@ var spine;
|
||||
var timelines = current.animation.timelines;
|
||||
if (mix == 1) {
|
||||
for (var ii = 0; ii < timelineCount; ii++)
|
||||
timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, true, false);
|
||||
timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, spine.MixPose.setup, spine.MixDirection.in);
|
||||
}
|
||||
else {
|
||||
var timelineData = current.timelineData;
|
||||
@ -1150,11 +1229,12 @@ var spine;
|
||||
var timelinesRotation = current.timelinesRotation;
|
||||
for (var ii = 0; ii < timelineCount; ii++) {
|
||||
var timeline = timelines[ii];
|
||||
var pose = timelineData[ii] >= AnimationState.FIRST ? spine.MixPose.setup : currentPose;
|
||||
if (timeline instanceof spine.RotateTimeline) {
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineData[ii] >= AnimationState.FIRST, timelinesRotation, ii << 1, firstFrame);
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, mix, pose, timelinesRotation, ii << 1, firstFrame);
|
||||
}
|
||||
else
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineData[ii] >= AnimationState.FIRST, false);
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, mix, pose, spine.MixDirection.in);
|
||||
}
|
||||
}
|
||||
this.queueEvents(current, animationTime);
|
||||
@ -1165,10 +1245,10 @@ var spine;
|
||||
this.queue.drain();
|
||||
return applied;
|
||||
};
|
||||
AnimationState.prototype.applyMixingFrom = function (to, skeleton) {
|
||||
AnimationState.prototype.applyMixingFrom = function (to, skeleton, currentPose) {
|
||||
var from = to.mixingFrom;
|
||||
if (from.mixingFrom != null)
|
||||
this.applyMixingFrom(from, skeleton);
|
||||
this.applyMixingFrom(from, skeleton, currentPose);
|
||||
var mix = 0;
|
||||
if (to.mixDuration == 0)
|
||||
mix = 1;
|
||||
@ -1188,26 +1268,30 @@ var spine;
|
||||
if (firstFrame)
|
||||
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
|
||||
var timelinesRotation = from.timelinesRotation;
|
||||
var first = false;
|
||||
var pose;
|
||||
var alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix), alpha = 0;
|
||||
from.totalAlpha = 0;
|
||||
for (var i = 0; i < timelineCount; i++) {
|
||||
var timeline = timelines[i];
|
||||
switch (timelineData[i]) {
|
||||
case AnimationState.SUBSEQUENT:
|
||||
first = false;
|
||||
if (!attachments && timeline instanceof spine.AttachmentTimeline)
|
||||
continue;
|
||||
if (!drawOrder && timeline instanceof spine.DrawOrderTimeline)
|
||||
continue;
|
||||
pose = currentPose;
|
||||
alpha = alphaMix;
|
||||
break;
|
||||
case AnimationState.FIRST:
|
||||
first = true;
|
||||
pose = spine.MixPose.setup;
|
||||
alpha = alphaMix;
|
||||
break;
|
||||
case AnimationState.DIP:
|
||||
first = true;
|
||||
pose = spine.MixPose.setup;
|
||||
alpha = alphaDip;
|
||||
break;
|
||||
default:
|
||||
first = true;
|
||||
pose = spine.MixPose.setup;
|
||||
alpha = alphaDip;
|
||||
var dipMix = timelineDipMix[i];
|
||||
alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
|
||||
@ -1215,15 +1299,9 @@ var spine;
|
||||
}
|
||||
from.totalAlpha += alpha;
|
||||
if (timeline instanceof spine.RotateTimeline)
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, first, timelinesRotation, i << 1, firstFrame);
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame);
|
||||
else {
|
||||
if (!first) {
|
||||
if (!attachments && timeline instanceof spine.AttachmentTimeline)
|
||||
continue;
|
||||
if (!drawOrder && timeline instanceof spine.DrawOrderTimeline)
|
||||
continue;
|
||||
}
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, alpha, first, true);
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, alpha, pose, spine.MixDirection.out);
|
||||
}
|
||||
}
|
||||
if (to.mixDuration > 0)
|
||||
@ -1233,18 +1311,18 @@ var spine;
|
||||
from.nextTrackLast = from.trackTime;
|
||||
return mix;
|
||||
};
|
||||
AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, setupPose, timelinesRotation, i, firstFrame) {
|
||||
AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, pose, timelinesRotation, i, firstFrame) {
|
||||
if (firstFrame)
|
||||
timelinesRotation[i] = 0;
|
||||
if (alpha == 1) {
|
||||
timeline.apply(skeleton, 0, time, null, 1, setupPose, false);
|
||||
timeline.apply(skeleton, 0, time, null, 1, pose, spine.MixDirection.in);
|
||||
return;
|
||||
}
|
||||
var rotateTimeline = timeline;
|
||||
var frames = rotateTimeline.frames;
|
||||
var bone = skeleton.bones[rotateTimeline.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
if (pose == spine.MixPose.setup)
|
||||
bone.rotation = bone.data.rotation;
|
||||
return;
|
||||
}
|
||||
@ -1261,7 +1339,7 @@ var spine;
|
||||
r2 = prevRotation + r2 * percent + bone.data.rotation;
|
||||
r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
|
||||
}
|
||||
var r1 = setupPose ? bone.data.rotation : bone.rotation;
|
||||
var r1 = pose == spine.MixPose.setup ? bone.data.rotation : bone.rotation;
|
||||
var total = 0, diff = r2 - r1;
|
||||
if (diff == 0) {
|
||||
total = timelinesRotation[i];
|
||||
@ -1950,6 +2028,7 @@ var spine;
|
||||
__extends(VertexAttachment, _super);
|
||||
function VertexAttachment(name) {
|
||||
_super.call(this, name);
|
||||
this.id = (VertexAttachment.nextID++ & 65535) << 11;
|
||||
this.worldVerticesLength = 0;
|
||||
}
|
||||
VertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) {
|
||||
@ -2014,6 +2093,7 @@ var spine;
|
||||
VertexAttachment.prototype.applyDeform = function (sourceAttachment) {
|
||||
return this == sourceAttachment;
|
||||
};
|
||||
VertexAttachment.nextID = 0;
|
||||
return VertexAttachment;
|
||||
}(Attachment));
|
||||
spine.VertexAttachment = VertexAttachment;
|
||||
|
||||
File diff suppressed because one or more lines are too long
51
spine-ts/build/spine-webgl.d.ts
vendored
51
spine-ts/build/spine-webgl.d.ts
vendored
@ -4,14 +4,23 @@ declare module spine {
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
static binarySearch(values: ArrayLike<number>, target: number, step?: number): number;
|
||||
static linearSearch(values: ArrayLike<number>, target: number, step: number): number;
|
||||
}
|
||||
interface Timeline {
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
getPropertyId(): number;
|
||||
}
|
||||
enum MixPose {
|
||||
setup = 0,
|
||||
current = 1,
|
||||
currentLayered = 2,
|
||||
}
|
||||
enum MixDirection {
|
||||
in = 0,
|
||||
out = 1,
|
||||
}
|
||||
enum TimelineType {
|
||||
rotate = 0,
|
||||
translate = 1,
|
||||
@ -43,7 +52,7 @@ declare module spine {
|
||||
getCurveType(frameIndex: number): number;
|
||||
setCurve(frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void;
|
||||
getCurvePercent(frameIndex: number, percent: number): number;
|
||||
abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class RotateTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -55,7 +64,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, degrees: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class TranslateTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -69,17 +78,17 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, x: number, y: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class ScaleTimeline extends TranslateTimeline {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class ShearTimeline extends TranslateTimeline {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class ColorTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -97,7 +106,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class TwoColorTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -121,7 +130,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class AttachmentTimeline implements Timeline {
|
||||
slotIndex: number;
|
||||
@ -131,7 +140,7 @@ declare module spine {
|
||||
getPropertyId(): number;
|
||||
getFrameCount(): number;
|
||||
setFrame(frameIndex: number, time: number, attachmentName: string): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class DeformTimeline extends CurveTimeline {
|
||||
slotIndex: number;
|
||||
@ -141,7 +150,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class EventTimeline implements Timeline {
|
||||
frames: ArrayLike<number>;
|
||||
@ -150,7 +159,7 @@ declare module spine {
|
||||
getPropertyId(): number;
|
||||
getFrameCount(): number;
|
||||
setFrame(frameIndex: number, event: Event): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class DrawOrderTimeline implements Timeline {
|
||||
frames: ArrayLike<number>;
|
||||
@ -159,7 +168,7 @@ declare module spine {
|
||||
getPropertyId(): number;
|
||||
getFrameCount(): number;
|
||||
setFrame(frameIndex: number, time: number, drawOrder: Array<number>): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class IkConstraintTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -173,7 +182,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, mix: number, bendDirection: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class TransformConstraintTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -191,7 +200,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class PathConstraintPositionTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -203,12 +212,12 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, value: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class PathConstraintSpacingTimeline extends PathConstraintPositionTimeline {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class PathConstraintMixTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -222,7 +231,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
@ -246,8 +255,8 @@ declare module spine {
|
||||
update(delta: number): void;
|
||||
updateMixingFrom(to: TrackEntry, delta: number): boolean;
|
||||
apply(skeleton: Skeleton): boolean;
|
||||
applyMixingFrom(to: TrackEntry, skeleton: Skeleton): number;
|
||||
applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, setupPose: boolean, timelinesRotation: Array<number>, i: number, firstFrame: boolean): void;
|
||||
applyMixingFrom(to: TrackEntry, skeleton: Skeleton, currentPose: MixPose): number;
|
||||
applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, pose: MixPose, timelinesRotation: Array<number>, i: number, firstFrame: boolean): void;
|
||||
queueEvents(entry: TrackEntry, animationTime: number): void;
|
||||
clearTracks(): void;
|
||||
clearTrack(trackIndex: number): void;
|
||||
@ -396,6 +405,8 @@ declare module spine {
|
||||
constructor(name: string);
|
||||
}
|
||||
abstract class VertexAttachment extends Attachment {
|
||||
private static nextID;
|
||||
id: number;
|
||||
bones: Array<number>;
|
||||
vertices: ArrayLike<number>;
|
||||
worldVerticesLength: number;
|
||||
|
||||
@ -15,7 +15,7 @@ var spine;
|
||||
this.timelines = timelines;
|
||||
this.duration = duration;
|
||||
}
|
||||
Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, setupPose, mixingOut) {
|
||||
Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, pose, direction) {
|
||||
if (skeleton == null)
|
||||
throw new Error("skeleton cannot be null.");
|
||||
if (loop && this.duration != 0) {
|
||||
@ -25,7 +25,7 @@ var spine;
|
||||
}
|
||||
var timelines = this.timelines;
|
||||
for (var i = 0, n = timelines.length; i < n; i++)
|
||||
timelines[i].apply(skeleton, lastTime, time, events, alpha, setupPose, mixingOut);
|
||||
timelines[i].apply(skeleton, lastTime, time, events, alpha, pose, direction);
|
||||
};
|
||||
Animation.binarySearch = function (values, target, step) {
|
||||
if (step === void 0) { step = 1; }
|
||||
@ -53,6 +53,17 @@ var spine;
|
||||
return Animation;
|
||||
}());
|
||||
spine.Animation = Animation;
|
||||
(function (MixPose) {
|
||||
MixPose[MixPose["setup"] = 0] = "setup";
|
||||
MixPose[MixPose["current"] = 1] = "current";
|
||||
MixPose[MixPose["currentLayered"] = 2] = "currentLayered";
|
||||
})(spine.MixPose || (spine.MixPose = {}));
|
||||
var MixPose = spine.MixPose;
|
||||
(function (MixDirection) {
|
||||
MixDirection[MixDirection["in"] = 0] = "in";
|
||||
MixDirection[MixDirection["out"] = 1] = "out";
|
||||
})(spine.MixDirection || (spine.MixDirection = {}));
|
||||
var MixDirection = spine.MixDirection;
|
||||
(function (TimelineType) {
|
||||
TimelineType[TimelineType["rotate"] = 0] = "rotate";
|
||||
TimelineType[TimelineType["translate"] = 1] = "translate";
|
||||
@ -167,21 +178,28 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.frames[frameIndex + RotateTimeline.ROTATION] = degrees;
|
||||
};
|
||||
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
bone.rotation = bone.data.rotation;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.rotation = bone.data.rotation;
|
||||
return;
|
||||
case MixPose.current:
|
||||
var r_1 = bone.data.rotation - bone.rotation;
|
||||
r_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360;
|
||||
bone.rotation += r_1 * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha;
|
||||
else {
|
||||
var r_1 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation;
|
||||
r_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360;
|
||||
bone.rotation += r_1 * alpha;
|
||||
var r_2 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation;
|
||||
r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360;
|
||||
bone.rotation += r_2 * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -192,7 +210,7 @@ var spine;
|
||||
var r = frames[frame + RotateTimeline.ROTATION] - prevRotation;
|
||||
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
|
||||
r = prevRotation + r * percent;
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
|
||||
bone.rotation = bone.data.rotation + r * alpha;
|
||||
}
|
||||
@ -224,13 +242,18 @@ var spine;
|
||||
this.frames[frameIndex + TranslateTimeline.X] = x;
|
||||
this.frames[frameIndex + TranslateTimeline.Y] = y;
|
||||
};
|
||||
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
bone.x = bone.data.x;
|
||||
bone.y = bone.data.y;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.x = bone.data.x;
|
||||
bone.y = bone.data.y;
|
||||
return;
|
||||
case MixPose.current:
|
||||
bone.x += (bone.data.x - bone.x) * alpha;
|
||||
bone.y += (bone.data.y - bone.y) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -248,7 +271,7 @@ var spine;
|
||||
x += (frames[frame + TranslateTimeline.X] - x) * percent;
|
||||
y += (frames[frame + TranslateTimeline.Y] - y) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
bone.x = bone.data.x + x * alpha;
|
||||
bone.y = bone.data.y + y * alpha;
|
||||
}
|
||||
@ -274,13 +297,18 @@ var spine;
|
||||
ScaleTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.scale << 24) + this.boneIndex;
|
||||
};
|
||||
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
bone.scaleX = bone.data.scaleX;
|
||||
bone.scaleY = bone.data.scaleY;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.scaleX = bone.data.scaleX;
|
||||
bone.scaleY = bone.data.scaleY;
|
||||
return;
|
||||
case MixPose.current:
|
||||
bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;
|
||||
bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -304,7 +332,7 @@ var spine;
|
||||
}
|
||||
else {
|
||||
var bx = 0, by = 0;
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
bx = bone.data.scaleX;
|
||||
by = bone.data.scaleY;
|
||||
}
|
||||
@ -312,7 +340,7 @@ var spine;
|
||||
bx = bone.scaleX;
|
||||
by = bone.scaleY;
|
||||
}
|
||||
if (mixingOut) {
|
||||
if (direction == MixDirection.out) {
|
||||
x = Math.abs(x) * spine.MathUtils.signum(bx);
|
||||
y = Math.abs(y) * spine.MathUtils.signum(by);
|
||||
}
|
||||
@ -335,13 +363,18 @@ var spine;
|
||||
ShearTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.shear << 24) + this.boneIndex;
|
||||
};
|
||||
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
bone.shearX = bone.data.shearX;
|
||||
bone.shearY = bone.data.shearY;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.shearX = bone.data.shearX;
|
||||
bone.shearY = bone.data.shearY;
|
||||
return;
|
||||
case MixPose.current:
|
||||
bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
|
||||
bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -359,7 +392,7 @@ var spine;
|
||||
x = x + (frames[frame + ShearTimeline.X] - x) * percent;
|
||||
y = y + (frames[frame + ShearTimeline.Y] - y) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
bone.shearX = bone.data.shearX + x * alpha;
|
||||
bone.shearY = bone.data.shearY + y * alpha;
|
||||
}
|
||||
@ -388,12 +421,18 @@ var spine;
|
||||
this.frames[frameIndex + ColorTimeline.B] = b;
|
||||
this.frames[frameIndex + ColorTimeline.A] = a;
|
||||
};
|
||||
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
return;
|
||||
case MixPose.current:
|
||||
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);
|
||||
}
|
||||
return;
|
||||
}
|
||||
var r = 0, g = 0, b = 0, a = 0;
|
||||
@ -421,7 +460,7 @@ var spine;
|
||||
slot.color.set(r, g, b, a);
|
||||
else {
|
||||
var color = slot.color;
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
color.setFromColor(slot.data.color);
|
||||
color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
|
||||
}
|
||||
@ -459,13 +498,19 @@ var spine;
|
||||
this.frames[frameIndex + TwoColorTimeline.G2] = g2;
|
||||
this.frames[frameIndex + TwoColorTimeline.B2] = b2;
|
||||
};
|
||||
TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
slot.darkColor.setFromColor(slot.data.darkColor);
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
slot.darkColor.setFromColor(slot.data.darkColor);
|
||||
return;
|
||||
case MixPose.current:
|
||||
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);
|
||||
dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -504,9 +549,8 @@ var spine;
|
||||
slot.darkColor.set(r2, g2, b2, 1);
|
||||
}
|
||||
else {
|
||||
var light = slot.color;
|
||||
var dark = slot.darkColor;
|
||||
if (setupPose) {
|
||||
var light = slot.color, dark = slot.darkColor;
|
||||
if (pose == MixPose.setup) {
|
||||
light.setFromColor(slot.data.color);
|
||||
dark.setFromColor(slot.data.darkColor);
|
||||
}
|
||||
@ -548,16 +592,16 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.attachmentNames[frameIndex] = attachmentName;
|
||||
};
|
||||
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
if (mixingOut && setupPose) {
|
||||
if (direction == MixDirection.out && pose == MixPose.setup) {
|
||||
var attachmentName_1 = slot.data.attachmentName;
|
||||
slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1));
|
||||
return;
|
||||
}
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
var attachmentName_2 = slot.data.attachmentName;
|
||||
slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2));
|
||||
}
|
||||
@ -583,35 +627,42 @@ var spine;
|
||||
this.frameVertices = new Array(frameCount);
|
||||
}
|
||||
DeformTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.deform << 24) + this.slotIndex;
|
||||
return (TimelineType.deform << 27) + +this.attachment.id + this.slotIndex;
|
||||
};
|
||||
DeformTimeline.prototype.setFrame = function (frameIndex, time, vertices) {
|
||||
this.frames[frameIndex] = time;
|
||||
this.frameVertices[frameIndex] = vertices;
|
||||
};
|
||||
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var slotAttachment = slot.getAttachment();
|
||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
||||
return;
|
||||
var frames = this.frames;
|
||||
var verticesArray = slot.attachmentVertices;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
spine.Utils.setArraySize(verticesArray, 0);
|
||||
return;
|
||||
}
|
||||
var frameVertices = this.frameVertices;
|
||||
var vertexCount = frameVertices[0].length;
|
||||
if (verticesArray.length != vertexCount && !setupPose)
|
||||
if (verticesArray.length != vertexCount && pose != MixPose.setup)
|
||||
alpha = 1;
|
||||
var vertices = spine.Utils.setArraySize(verticesArray, vertexCount);
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
verticesArray.length = 0;
|
||||
return;
|
||||
case MixPose.current:
|
||||
alpha = 1 - alpha;
|
||||
for (var i = 0; i < vertexCount; i++)
|
||||
vertices[i] *= alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (time >= frames[frames.length - 1]) {
|
||||
var lastVertices = frameVertices[frames.length - 1];
|
||||
if (alpha == 1) {
|
||||
spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount);
|
||||
}
|
||||
else if (setupPose) {
|
||||
else if (pose == MixPose.setup) {
|
||||
var vertexAttachment = slotAttachment;
|
||||
if (vertexAttachment.bones == null) {
|
||||
var setupVertices = vertexAttachment.vertices;
|
||||
@ -642,7 +693,7 @@ var spine;
|
||||
vertices[i] = prev + (nextVertices[i] - prev) * percent;
|
||||
}
|
||||
}
|
||||
else if (setupPose) {
|
||||
else if (pose == MixPose.setup) {
|
||||
var vertexAttachment = slotAttachment;
|
||||
if (vertexAttachment.bones == null) {
|
||||
var setupVertices = vertexAttachment.vertices;
|
||||
@ -683,13 +734,13 @@ var spine;
|
||||
this.frames[frameIndex] = event.time;
|
||||
this.events[frameIndex] = event;
|
||||
};
|
||||
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
if (firedEvents == null)
|
||||
return;
|
||||
var frames = this.frames;
|
||||
var frameCount = this.frames.length;
|
||||
if (lastTime > time) {
|
||||
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, setupPose, mixingOut);
|
||||
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, pose, direction);
|
||||
lastTime = -1;
|
||||
}
|
||||
else if (lastTime >= frames[frameCount - 1])
|
||||
@ -729,16 +780,16 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.drawOrders[frameIndex] = drawOrder;
|
||||
};
|
||||
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var drawOrder = skeleton.drawOrder;
|
||||
var slots = skeleton.slots;
|
||||
if (mixingOut && setupPose) {
|
||||
if (direction == MixDirection.out && pose == MixPose.setup) {
|
||||
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||
return;
|
||||
}
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||
return;
|
||||
}
|
||||
@ -773,25 +824,30 @@ var spine;
|
||||
this.frames[frameIndex + IkConstraintTimeline.MIX] = mix;
|
||||
this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection;
|
||||
};
|
||||
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
constraint.mix = constraint.data.mix;
|
||||
constraint.bendDirection = constraint.data.bendDirection;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.mix = constraint.data.mix;
|
||||
constraint.bendDirection = constraint.data.bendDirection;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.mix += (constraint.data.mix - constraint.mix) * alpha;
|
||||
constraint.bendDirection = constraint.data.bendDirection;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
|
||||
constraint.bendDirection = mixingOut ? constraint.data.bendDirection
|
||||
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection
|
||||
: frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
else {
|
||||
constraint.mix += (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.mix) * alpha;
|
||||
if (!mixingOut)
|
||||
if (direction == MixDirection.in)
|
||||
constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
return;
|
||||
@ -800,13 +856,13 @@ var spine;
|
||||
var mix = frames[frame + IkConstraintTimeline.PREV_MIX];
|
||||
var frameTime = frames[frame];
|
||||
var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime));
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha;
|
||||
constraint.bendDirection = mixingOut ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
else {
|
||||
constraint.mix += (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.mix) * alpha;
|
||||
if (!mixingOut)
|
||||
if (direction == MixDirection.in)
|
||||
constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
};
|
||||
@ -836,16 +892,23 @@ var spine;
|
||||
this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix;
|
||||
this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix;
|
||||
};
|
||||
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
var data = constraint.data;
|
||||
constraint.rotateMix = data.rotateMix;
|
||||
constraint.translateMix = data.rotateMix;
|
||||
constraint.scaleMix = data.scaleMix;
|
||||
constraint.shearMix = data.shearMix;
|
||||
var data = constraint.data;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.rotateMix = data.rotateMix;
|
||||
constraint.translateMix = data.translateMix;
|
||||
constraint.scaleMix = data.scaleMix;
|
||||
constraint.shearMix = data.shearMix;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha;
|
||||
constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha;
|
||||
constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha;
|
||||
constraint.shearMix += (data.shearMix - constraint.shearMix) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -870,7 +933,7 @@ var spine;
|
||||
scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent;
|
||||
shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
var data = constraint.data;
|
||||
constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha;
|
||||
constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha;
|
||||
@ -911,12 +974,17 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value;
|
||||
};
|
||||
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
constraint.position = constraint.data.position;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.position = constraint.data.position;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.position += (constraint.data.position - constraint.position) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
var position = 0;
|
||||
@ -929,7 +997,7 @@ var spine;
|
||||
var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime));
|
||||
position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent;
|
||||
}
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
constraint.position = constraint.data.position + (position - constraint.data.position) * alpha;
|
||||
else
|
||||
constraint.position += (position - constraint.position) * alpha;
|
||||
@ -949,12 +1017,17 @@ var spine;
|
||||
PathConstraintSpacingTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex;
|
||||
};
|
||||
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
constraint.spacing = constraint.data.spacing;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.spacing = constraint.data.spacing;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
var spacing = 0;
|
||||
@ -967,7 +1040,7 @@ var spine;
|
||||
var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime));
|
||||
spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent;
|
||||
}
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;
|
||||
else
|
||||
constraint.spacing += (spacing - constraint.spacing) * alpha;
|
||||
@ -990,13 +1063,18 @@ var spine;
|
||||
this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix;
|
||||
this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix;
|
||||
};
|
||||
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
constraint.rotateMix = constraint.data.rotateMix;
|
||||
constraint.translateMix = constraint.data.translateMix;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.rotateMix = constraint.data.rotateMix;
|
||||
constraint.translateMix = constraint.data.translateMix;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha;
|
||||
constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1014,7 +1092,7 @@ var spine;
|
||||
rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent;
|
||||
translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha;
|
||||
constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha;
|
||||
}
|
||||
@ -1130,9 +1208,10 @@ var spine;
|
||||
if (current == null || current.delay > 0)
|
||||
continue;
|
||||
applied = true;
|
||||
var currentPose = i == 0 ? spine.MixPose.current : spine.MixPose.currentLayered;
|
||||
var mix = current.alpha;
|
||||
if (current.mixingFrom != null)
|
||||
mix *= this.applyMixingFrom(current, skeleton);
|
||||
mix *= this.applyMixingFrom(current, skeleton, currentPose);
|
||||
else if (current.trackTime >= current.trackEnd && current.next == null)
|
||||
mix = 0;
|
||||
var animationLast = current.animationLast, animationTime = current.getAnimationTime();
|
||||
@ -1140,7 +1219,7 @@ var spine;
|
||||
var timelines = current.animation.timelines;
|
||||
if (mix == 1) {
|
||||
for (var ii = 0; ii < timelineCount; ii++)
|
||||
timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, true, false);
|
||||
timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, spine.MixPose.setup, spine.MixDirection.in);
|
||||
}
|
||||
else {
|
||||
var timelineData = current.timelineData;
|
||||
@ -1150,11 +1229,12 @@ var spine;
|
||||
var timelinesRotation = current.timelinesRotation;
|
||||
for (var ii = 0; ii < timelineCount; ii++) {
|
||||
var timeline = timelines[ii];
|
||||
var pose = timelineData[ii] >= AnimationState.FIRST ? spine.MixPose.setup : currentPose;
|
||||
if (timeline instanceof spine.RotateTimeline) {
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineData[ii] >= AnimationState.FIRST, timelinesRotation, ii << 1, firstFrame);
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, mix, pose, timelinesRotation, ii << 1, firstFrame);
|
||||
}
|
||||
else
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineData[ii] >= AnimationState.FIRST, false);
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, mix, pose, spine.MixDirection.in);
|
||||
}
|
||||
}
|
||||
this.queueEvents(current, animationTime);
|
||||
@ -1165,10 +1245,10 @@ var spine;
|
||||
this.queue.drain();
|
||||
return applied;
|
||||
};
|
||||
AnimationState.prototype.applyMixingFrom = function (to, skeleton) {
|
||||
AnimationState.prototype.applyMixingFrom = function (to, skeleton, currentPose) {
|
||||
var from = to.mixingFrom;
|
||||
if (from.mixingFrom != null)
|
||||
this.applyMixingFrom(from, skeleton);
|
||||
this.applyMixingFrom(from, skeleton, currentPose);
|
||||
var mix = 0;
|
||||
if (to.mixDuration == 0)
|
||||
mix = 1;
|
||||
@ -1188,26 +1268,30 @@ var spine;
|
||||
if (firstFrame)
|
||||
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
|
||||
var timelinesRotation = from.timelinesRotation;
|
||||
var first = false;
|
||||
var pose;
|
||||
var alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix), alpha = 0;
|
||||
from.totalAlpha = 0;
|
||||
for (var i = 0; i < timelineCount; i++) {
|
||||
var timeline = timelines[i];
|
||||
switch (timelineData[i]) {
|
||||
case AnimationState.SUBSEQUENT:
|
||||
first = false;
|
||||
if (!attachments && timeline instanceof spine.AttachmentTimeline)
|
||||
continue;
|
||||
if (!drawOrder && timeline instanceof spine.DrawOrderTimeline)
|
||||
continue;
|
||||
pose = currentPose;
|
||||
alpha = alphaMix;
|
||||
break;
|
||||
case AnimationState.FIRST:
|
||||
first = true;
|
||||
pose = spine.MixPose.setup;
|
||||
alpha = alphaMix;
|
||||
break;
|
||||
case AnimationState.DIP:
|
||||
first = true;
|
||||
pose = spine.MixPose.setup;
|
||||
alpha = alphaDip;
|
||||
break;
|
||||
default:
|
||||
first = true;
|
||||
pose = spine.MixPose.setup;
|
||||
alpha = alphaDip;
|
||||
var dipMix = timelineDipMix[i];
|
||||
alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
|
||||
@ -1215,15 +1299,9 @@ var spine;
|
||||
}
|
||||
from.totalAlpha += alpha;
|
||||
if (timeline instanceof spine.RotateTimeline)
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, first, timelinesRotation, i << 1, firstFrame);
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame);
|
||||
else {
|
||||
if (!first) {
|
||||
if (!attachments && timeline instanceof spine.AttachmentTimeline)
|
||||
continue;
|
||||
if (!drawOrder && timeline instanceof spine.DrawOrderTimeline)
|
||||
continue;
|
||||
}
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, alpha, first, true);
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, alpha, pose, spine.MixDirection.out);
|
||||
}
|
||||
}
|
||||
if (to.mixDuration > 0)
|
||||
@ -1233,18 +1311,18 @@ var spine;
|
||||
from.nextTrackLast = from.trackTime;
|
||||
return mix;
|
||||
};
|
||||
AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, setupPose, timelinesRotation, i, firstFrame) {
|
||||
AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, pose, timelinesRotation, i, firstFrame) {
|
||||
if (firstFrame)
|
||||
timelinesRotation[i] = 0;
|
||||
if (alpha == 1) {
|
||||
timeline.apply(skeleton, 0, time, null, 1, setupPose, false);
|
||||
timeline.apply(skeleton, 0, time, null, 1, pose, spine.MixDirection.in);
|
||||
return;
|
||||
}
|
||||
var rotateTimeline = timeline;
|
||||
var frames = rotateTimeline.frames;
|
||||
var bone = skeleton.bones[rotateTimeline.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
if (pose == spine.MixPose.setup)
|
||||
bone.rotation = bone.data.rotation;
|
||||
return;
|
||||
}
|
||||
@ -1261,7 +1339,7 @@ var spine;
|
||||
r2 = prevRotation + r2 * percent + bone.data.rotation;
|
||||
r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
|
||||
}
|
||||
var r1 = setupPose ? bone.data.rotation : bone.rotation;
|
||||
var r1 = pose == spine.MixPose.setup ? bone.data.rotation : bone.rotation;
|
||||
var total = 0, diff = r2 - r1;
|
||||
if (diff == 0) {
|
||||
total = timelinesRotation[i];
|
||||
@ -1950,6 +2028,7 @@ var spine;
|
||||
__extends(VertexAttachment, _super);
|
||||
function VertexAttachment(name) {
|
||||
_super.call(this, name);
|
||||
this.id = (VertexAttachment.nextID++ & 65535) << 11;
|
||||
this.worldVerticesLength = 0;
|
||||
}
|
||||
VertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) {
|
||||
@ -2014,6 +2093,7 @@ var spine;
|
||||
VertexAttachment.prototype.applyDeform = function (sourceAttachment) {
|
||||
return this == sourceAttachment;
|
||||
};
|
||||
VertexAttachment.nextID = 0;
|
||||
return VertexAttachment;
|
||||
}(Attachment));
|
||||
spine.VertexAttachment = VertexAttachment;
|
||||
|
||||
File diff suppressed because one or more lines are too long
51
spine-ts/build/spine-widget.d.ts
vendored
51
spine-ts/build/spine-widget.d.ts
vendored
@ -4,14 +4,23 @@ declare module spine {
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
static binarySearch(values: ArrayLike<number>, target: number, step?: number): number;
|
||||
static linearSearch(values: ArrayLike<number>, target: number, step: number): number;
|
||||
}
|
||||
interface Timeline {
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
getPropertyId(): number;
|
||||
}
|
||||
enum MixPose {
|
||||
setup = 0,
|
||||
current = 1,
|
||||
currentLayered = 2,
|
||||
}
|
||||
enum MixDirection {
|
||||
in = 0,
|
||||
out = 1,
|
||||
}
|
||||
enum TimelineType {
|
||||
rotate = 0,
|
||||
translate = 1,
|
||||
@ -43,7 +52,7 @@ declare module spine {
|
||||
getCurveType(frameIndex: number): number;
|
||||
setCurve(frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void;
|
||||
getCurvePercent(frameIndex: number, percent: number): number;
|
||||
abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
abstract apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class RotateTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -55,7 +64,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, degrees: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class TranslateTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -69,17 +78,17 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, x: number, y: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class ScaleTimeline extends TranslateTimeline {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class ShearTimeline extends TranslateTimeline {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class ColorTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -97,7 +106,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class TwoColorTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -121,7 +130,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class AttachmentTimeline implements Timeline {
|
||||
slotIndex: number;
|
||||
@ -131,7 +140,7 @@ declare module spine {
|
||||
getPropertyId(): number;
|
||||
getFrameCount(): number;
|
||||
setFrame(frameIndex: number, time: number, attachmentName: string): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class DeformTimeline extends CurveTimeline {
|
||||
slotIndex: number;
|
||||
@ -141,7 +150,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, vertices: ArrayLike<number>): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class EventTimeline implements Timeline {
|
||||
frames: ArrayLike<number>;
|
||||
@ -150,7 +159,7 @@ declare module spine {
|
||||
getPropertyId(): number;
|
||||
getFrameCount(): number;
|
||||
setFrame(frameIndex: number, event: Event): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class DrawOrderTimeline implements Timeline {
|
||||
frames: ArrayLike<number>;
|
||||
@ -159,7 +168,7 @@ declare module spine {
|
||||
getPropertyId(): number;
|
||||
getFrameCount(): number;
|
||||
setFrame(frameIndex: number, time: number, drawOrder: Array<number>): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class IkConstraintTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -173,7 +182,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, mix: number, bendDirection: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class TransformConstraintTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -191,7 +200,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
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, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class PathConstraintPositionTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -203,12 +212,12 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, value: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class PathConstraintSpacingTimeline extends PathConstraintPositionTimeline {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
class PathConstraintMixTimeline extends CurveTimeline {
|
||||
static ENTRIES: number;
|
||||
@ -222,7 +231,7 @@ declare module spine {
|
||||
constructor(frameCount: number);
|
||||
getPropertyId(): number;
|
||||
setFrame(frameIndex: number, time: number, rotateMix: number, translateMix: number): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply(skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
}
|
||||
declare module spine {
|
||||
@ -246,8 +255,8 @@ declare module spine {
|
||||
update(delta: number): void;
|
||||
updateMixingFrom(to: TrackEntry, delta: number): boolean;
|
||||
apply(skeleton: Skeleton): boolean;
|
||||
applyMixingFrom(to: TrackEntry, skeleton: Skeleton): number;
|
||||
applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, setupPose: boolean, timelinesRotation: Array<number>, i: number, firstFrame: boolean): void;
|
||||
applyMixingFrom(to: TrackEntry, skeleton: Skeleton, currentPose: MixPose): number;
|
||||
applyRotateTimeline(timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, pose: MixPose, timelinesRotation: Array<number>, i: number, firstFrame: boolean): void;
|
||||
queueEvents(entry: TrackEntry, animationTime: number): void;
|
||||
clearTracks(): void;
|
||||
clearTrack(trackIndex: number): void;
|
||||
@ -396,6 +405,8 @@ declare module spine {
|
||||
constructor(name: string);
|
||||
}
|
||||
abstract class VertexAttachment extends Attachment {
|
||||
private static nextID;
|
||||
id: number;
|
||||
bones: Array<number>;
|
||||
vertices: ArrayLike<number>;
|
||||
worldVerticesLength: number;
|
||||
|
||||
@ -15,7 +15,7 @@ var spine;
|
||||
this.timelines = timelines;
|
||||
this.duration = duration;
|
||||
}
|
||||
Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, setupPose, mixingOut) {
|
||||
Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, pose, direction) {
|
||||
if (skeleton == null)
|
||||
throw new Error("skeleton cannot be null.");
|
||||
if (loop && this.duration != 0) {
|
||||
@ -25,7 +25,7 @@ var spine;
|
||||
}
|
||||
var timelines = this.timelines;
|
||||
for (var i = 0, n = timelines.length; i < n; i++)
|
||||
timelines[i].apply(skeleton, lastTime, time, events, alpha, setupPose, mixingOut);
|
||||
timelines[i].apply(skeleton, lastTime, time, events, alpha, pose, direction);
|
||||
};
|
||||
Animation.binarySearch = function (values, target, step) {
|
||||
if (step === void 0) { step = 1; }
|
||||
@ -53,6 +53,17 @@ var spine;
|
||||
return Animation;
|
||||
}());
|
||||
spine.Animation = Animation;
|
||||
(function (MixPose) {
|
||||
MixPose[MixPose["setup"] = 0] = "setup";
|
||||
MixPose[MixPose["current"] = 1] = "current";
|
||||
MixPose[MixPose["currentLayered"] = 2] = "currentLayered";
|
||||
})(spine.MixPose || (spine.MixPose = {}));
|
||||
var MixPose = spine.MixPose;
|
||||
(function (MixDirection) {
|
||||
MixDirection[MixDirection["in"] = 0] = "in";
|
||||
MixDirection[MixDirection["out"] = 1] = "out";
|
||||
})(spine.MixDirection || (spine.MixDirection = {}));
|
||||
var MixDirection = spine.MixDirection;
|
||||
(function (TimelineType) {
|
||||
TimelineType[TimelineType["rotate"] = 0] = "rotate";
|
||||
TimelineType[TimelineType["translate"] = 1] = "translate";
|
||||
@ -167,21 +178,28 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.frames[frameIndex + RotateTimeline.ROTATION] = degrees;
|
||||
};
|
||||
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
bone.rotation = bone.data.rotation;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.rotation = bone.data.rotation;
|
||||
return;
|
||||
case MixPose.current:
|
||||
var r_1 = bone.data.rotation - bone.rotation;
|
||||
r_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360;
|
||||
bone.rotation += r_1 * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) {
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha;
|
||||
else {
|
||||
var r_1 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation;
|
||||
r_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360;
|
||||
bone.rotation += r_1 * alpha;
|
||||
var r_2 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation;
|
||||
r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360;
|
||||
bone.rotation += r_2 * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -192,7 +210,7 @@ var spine;
|
||||
var r = frames[frame + RotateTimeline.ROTATION] - prevRotation;
|
||||
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
|
||||
r = prevRotation + r * percent;
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
|
||||
bone.rotation = bone.data.rotation + r * alpha;
|
||||
}
|
||||
@ -224,13 +242,18 @@ var spine;
|
||||
this.frames[frameIndex + TranslateTimeline.X] = x;
|
||||
this.frames[frameIndex + TranslateTimeline.Y] = y;
|
||||
};
|
||||
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
bone.x = bone.data.x;
|
||||
bone.y = bone.data.y;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.x = bone.data.x;
|
||||
bone.y = bone.data.y;
|
||||
return;
|
||||
case MixPose.current:
|
||||
bone.x += (bone.data.x - bone.x) * alpha;
|
||||
bone.y += (bone.data.y - bone.y) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -248,7 +271,7 @@ var spine;
|
||||
x += (frames[frame + TranslateTimeline.X] - x) * percent;
|
||||
y += (frames[frame + TranslateTimeline.Y] - y) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
bone.x = bone.data.x + x * alpha;
|
||||
bone.y = bone.data.y + y * alpha;
|
||||
}
|
||||
@ -274,13 +297,18 @@ var spine;
|
||||
ScaleTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.scale << 24) + this.boneIndex;
|
||||
};
|
||||
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
bone.scaleX = bone.data.scaleX;
|
||||
bone.scaleY = bone.data.scaleY;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.scaleX = bone.data.scaleX;
|
||||
bone.scaleY = bone.data.scaleY;
|
||||
return;
|
||||
case MixPose.current:
|
||||
bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;
|
||||
bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -304,7 +332,7 @@ var spine;
|
||||
}
|
||||
else {
|
||||
var bx = 0, by = 0;
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
bx = bone.data.scaleX;
|
||||
by = bone.data.scaleY;
|
||||
}
|
||||
@ -312,7 +340,7 @@ var spine;
|
||||
bx = bone.scaleX;
|
||||
by = bone.scaleY;
|
||||
}
|
||||
if (mixingOut) {
|
||||
if (direction == MixDirection.out) {
|
||||
x = Math.abs(x) * spine.MathUtils.signum(bx);
|
||||
y = Math.abs(y) * spine.MathUtils.signum(by);
|
||||
}
|
||||
@ -335,13 +363,18 @@ var spine;
|
||||
ShearTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.shear << 24) + this.boneIndex;
|
||||
};
|
||||
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
bone.shearX = bone.data.shearX;
|
||||
bone.shearY = bone.data.shearY;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.shearX = bone.data.shearX;
|
||||
bone.shearY = bone.data.shearY;
|
||||
return;
|
||||
case MixPose.current:
|
||||
bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
|
||||
bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -359,7 +392,7 @@ var spine;
|
||||
x = x + (frames[frame + ShearTimeline.X] - x) * percent;
|
||||
y = y + (frames[frame + ShearTimeline.Y] - y) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
bone.shearX = bone.data.shearX + x * alpha;
|
||||
bone.shearY = bone.data.shearY + y * alpha;
|
||||
}
|
||||
@ -388,12 +421,18 @@ var spine;
|
||||
this.frames[frameIndex + ColorTimeline.B] = b;
|
||||
this.frames[frameIndex + ColorTimeline.A] = a;
|
||||
};
|
||||
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
return;
|
||||
case MixPose.current:
|
||||
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);
|
||||
}
|
||||
return;
|
||||
}
|
||||
var r = 0, g = 0, b = 0, a = 0;
|
||||
@ -421,7 +460,7 @@ var spine;
|
||||
slot.color.set(r, g, b, a);
|
||||
else {
|
||||
var color = slot.color;
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
color.setFromColor(slot.data.color);
|
||||
color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
|
||||
}
|
||||
@ -459,13 +498,19 @@ var spine;
|
||||
this.frames[frameIndex + TwoColorTimeline.G2] = g2;
|
||||
this.frames[frameIndex + TwoColorTimeline.B2] = b2;
|
||||
};
|
||||
TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
slot.darkColor.setFromColor(slot.data.darkColor);
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
slot.darkColor.setFromColor(slot.data.darkColor);
|
||||
return;
|
||||
case MixPose.current:
|
||||
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);
|
||||
dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -504,9 +549,8 @@ var spine;
|
||||
slot.darkColor.set(r2, g2, b2, 1);
|
||||
}
|
||||
else {
|
||||
var light = slot.color;
|
||||
var dark = slot.darkColor;
|
||||
if (setupPose) {
|
||||
var light = slot.color, dark = slot.darkColor;
|
||||
if (pose == MixPose.setup) {
|
||||
light.setFromColor(slot.data.color);
|
||||
dark.setFromColor(slot.data.darkColor);
|
||||
}
|
||||
@ -548,16 +592,16 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.attachmentNames[frameIndex] = attachmentName;
|
||||
};
|
||||
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, setupPose, mixingOut) {
|
||||
AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
if (mixingOut && setupPose) {
|
||||
if (direction == MixDirection.out && pose == MixPose.setup) {
|
||||
var attachmentName_1 = slot.data.attachmentName;
|
||||
slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1));
|
||||
return;
|
||||
}
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
var attachmentName_2 = slot.data.attachmentName;
|
||||
slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2));
|
||||
}
|
||||
@ -583,35 +627,42 @@ var spine;
|
||||
this.frameVertices = new Array(frameCount);
|
||||
}
|
||||
DeformTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.deform << 24) + this.slotIndex;
|
||||
return (TimelineType.deform << 27) + +this.attachment.id + this.slotIndex;
|
||||
};
|
||||
DeformTimeline.prototype.setFrame = function (frameIndex, time, vertices) {
|
||||
this.frames[frameIndex] = time;
|
||||
this.frameVertices[frameIndex] = vertices;
|
||||
};
|
||||
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
var slotAttachment = slot.getAttachment();
|
||||
if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))
|
||||
return;
|
||||
var frames = this.frames;
|
||||
var verticesArray = slot.attachmentVertices;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
spine.Utils.setArraySize(verticesArray, 0);
|
||||
return;
|
||||
}
|
||||
var frameVertices = this.frameVertices;
|
||||
var vertexCount = frameVertices[0].length;
|
||||
if (verticesArray.length != vertexCount && !setupPose)
|
||||
if (verticesArray.length != vertexCount && pose != MixPose.setup)
|
||||
alpha = 1;
|
||||
var vertices = spine.Utils.setArraySize(verticesArray, vertexCount);
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
verticesArray.length = 0;
|
||||
return;
|
||||
case MixPose.current:
|
||||
alpha = 1 - alpha;
|
||||
for (var i = 0; i < vertexCount; i++)
|
||||
vertices[i] *= alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (time >= frames[frames.length - 1]) {
|
||||
var lastVertices = frameVertices[frames.length - 1];
|
||||
if (alpha == 1) {
|
||||
spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount);
|
||||
}
|
||||
else if (setupPose) {
|
||||
else if (pose == MixPose.setup) {
|
||||
var vertexAttachment = slotAttachment;
|
||||
if (vertexAttachment.bones == null) {
|
||||
var setupVertices = vertexAttachment.vertices;
|
||||
@ -642,7 +693,7 @@ var spine;
|
||||
vertices[i] = prev + (nextVertices[i] - prev) * percent;
|
||||
}
|
||||
}
|
||||
else if (setupPose) {
|
||||
else if (pose == MixPose.setup) {
|
||||
var vertexAttachment = slotAttachment;
|
||||
if (vertexAttachment.bones == null) {
|
||||
var setupVertices = vertexAttachment.vertices;
|
||||
@ -683,13 +734,13 @@ var spine;
|
||||
this.frames[frameIndex] = event.time;
|
||||
this.events[frameIndex] = event;
|
||||
};
|
||||
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
if (firedEvents == null)
|
||||
return;
|
||||
var frames = this.frames;
|
||||
var frameCount = this.frames.length;
|
||||
if (lastTime > time) {
|
||||
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, setupPose, mixingOut);
|
||||
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, pose, direction);
|
||||
lastTime = -1;
|
||||
}
|
||||
else if (lastTime >= frames[frameCount - 1])
|
||||
@ -729,16 +780,16 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.drawOrders[frameIndex] = drawOrder;
|
||||
};
|
||||
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var drawOrder = skeleton.drawOrder;
|
||||
var slots = skeleton.slots;
|
||||
if (mixingOut && setupPose) {
|
||||
if (direction == MixDirection.out && pose == MixPose.setup) {
|
||||
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||
return;
|
||||
}
|
||||
var frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||
return;
|
||||
}
|
||||
@ -773,25 +824,30 @@ var spine;
|
||||
this.frames[frameIndex + IkConstraintTimeline.MIX] = mix;
|
||||
this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection;
|
||||
};
|
||||
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.ikConstraints[this.ikConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
constraint.mix = constraint.data.mix;
|
||||
constraint.bendDirection = constraint.data.bendDirection;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.mix = constraint.data.mix;
|
||||
constraint.bendDirection = constraint.data.bendDirection;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.mix += (constraint.data.mix - constraint.mix) * alpha;
|
||||
constraint.bendDirection = constraint.data.bendDirection;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
|
||||
constraint.bendDirection = mixingOut ? constraint.data.bendDirection
|
||||
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection
|
||||
: frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
else {
|
||||
constraint.mix += (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.mix) * alpha;
|
||||
if (!mixingOut)
|
||||
if (direction == MixDirection.in)
|
||||
constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
return;
|
||||
@ -800,13 +856,13 @@ var spine;
|
||||
var mix = frames[frame + IkConstraintTimeline.PREV_MIX];
|
||||
var frameTime = frames[frame];
|
||||
var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime));
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha;
|
||||
constraint.bendDirection = mixingOut ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
else {
|
||||
constraint.mix += (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.mix) * alpha;
|
||||
if (!mixingOut)
|
||||
if (direction == MixDirection.in)
|
||||
constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
};
|
||||
@ -836,16 +892,23 @@ var spine;
|
||||
this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix;
|
||||
this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix;
|
||||
};
|
||||
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.transformConstraints[this.transformConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
var data = constraint.data;
|
||||
constraint.rotateMix = data.rotateMix;
|
||||
constraint.translateMix = data.rotateMix;
|
||||
constraint.scaleMix = data.scaleMix;
|
||||
constraint.shearMix = data.shearMix;
|
||||
var data = constraint.data;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.rotateMix = data.rotateMix;
|
||||
constraint.translateMix = data.translateMix;
|
||||
constraint.scaleMix = data.scaleMix;
|
||||
constraint.shearMix = data.shearMix;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha;
|
||||
constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha;
|
||||
constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha;
|
||||
constraint.shearMix += (data.shearMix - constraint.shearMix) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -870,7 +933,7 @@ var spine;
|
||||
scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent;
|
||||
shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
var data = constraint.data;
|
||||
constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha;
|
||||
constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha;
|
||||
@ -911,12 +974,17 @@ var spine;
|
||||
this.frames[frameIndex] = time;
|
||||
this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value;
|
||||
};
|
||||
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
constraint.position = constraint.data.position;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.position = constraint.data.position;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.position += (constraint.data.position - constraint.position) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
var position = 0;
|
||||
@ -929,7 +997,7 @@ var spine;
|
||||
var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime));
|
||||
position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent;
|
||||
}
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
constraint.position = constraint.data.position + (position - constraint.data.position) * alpha;
|
||||
else
|
||||
constraint.position += (position - constraint.position) * alpha;
|
||||
@ -949,12 +1017,17 @@ var spine;
|
||||
PathConstraintSpacingTimeline.prototype.getPropertyId = function () {
|
||||
return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex;
|
||||
};
|
||||
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
constraint.spacing = constraint.data.spacing;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.spacing = constraint.data.spacing;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
var spacing = 0;
|
||||
@ -967,7 +1040,7 @@ var spine;
|
||||
var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime));
|
||||
spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent;
|
||||
}
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;
|
||||
else
|
||||
constraint.spacing += (spacing - constraint.spacing) * alpha;
|
||||
@ -990,13 +1063,18 @@ var spine;
|
||||
this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix;
|
||||
this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix;
|
||||
};
|
||||
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, setupPose, mixingOut) {
|
||||
PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {
|
||||
var frames = this.frames;
|
||||
var constraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
constraint.rotateMix = constraint.data.rotateMix;
|
||||
constraint.translateMix = constraint.data.translateMix;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.rotateMix = constraint.data.rotateMix;
|
||||
constraint.translateMix = constraint.data.translateMix;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha;
|
||||
constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1014,7 +1092,7 @@ var spine;
|
||||
rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent;
|
||||
translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha;
|
||||
constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha;
|
||||
}
|
||||
@ -1130,9 +1208,10 @@ var spine;
|
||||
if (current == null || current.delay > 0)
|
||||
continue;
|
||||
applied = true;
|
||||
var currentPose = i == 0 ? spine.MixPose.current : spine.MixPose.currentLayered;
|
||||
var mix = current.alpha;
|
||||
if (current.mixingFrom != null)
|
||||
mix *= this.applyMixingFrom(current, skeleton);
|
||||
mix *= this.applyMixingFrom(current, skeleton, currentPose);
|
||||
else if (current.trackTime >= current.trackEnd && current.next == null)
|
||||
mix = 0;
|
||||
var animationLast = current.animationLast, animationTime = current.getAnimationTime();
|
||||
@ -1140,7 +1219,7 @@ var spine;
|
||||
var timelines = current.animation.timelines;
|
||||
if (mix == 1) {
|
||||
for (var ii = 0; ii < timelineCount; ii++)
|
||||
timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, true, false);
|
||||
timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, spine.MixPose.setup, spine.MixDirection.in);
|
||||
}
|
||||
else {
|
||||
var timelineData = current.timelineData;
|
||||
@ -1150,11 +1229,12 @@ var spine;
|
||||
var timelinesRotation = current.timelinesRotation;
|
||||
for (var ii = 0; ii < timelineCount; ii++) {
|
||||
var timeline = timelines[ii];
|
||||
var pose = timelineData[ii] >= AnimationState.FIRST ? spine.MixPose.setup : currentPose;
|
||||
if (timeline instanceof spine.RotateTimeline) {
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineData[ii] >= AnimationState.FIRST, timelinesRotation, ii << 1, firstFrame);
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, mix, pose, timelinesRotation, ii << 1, firstFrame);
|
||||
}
|
||||
else
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineData[ii] >= AnimationState.FIRST, false);
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, mix, pose, spine.MixDirection.in);
|
||||
}
|
||||
}
|
||||
this.queueEvents(current, animationTime);
|
||||
@ -1165,10 +1245,10 @@ var spine;
|
||||
this.queue.drain();
|
||||
return applied;
|
||||
};
|
||||
AnimationState.prototype.applyMixingFrom = function (to, skeleton) {
|
||||
AnimationState.prototype.applyMixingFrom = function (to, skeleton, currentPose) {
|
||||
var from = to.mixingFrom;
|
||||
if (from.mixingFrom != null)
|
||||
this.applyMixingFrom(from, skeleton);
|
||||
this.applyMixingFrom(from, skeleton, currentPose);
|
||||
var mix = 0;
|
||||
if (to.mixDuration == 0)
|
||||
mix = 1;
|
||||
@ -1188,26 +1268,30 @@ var spine;
|
||||
if (firstFrame)
|
||||
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
|
||||
var timelinesRotation = from.timelinesRotation;
|
||||
var first = false;
|
||||
var pose;
|
||||
var alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix), alpha = 0;
|
||||
from.totalAlpha = 0;
|
||||
for (var i = 0; i < timelineCount; i++) {
|
||||
var timeline = timelines[i];
|
||||
switch (timelineData[i]) {
|
||||
case AnimationState.SUBSEQUENT:
|
||||
first = false;
|
||||
if (!attachments && timeline instanceof spine.AttachmentTimeline)
|
||||
continue;
|
||||
if (!drawOrder && timeline instanceof spine.DrawOrderTimeline)
|
||||
continue;
|
||||
pose = currentPose;
|
||||
alpha = alphaMix;
|
||||
break;
|
||||
case AnimationState.FIRST:
|
||||
first = true;
|
||||
pose = spine.MixPose.setup;
|
||||
alpha = alphaMix;
|
||||
break;
|
||||
case AnimationState.DIP:
|
||||
first = true;
|
||||
pose = spine.MixPose.setup;
|
||||
alpha = alphaDip;
|
||||
break;
|
||||
default:
|
||||
first = true;
|
||||
pose = spine.MixPose.setup;
|
||||
alpha = alphaDip;
|
||||
var dipMix = timelineDipMix[i];
|
||||
alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
|
||||
@ -1215,15 +1299,9 @@ var spine;
|
||||
}
|
||||
from.totalAlpha += alpha;
|
||||
if (timeline instanceof spine.RotateTimeline)
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, first, timelinesRotation, i << 1, firstFrame);
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame);
|
||||
else {
|
||||
if (!first) {
|
||||
if (!attachments && timeline instanceof spine.AttachmentTimeline)
|
||||
continue;
|
||||
if (!drawOrder && timeline instanceof spine.DrawOrderTimeline)
|
||||
continue;
|
||||
}
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, alpha, first, true);
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, alpha, pose, spine.MixDirection.out);
|
||||
}
|
||||
}
|
||||
if (to.mixDuration > 0)
|
||||
@ -1233,18 +1311,18 @@ var spine;
|
||||
from.nextTrackLast = from.trackTime;
|
||||
return mix;
|
||||
};
|
||||
AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, setupPose, timelinesRotation, i, firstFrame) {
|
||||
AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, pose, timelinesRotation, i, firstFrame) {
|
||||
if (firstFrame)
|
||||
timelinesRotation[i] = 0;
|
||||
if (alpha == 1) {
|
||||
timeline.apply(skeleton, 0, time, null, 1, setupPose, false);
|
||||
timeline.apply(skeleton, 0, time, null, 1, pose, spine.MixDirection.in);
|
||||
return;
|
||||
}
|
||||
var rotateTimeline = timeline;
|
||||
var frames = rotateTimeline.frames;
|
||||
var bone = skeleton.bones[rotateTimeline.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose)
|
||||
if (pose == spine.MixPose.setup)
|
||||
bone.rotation = bone.data.rotation;
|
||||
return;
|
||||
}
|
||||
@ -1261,7 +1339,7 @@ var spine;
|
||||
r2 = prevRotation + r2 * percent + bone.data.rotation;
|
||||
r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;
|
||||
}
|
||||
var r1 = setupPose ? bone.data.rotation : bone.rotation;
|
||||
var r1 = pose == spine.MixPose.setup ? bone.data.rotation : bone.rotation;
|
||||
var total = 0, diff = r2 - r1;
|
||||
if (diff == 0) {
|
||||
total = timelinesRotation[i];
|
||||
@ -1950,6 +2028,7 @@ var spine;
|
||||
__extends(VertexAttachment, _super);
|
||||
function VertexAttachment(name) {
|
||||
_super.call(this, name);
|
||||
this.id = (VertexAttachment.nextID++ & 65535) << 11;
|
||||
this.worldVerticesLength = 0;
|
||||
}
|
||||
VertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) {
|
||||
@ -2014,6 +2093,7 @@ var spine;
|
||||
VertexAttachment.prototype.applyDeform = function (sourceAttachment) {
|
||||
return this == sourceAttachment;
|
||||
};
|
||||
VertexAttachment.nextID = 0;
|
||||
return VertexAttachment;
|
||||
}(Attachment));
|
||||
spine.VertexAttachment = VertexAttachment;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -42,7 +42,7 @@ module spine {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, loop: boolean, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection) {
|
||||
if (skeleton == null) throw new Error("skeleton cannot be null.");
|
||||
|
||||
if (loop && this.duration != 0) {
|
||||
@ -52,7 +52,7 @@ module spine {
|
||||
|
||||
let timelines = this.timelines;
|
||||
for (let i = 0, n = timelines.length; i < n; i++)
|
||||
timelines[i].apply(skeleton, lastTime, time, events, alpha, setupPose, mixingOut);
|
||||
timelines[i].apply(skeleton, lastTime, time, events, alpha, pose, direction);
|
||||
}
|
||||
|
||||
static binarySearch (values: ArrayLike<number>, target: number, step: number = 1) {
|
||||
@ -78,10 +78,20 @@ module spine {
|
||||
}
|
||||
|
||||
export interface Timeline {
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
getPropertyId (): number;
|
||||
}
|
||||
|
||||
export enum MixPose {
|
||||
setup,
|
||||
current,
|
||||
currentLayered
|
||||
}
|
||||
|
||||
export enum MixDirection {
|
||||
in, out
|
||||
}
|
||||
|
||||
export enum TimelineType {
|
||||
rotate, translate, scale, shear,
|
||||
attachment, color, deform,
|
||||
@ -178,7 +188,7 @@ module spine {
|
||||
return y + (1 - y) * (percent - x) / (1 - x); // Last point is 1,1.
|
||||
}
|
||||
|
||||
abstract apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean): void;
|
||||
abstract apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection): void;
|
||||
}
|
||||
|
||||
export class RotateTimeline extends CurveTimeline {
|
||||
@ -205,17 +215,25 @@ module spine {
|
||||
this.frames[frameIndex + RotateTimeline.ROTATION] = degrees;
|
||||
}
|
||||
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection) {
|
||||
let frames = this.frames;
|
||||
|
||||
let bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) bone.rotation = bone.data.rotation;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.rotation = bone.data.rotation;
|
||||
return;
|
||||
case MixPose.current:
|
||||
let r = bone.data.rotation - bone.rotation;
|
||||
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
|
||||
bone.rotation += r * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (time >= frames[frames.length - RotateTimeline.ENTRIES]) { // Time is after last frame.
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha;
|
||||
else {
|
||||
let r = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation;
|
||||
@ -235,7 +253,7 @@ module spine {
|
||||
let r = frames[frame + RotateTimeline.ROTATION] - prevRotation;
|
||||
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
|
||||
r = prevRotation + r * percent;
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;
|
||||
bone.rotation = bone.data.rotation + r * alpha;
|
||||
} else {
|
||||
@ -271,14 +289,19 @@ module spine {
|
||||
this.frames[frameIndex + TranslateTimeline.Y] = y;
|
||||
}
|
||||
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection) {
|
||||
let frames = this.frames;
|
||||
|
||||
let bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.x = bone.data.x;
|
||||
bone.y = bone.data.y;
|
||||
return;
|
||||
case MixPose.current:
|
||||
bone.x += (bone.data.x - bone.x) * alpha;
|
||||
bone.y += (bone.data.y - bone.y) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -299,7 +322,7 @@ module spine {
|
||||
x += (frames[frame + TranslateTimeline.X] - x) * percent;
|
||||
y += (frames[frame + TranslateTimeline.Y] - y) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
bone.x = bone.data.x + x * alpha;
|
||||
bone.y = bone.data.y + y * alpha;
|
||||
} else {
|
||||
@ -318,14 +341,19 @@ module spine {
|
||||
return (TimelineType.scale << 24) + this.boneIndex;
|
||||
}
|
||||
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection) {
|
||||
let frames = this.frames;
|
||||
|
||||
let bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.scaleX = bone.data.scaleX;
|
||||
bone.scaleY = bone.data.scaleY;
|
||||
return;
|
||||
case MixPose.current:
|
||||
bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;
|
||||
bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -351,7 +379,7 @@ module spine {
|
||||
bone.scaleY = y;
|
||||
} else {
|
||||
let bx = 0, by = 0;
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
bx = bone.data.scaleX;
|
||||
by = bone.data.scaleY;
|
||||
} else {
|
||||
@ -359,7 +387,7 @@ module spine {
|
||||
by = bone.scaleY;
|
||||
}
|
||||
// Mixing out uses sign of setup or current pose, else use sign of key.
|
||||
if (mixingOut) {
|
||||
if (direction == MixDirection.out) {
|
||||
x = Math.abs(x) * MathUtils.signum(bx);
|
||||
y = Math.abs(y) * MathUtils.signum(by);
|
||||
} else {
|
||||
@ -381,14 +409,19 @@ module spine {
|
||||
return (TimelineType.shear << 24) + this.boneIndex;
|
||||
}
|
||||
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection) {
|
||||
let frames = this.frames;
|
||||
|
||||
let bone = skeleton.bones[this.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
bone.shearX = bone.data.shearX;
|
||||
bone.shearY = bone.data.shearY;
|
||||
return;
|
||||
case MixPose.current:
|
||||
bone.shearX += (bone.data.shearX - bone.shearX) * alpha;
|
||||
bone.shearY += (bone.data.shearY - bone.shearY) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -409,7 +442,7 @@ module spine {
|
||||
x = x + (frames[frame + ShearTimeline.X] - x) * percent;
|
||||
y = y + (frames[frame + ShearTimeline.Y] - y) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
bone.shearX = bone.data.shearX + x * alpha;
|
||||
bone.shearY = bone.data.shearY + y * alpha;
|
||||
} else {
|
||||
@ -446,11 +479,19 @@ module spine {
|
||||
this.frames[frameIndex + ColorTimeline.A] = a;
|
||||
}
|
||||
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection) {
|
||||
let slot = skeleton.slots[this.slotIndex];
|
||||
let frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) slot.color.setFromColor(slot.data.color);
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
return;
|
||||
case MixPose.current:
|
||||
let 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);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -481,7 +522,7 @@ module spine {
|
||||
slot.color.set(r, g, b, a);
|
||||
else {
|
||||
let color = slot.color;
|
||||
if (setupPose) color.setFromColor(slot.data.color);
|
||||
if (pose == MixPose.setup) color.setFromColor(slot.data.color);
|
||||
color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
|
||||
}
|
||||
}
|
||||
@ -518,13 +559,20 @@ module spine {
|
||||
this.frames[frameIndex + TwoColorTimeline.B2] = b2;
|
||||
}
|
||||
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection) {
|
||||
let slot = skeleton.slots[this.slotIndex];
|
||||
let frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
slot.color.setFromColor(slot.data.color);
|
||||
slot.darkColor.setFromColor(slot.data.darkColor);
|
||||
return;
|
||||
case MixPose.current:
|
||||
let 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);
|
||||
dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -565,9 +613,8 @@ module spine {
|
||||
slot.color.set(r, g, b, a);
|
||||
slot.darkColor.set(r2, g2, b2, 1);
|
||||
} else {
|
||||
let light = slot.color;
|
||||
let dark = slot.darkColor;
|
||||
if (setupPose) {
|
||||
let light = slot.color, dark = slot.darkColor;
|
||||
if (pose == MixPose.setup) {
|
||||
light.setFromColor(slot.data.color);
|
||||
dark.setFromColor(slot.data.darkColor);
|
||||
}
|
||||
@ -601,9 +648,9 @@ module spine {
|
||||
this.attachmentNames[frameIndex] = attachmentName;
|
||||
}
|
||||
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, events: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection) {
|
||||
let slot = skeleton.slots[this.slotIndex];
|
||||
if (mixingOut && setupPose) {
|
||||
if (direction == MixDirection.out && pose == MixPose.setup) {
|
||||
let attachmentName = slot.data.attachmentName;
|
||||
slot.setAttachment(attachmentName == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName));
|
||||
return;
|
||||
@ -611,7 +658,7 @@ module spine {
|
||||
|
||||
let frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
let attachmentName = slot.data.attachmentName;
|
||||
slot.setAttachment(attachmentName == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName));
|
||||
}
|
||||
@ -643,7 +690,7 @@ module spine {
|
||||
}
|
||||
|
||||
getPropertyId () {
|
||||
return (TimelineType.deform << 24) + this.slotIndex;
|
||||
return (TimelineType.deform << 27) + + this.attachment.id + this.slotIndex;
|
||||
}
|
||||
|
||||
/** Sets the time of the specified keyframe. */
|
||||
@ -652,29 +699,36 @@ module spine {
|
||||
this.frameVertices[frameIndex] = vertices;
|
||||
}
|
||||
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection) {
|
||||
let slot: Slot = skeleton.slots[this.slotIndex];
|
||||
let slotAttachment: Attachment = slot.getAttachment();
|
||||
if (!(slotAttachment instanceof VertexAttachment) || !(<VertexAttachment>slotAttachment).applyDeform(this.attachment)) return;
|
||||
|
||||
let verticesArray: Array<number> = slot.attachmentVertices;
|
||||
let frameVertices = this.frameVertices;
|
||||
let vertexCount = frameVertices[0].length;
|
||||
if (verticesArray.length != vertexCount && pose != MixPose.setup) alpha = 1; // Don't mix from uninitialized slot vertices.
|
||||
let vertices: Array<number> = Utils.setArraySize(verticesArray, vertexCount);
|
||||
|
||||
let frames = this.frames;
|
||||
let verticesArray: Array<number> = slot.attachmentVertices;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) Utils.setArraySize(verticesArray, 0);
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
verticesArray.length = 0;
|
||||
return;
|
||||
case MixPose.current:
|
||||
alpha = 1 - alpha;
|
||||
for (let i = 0; i < vertexCount; i++)
|
||||
vertices[i] *= alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let frameVertices = this.frameVertices;
|
||||
let vertexCount = frameVertices[0].length;
|
||||
|
||||
if (verticesArray.length != vertexCount && !setupPose) alpha = 1; // Don't mix from uninitialized slot vertices.
|
||||
let vertices: Array<number> = Utils.setArraySize(verticesArray, vertexCount);
|
||||
}
|
||||
|
||||
if (time >= frames[frames.length - 1]) { // Time is after last frame.
|
||||
let lastVertices = frameVertices[frames.length - 1];
|
||||
if (alpha == 1) {
|
||||
Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount);
|
||||
} else if (setupPose) {
|
||||
} else if (pose == MixPose.setup) {
|
||||
let vertexAttachment = slotAttachment as VertexAttachment;
|
||||
if (vertexAttachment.bones == null) {
|
||||
// Unweighted vertex positions, with alpha.
|
||||
@ -707,7 +761,7 @@ module spine {
|
||||
let prev = prevVertices[i];
|
||||
vertices[i] = prev + (nextVertices[i] - prev) * percent;
|
||||
}
|
||||
} else if (setupPose) {
|
||||
} else if (pose == MixPose.setup) {
|
||||
let vertexAttachment = slotAttachment as VertexAttachment;
|
||||
if (vertexAttachment.bones == null) {
|
||||
// Unweighted vertex positions, with alpha.
|
||||
@ -757,13 +811,13 @@ module spine {
|
||||
}
|
||||
|
||||
/** Fires events for frames > lastTime and <= time. */
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection) {
|
||||
if (firedEvents == null) return;
|
||||
let frames = this.frames;
|
||||
let frameCount = this.frames.length;
|
||||
|
||||
if (lastTime > time) { // Fire events after last time for looped animations.
|
||||
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, setupPose, mixingOut);
|
||||
this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, pose, direction);
|
||||
lastTime = -1;
|
||||
} else if (lastTime >= frames[frameCount - 1]) // Last time is after last frame.
|
||||
return;
|
||||
@ -809,17 +863,17 @@ module spine {
|
||||
this.drawOrders[frameIndex] = drawOrder;
|
||||
}
|
||||
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection) {
|
||||
let drawOrder: Array<Slot> = skeleton.drawOrder;
|
||||
let slots: Array<Slot> = skeleton.slots;
|
||||
if (mixingOut && setupPose) {
|
||||
if (direction == MixDirection.out && pose == MixPose.setup) {
|
||||
Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||
return;
|
||||
}
|
||||
|
||||
let frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||
if (pose == MixPose.setup) Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -864,25 +918,30 @@ module spine {
|
||||
this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection;
|
||||
}
|
||||
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection) {
|
||||
let frames = this.frames;
|
||||
let constraint: IkConstraint = skeleton.ikConstraints[this.ikConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.mix = constraint.data.mix;
|
||||
constraint.bendDirection = constraint.data.bendDirection;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.mix += (constraint.data.mix - constraint.mix) * alpha;
|
||||
constraint.bendDirection = constraint.data.bendDirection;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) { // Time is after last frame.
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;
|
||||
constraint.bendDirection = mixingOut ? constraint.data.bendDirection
|
||||
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection
|
||||
: frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
} else {
|
||||
constraint.mix += (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.mix) * alpha;
|
||||
if (!mixingOut) constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
if (direction == MixDirection.in) constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -894,12 +953,12 @@ module spine {
|
||||
let percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1,
|
||||
1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime));
|
||||
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha;
|
||||
constraint.bendDirection = mixingOut ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
} else {
|
||||
constraint.mix += (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.mix) * alpha;
|
||||
if (!mixingOut) constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
if (direction == MixDirection.in) constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -931,17 +990,24 @@ module spine {
|
||||
this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix;
|
||||
}
|
||||
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection) {
|
||||
let frames = this.frames;
|
||||
|
||||
let constraint: TransformConstraint = skeleton.transformConstraints[this.transformConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
let data = constraint.data;
|
||||
let data = constraint.data;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.rotateMix = data.rotateMix;
|
||||
constraint.translateMix = data.rotateMix;
|
||||
constraint.translateMix = data.translateMix;
|
||||
constraint.scaleMix = data.scaleMix;
|
||||
constraint.shearMix = data.shearMix;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha;
|
||||
constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha;
|
||||
constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha;
|
||||
constraint.shearMix += (data.shearMix - constraint.shearMix) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -969,7 +1035,7 @@ module spine {
|
||||
scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent;
|
||||
shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent;
|
||||
}
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
let data = constraint.data;
|
||||
constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha;
|
||||
constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha;
|
||||
@ -1009,11 +1075,17 @@ module spine {
|
||||
this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value;
|
||||
}
|
||||
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection) {
|
||||
let frames = this.frames;
|
||||
let constraint: PathConstraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) constraint.position = constraint.data.position;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.position = constraint.data.position;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.position += (constraint.data.position - constraint.position) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1030,7 +1102,7 @@ module spine {
|
||||
|
||||
position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent;
|
||||
}
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
constraint.position = constraint.data.position + (position - constraint.data.position) * alpha;
|
||||
else
|
||||
constraint.position += (position - constraint.position) * alpha;
|
||||
@ -1046,11 +1118,17 @@ module spine {
|
||||
return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex;
|
||||
}
|
||||
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection) {
|
||||
let frames = this.frames;
|
||||
let constraint: PathConstraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) constraint.spacing = constraint.data.spacing;
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.spacing = constraint.data.spacing;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1068,7 +1146,7 @@ module spine {
|
||||
spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent;
|
||||
}
|
||||
|
||||
if (setupPose)
|
||||
if (pose == MixPose.setup)
|
||||
constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;
|
||||
else
|
||||
constraint.spacing += (spacing - constraint.spacing) * alpha;
|
||||
@ -1101,14 +1179,19 @@ module spine {
|
||||
this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix;
|
||||
}
|
||||
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, setupPose: boolean, mixingOut: boolean) {
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, pose: MixPose, direction: MixDirection) {
|
||||
let frames = this.frames;
|
||||
let constraint: PathConstraint = skeleton.pathConstraints[this.pathConstraintIndex];
|
||||
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) {
|
||||
switch (pose) {
|
||||
case MixPose.setup:
|
||||
constraint.rotateMix = constraint.data.rotateMix;
|
||||
constraint.translateMix = constraint.data.translateMix;
|
||||
return;
|
||||
case MixPose.current:
|
||||
constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha;
|
||||
constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1130,7 +1213,7 @@ module spine {
|
||||
translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent;
|
||||
}
|
||||
|
||||
if (setupPose) {
|
||||
if (pose == MixPose.setup) {
|
||||
constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha;
|
||||
constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha;
|
||||
} else {
|
||||
|
||||
@ -143,11 +143,12 @@ module spine {
|
||||
let current = tracks[i];
|
||||
if (current == null || current.delay > 0) continue;
|
||||
applied = true;
|
||||
let currentPose = i == 0 ? MixPose.current : MixPose.currentLayered;
|
||||
|
||||
// Apply mixing from entries first.
|
||||
let mix = current.alpha;
|
||||
if (current.mixingFrom != null)
|
||||
mix *= this.applyMixingFrom(current, skeleton);
|
||||
mix *= this.applyMixingFrom(current, skeleton, currentPose);
|
||||
else if (current.trackTime >= current.trackEnd && current.next == null)
|
||||
mix = 0;
|
||||
|
||||
@ -157,7 +158,7 @@ module spine {
|
||||
let timelines = current.animation.timelines;
|
||||
if (mix == 1) {
|
||||
for (let ii = 0; ii < timelineCount; ii++)
|
||||
timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, true, false);
|
||||
timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, MixPose.setup, MixDirection.in);
|
||||
} else {
|
||||
let timelineData = current.timelineData;
|
||||
|
||||
@ -167,11 +168,11 @@ module spine {
|
||||
|
||||
for (let ii = 0; ii < timelineCount; ii++) {
|
||||
let timeline = timelines[ii];
|
||||
let pose = timelineData[ii] >= AnimationState.FIRST ? MixPose.setup : currentPose;
|
||||
if (timeline instanceof RotateTimeline) {
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, mix, timelineData[ii] >= AnimationState.FIRST, timelinesRotation, ii << 1,
|
||||
firstFrame);
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, mix, pose, timelinesRotation, ii << 1, firstFrame);
|
||||
} else
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, mix, timelineData[ii] >= AnimationState.FIRST, false);
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, mix, pose, MixDirection.in);
|
||||
}
|
||||
}
|
||||
this.queueEvents(current, animationTime);
|
||||
@ -184,9 +185,9 @@ module spine {
|
||||
return applied;
|
||||
}
|
||||
|
||||
applyMixingFrom (to: TrackEntry, skeleton: Skeleton) {
|
||||
applyMixingFrom (to: TrackEntry, skeleton: Skeleton, currentPose: MixPose) {
|
||||
let from = to.mixingFrom;
|
||||
if (from.mixingFrom != null) this.applyMixingFrom(from, skeleton);
|
||||
if (from.mixingFrom != null) this.applyMixingFrom(from, skeleton, currentPose);
|
||||
|
||||
let mix = 0;
|
||||
if (to.mixDuration == 0) // Single frame mix to undo mixingFrom changes.
|
||||
@ -207,27 +208,29 @@ module spine {
|
||||
let firstFrame = from.timelinesRotation.length == 0;
|
||||
if (firstFrame) Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
|
||||
let timelinesRotation = from.timelinesRotation;
|
||||
|
||||
let first = false;
|
||||
|
||||
let pose: MixPose;
|
||||
let alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix), alpha = 0;
|
||||
from.totalAlpha = 0;
|
||||
for (var i = 0; i < timelineCount; i++) {
|
||||
let timeline = timelines[i];
|
||||
switch (timelineData[i]) {
|
||||
case AnimationState.SUBSEQUENT:
|
||||
first = false;
|
||||
if (!attachments && timeline instanceof AttachmentTimeline) continue;
|
||||
if (!drawOrder && timeline instanceof DrawOrderTimeline) continue;
|
||||
pose = currentPose;
|
||||
alpha = alphaMix;
|
||||
break;
|
||||
case AnimationState.FIRST:
|
||||
first = true;
|
||||
pose = MixPose.setup
|
||||
alpha = alphaMix;
|
||||
break;
|
||||
case AnimationState.DIP:
|
||||
first = true;
|
||||
pose = MixPose.setup;
|
||||
alpha = alphaDip;
|
||||
break;
|
||||
default:
|
||||
first = true;
|
||||
pose = MixPose.setup;
|
||||
alpha = alphaDip;
|
||||
let dipMix = timelineDipMix[i];
|
||||
alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration);
|
||||
@ -235,13 +238,9 @@ module spine {
|
||||
}
|
||||
from.totalAlpha += alpha;
|
||||
if (timeline instanceof RotateTimeline)
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, first, timelinesRotation, i << 1, firstFrame);
|
||||
else {
|
||||
if (!first) {
|
||||
if (!attachments && timeline instanceof AttachmentTimeline) continue;
|
||||
if (!drawOrder && timeline instanceof DrawOrderTimeline) continue;
|
||||
}
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, alpha, first, true);
|
||||
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame);
|
||||
else {
|
||||
timeline.apply(skeleton, animationLast, animationTime, events, alpha, pose, MixDirection.out);
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,13 +252,13 @@ module spine {
|
||||
return mix;
|
||||
}
|
||||
|
||||
applyRotateTimeline (timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, setupPose: boolean,
|
||||
applyRotateTimeline (timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, pose: MixPose,
|
||||
timelinesRotation: Array<number>, i: number, firstFrame: boolean) {
|
||||
|
||||
if (firstFrame) timelinesRotation[i] = 0;
|
||||
|
||||
if (alpha == 1) {
|
||||
timeline.apply(skeleton, 0, time, null, 1, setupPose, false);
|
||||
timeline.apply(skeleton, 0, time, null, 1, pose, MixDirection.in);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -267,7 +266,7 @@ module spine {
|
||||
let frames = rotateTimeline.frames;
|
||||
let bone = skeleton.bones[rotateTimeline.boneIndex];
|
||||
if (time < frames[0]) {
|
||||
if (setupPose) bone.rotation = bone.data.rotation;
|
||||
if (pose == MixPose.setup) bone.rotation = bone.data.rotation;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -289,7 +288,7 @@ module spine {
|
||||
}
|
||||
|
||||
// Mix between rotations using the direction of the shortest route on the first frame while detecting crosses.
|
||||
let r1 = setupPose ? bone.data.rotation : bone.rotation;
|
||||
let r1 = pose == MixPose.setup ? bone.data.rotation : bone.rotation;
|
||||
let total = 0, diff = r2 - r1;
|
||||
if (diff == 0) {
|
||||
total = timelinesRotation[i];
|
||||
|
||||
@ -39,6 +39,9 @@ module spine {
|
||||
}
|
||||
|
||||
export abstract class VertexAttachment extends Attachment {
|
||||
private static nextID = 0;
|
||||
|
||||
id = (VertexAttachment.nextID++ & 65535) << 11;
|
||||
bones: Array<number>;
|
||||
vertices: ArrayLike<number>;
|
||||
worldVerticesLength = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user