mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[ts] Clean up, build fixes.
This commit is contained in:
parent
9e00e5c701
commit
551f33b2d1
@ -81,10 +81,10 @@ package spine.examples {
|
||||
skeleton.state.apply(skeleton.skeleton);
|
||||
skeleton.skeleton.updateWorldTransform();
|
||||
this.setRequiresRedraw();
|
||||
|
||||
|
||||
// skeleton.vertexEffect = new JitterEffect(10, 10);
|
||||
swirl = new SwirlEffect(400);
|
||||
swirl.centerY = -200;
|
||||
swirl.centerY = -200;
|
||||
skeleton.vertexEffect = swirl;
|
||||
|
||||
addChild(skeleton);
|
||||
|
||||
3790
spine-ts/build/spine-all.d.ts
vendored
3790
spine-ts/build/spine-all.d.ts
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2612
spine-ts/build/spine-canvas.d.ts
vendored
2612
spine-ts/build/spine-canvas.d.ts
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
2562
spine-ts/build/spine-core.d.ts
vendored
2562
spine-ts/build/spine-core.d.ts
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
3686
spine-ts/build/spine-player.d.ts
vendored
3686
spine-ts/build/spine-player.d.ts
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2676
spine-ts/build/spine-threejs.d.ts
vendored
2676
spine-ts/build/spine-threejs.d.ts
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
3378
spine-ts/build/spine-webgl.d.ts
vendored
3378
spine-ts/build/spine-webgl.d.ts
vendored
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -111,13 +111,31 @@ module spine {
|
||||
mixIn, mixOut
|
||||
}
|
||||
|
||||
export enum Property {
|
||||
rotate, x, y, scaleX, scaleY, shearX, shearY, //
|
||||
rgb, alpha, rgb2, //
|
||||
attachment, deform, //
|
||||
event, drawOrder, //
|
||||
ikConstraint, transformConstraint, //
|
||||
pathConstraintPosition, pathConstraintSpacing, pathConstraintMix
|
||||
const Property = {
|
||||
rotate: 0,
|
||||
x: 1,
|
||||
y: 2,
|
||||
scaleX: 3,
|
||||
scaleY: 4,
|
||||
shearX: 5,
|
||||
shearY: 6,
|
||||
|
||||
rgb: 7,
|
||||
alpha: 8,
|
||||
rgb2: 9,
|
||||
|
||||
attachment: 10,
|
||||
deform: 11,
|
||||
|
||||
event: 12,
|
||||
drawOrder: 13,
|
||||
|
||||
ikConstraint: 14,
|
||||
transformConstraint: 15,
|
||||
|
||||
pathConstraintPosition: 16,
|
||||
pathConstraintSpacing: 17,
|
||||
pathConstraintMix: 18
|
||||
}
|
||||
|
||||
/** The interface for all timelines. */
|
||||
@ -173,33 +191,33 @@ module spine {
|
||||
slotIndex: number;
|
||||
}
|
||||
|
||||
const LINEAR = 0; const STEPPED = 1; const BEZIER = 2;
|
||||
const BEZIER_SIZE = 18;
|
||||
|
||||
/** The base class for timelines that use interpolation between key frame values. */
|
||||
export abstract class CurveTimeline extends Timeline {
|
||||
static LINEAR = 0; static STEPPED = 1; static BEZIER = 2;
|
||||
static BEZIER_SIZE = 18;
|
||||
|
||||
protected curves: ArrayLike<number>; // type, x, y, ...
|
||||
|
||||
constructor (frameCount: number, bezierCount: number, propertyIds: string[]) {
|
||||
super(frameCount, propertyIds);
|
||||
this.curves = Utils.newFloatArray(frameCount + bezierCount * CurveTimeline.BEZIER_SIZE);
|
||||
this.curves[frameCount - 1] = CurveTimeline.STEPPED;
|
||||
this.curves = Utils.newFloatArray(frameCount + bezierCount * BEZIER_SIZE);
|
||||
this.curves[frameCount - 1] = STEPPED;
|
||||
}
|
||||
|
||||
/** Sets the specified key frame to linear interpolation. */
|
||||
setLinear (frame: number) {
|
||||
this.curves[frame] = CurveTimeline.LINEAR;
|
||||
this.curves[frame] = LINEAR;
|
||||
}
|
||||
|
||||
/** Sets the specified key frame to stepped interpolation. */
|
||||
setStepped (frame: number) {
|
||||
this.curves[frame] = CurveTimeline.STEPPED;
|
||||
this.curves[frame] = STEPPED;
|
||||
}
|
||||
|
||||
/** Shrinks the storage for Bezier curves, for use when <code>bezierCount</code> (specified in the constructor) was larger
|
||||
* than the actual number of Bezier curves. */
|
||||
shrink (bezierCount: number) {
|
||||
let size = this.getFrameCount() + bezierCount * CurveTimeline.BEZIER_SIZE;
|
||||
let size = this.getFrameCount() + bezierCount * BEZIER_SIZE;
|
||||
if (this.curves.length > size) {
|
||||
let newCurves = Utils.newFloatArray(size);
|
||||
Utils.arrayCopy(this.curves, 0, newCurves, 0, size);
|
||||
@ -224,14 +242,14 @@ module spine {
|
||||
setBezier (bezier: number, frame: number, value: number, time1: number, value1: number, cx1: number, cy1: number, cx2: number,
|
||||
cy2: number, time2: number, value2: number) {
|
||||
let curves = this.curves;
|
||||
let i = this.getFrameCount() + bezier * CurveTimeline.BEZIER_SIZE;
|
||||
if (value == 0) curves[frame] = CurveTimeline.BEZIER + i;
|
||||
let i = this.getFrameCount() + bezier * BEZIER_SIZE;
|
||||
if (value == 0) curves[frame] = BEZIER + i;
|
||||
let tmpx = (time1 - cx1 * 2 + cx2) * 0.03, tmpy = (value1 - cy1 * 2 + cy2) * 0.03;
|
||||
let dddx = ((cx1 - cx2) * 3 - time1 + time2) * 0.006, dddy = ((cy1 - cy2) * 3 - value1 + value2) * 0.006;
|
||||
let ddx = tmpx * 2 + dddx, ddy = tmpy * 2 + dddy;
|
||||
let dx = (cx1 - time1) * 0.3 + tmpx + dddx * 0.16666667, dy = (cy1 - value1) * 0.3 + tmpy + dddy * 0.16666667;
|
||||
let x = time1 + dx, y = value1 + dy;
|
||||
for (let n = i + CurveTimeline.BEZIER_SIZE; i < n; i += 2) {
|
||||
for (let n = i + BEZIER_SIZE; i < n; i += 2) {
|
||||
curves[i] = x;
|
||||
curves[i + 1] = y;
|
||||
dx += ddx;
|
||||
@ -250,10 +268,10 @@ module spine {
|
||||
getBezierValue (time: number, frameIndex: number, valueOffset: number, i: number) {
|
||||
let curves = this.curves;
|
||||
if (curves[i] > time) {
|
||||
let x = frames[frameIndex], y = frames[frameIndex + valueOffset];
|
||||
let x = this.frames[frameIndex], y = this.frames[frameIndex + valueOffset];
|
||||
return y + (time - x) / (curves[i] - x) * (curves[i + 1] - y);
|
||||
}
|
||||
let n = i + CurveTimeline.BEZIER_SIZE;
|
||||
let n = i + BEZIER_SIZE;
|
||||
for (i += 2; i < n; i += 2) {
|
||||
if (curves[i] >= time) {
|
||||
let x = curves[i - 2], y = curves[i - 1];
|
||||
@ -262,7 +280,7 @@ module spine {
|
||||
}
|
||||
frameIndex += this.getFrameEntries();
|
||||
let x = curves[n - 2], y = curves[n - 1];
|
||||
return y + (time - x) / (frames[frameIndex] - x) * (frames[frameIndex + valueOffset] - y);
|
||||
return y + (time - x) / (this.frames[frameIndex] - x) * (this.frames[frameIndex + valueOffset] - y);
|
||||
}
|
||||
}
|
||||
|
||||
@ -300,21 +318,20 @@ module spine {
|
||||
|
||||
let curveType = this.curves[i >> 1];
|
||||
switch (curveType) {
|
||||
case CurveTimeline.LINEAR:
|
||||
case LINEAR:
|
||||
let before = frames[i], value = frames[i + CurveTimeline1.VALUE];
|
||||
return value + (time - before) / (frames[i + CurveTimeline1.ENTRIES] - before) * (frames[i + CurveTimeline1.ENTRIES + CurveTimeline1.VALUE] - value);
|
||||
case CurveTimeline.STEPPED:
|
||||
case STEPPED:
|
||||
return frames[i + CurveTimeline1.VALUE];
|
||||
}
|
||||
return this.getBezierValue(time, i, CurveTimeline1.VALUE, curveType - CurveTimeline.BEZIER);
|
||||
return this.getBezierValue(time, i, CurveTimeline1.VALUE, curveType - BEZIER);
|
||||
}
|
||||
}
|
||||
|
||||
/** The base class for a {@link CurveTimeline} which sets two properties. */
|
||||
export abstract class CurveTimeline2 extends CurveTimeline {
|
||||
static ENTRIES = 3;
|
||||
static VALUE1 = 1;
|
||||
static VALUE2 = 2;
|
||||
static VALUE1 = 1; static VALUE2 = 2;
|
||||
|
||||
/** @param bezierCount The maximum number of Bezier curves. See {@link #shrink(int)}.
|
||||
* @param propertyIds Unique identifiers for the properties the timeline modifies. */
|
||||
@ -412,7 +429,7 @@ module spine {
|
||||
let i = Timeline.search2(frames, time, CurveTimeline2.ENTRIES);
|
||||
let curveType = this.curves[i / CurveTimeline2.ENTRIES];
|
||||
switch (curveType) {
|
||||
case CurveTimeline.LINEAR:
|
||||
case LINEAR:
|
||||
let before = frames[i];
|
||||
x = frames[i + CurveTimeline2.VALUE1];
|
||||
y = frames[i + CurveTimeline2.VALUE2];
|
||||
@ -420,13 +437,13 @@ module spine {
|
||||
x += (frames[i + CurveTimeline2.ENTRIES + CurveTimeline2.VALUE1] - x) * t;
|
||||
y += (frames[i + CurveTimeline2.ENTRIES + CurveTimeline2.VALUE2] - y) * t;
|
||||
break;
|
||||
case CurveTimeline.STEPPED:
|
||||
case STEPPED:
|
||||
x = frames[i + CurveTimeline2.VALUE1];
|
||||
y = frames[i + CurveTimeline2.VALUE2];
|
||||
break;
|
||||
default:
|
||||
x = this.getBezierValue(time, i, CurveTimeline2.VALUE1, curveType - CurveTimeline.BEZIER);
|
||||
y = this.getBezierValue(time, i, CurveTimeline2.VALUE2, curveType + CurveTimeline.BEZIER_SIZE - CurveTimeline.BEZIER);
|
||||
x = this.getBezierValue(time, i, CurveTimeline2.VALUE1, curveType - BEZIER);
|
||||
y = this.getBezierValue(time, i, CurveTimeline2.VALUE2, curveType + BEZIER_SIZE - BEZIER);
|
||||
}
|
||||
|
||||
switch (blend) {
|
||||
@ -564,7 +581,7 @@ module spine {
|
||||
let i = Timeline.search2(frames, time, CurveTimeline2.ENTRIES);
|
||||
let curveType = this.curves[i / CurveTimeline2.ENTRIES];
|
||||
switch (curveType) {
|
||||
case CurveTimeline.LINEAR:
|
||||
case LINEAR:
|
||||
let before = frames[i];
|
||||
x = frames[i + CurveTimeline2.VALUE1];
|
||||
y = frames[i + CurveTimeline2.VALUE2];
|
||||
@ -572,13 +589,13 @@ module spine {
|
||||
x += (frames[i + CurveTimeline2.ENTRIES + CurveTimeline2.VALUE1] - x) * t;
|
||||
y += (frames[i + CurveTimeline2.ENTRIES + CurveTimeline2.VALUE2] - y) * t;
|
||||
break;
|
||||
case CurveTimeline.STEPPED:
|
||||
case STEPPED:
|
||||
x = frames[i + CurveTimeline2.VALUE1];
|
||||
y = frames[i + CurveTimeline2.VALUE2];
|
||||
break;
|
||||
default:
|
||||
x = this.getBezierValue(time, i, CurveTimeline2.VALUE1, curveType - CurveTimeline.BEZIER);
|
||||
y = this.getBezierValue(time, i, CurveTimeline2.VALUE2, curveType + CurveTimeline.BEZIER_SIZE - CurveTimeline.BEZIER);
|
||||
x = this.getBezierValue(time, i, CurveTimeline2.VALUE1, curveType - BEZIER);
|
||||
y = this.getBezierValue(time, i, CurveTimeline2.VALUE2, curveType + BEZIER_SIZE - BEZIER);
|
||||
}
|
||||
x *= bone.data.scaleX;
|
||||
y *= bone.data.scaleY;
|
||||
@ -816,7 +833,7 @@ module spine {
|
||||
let i = Timeline.search2(frames, time, CurveTimeline2.ENTRIES);
|
||||
let curveType = this.curves[i / CurveTimeline2.ENTRIES];
|
||||
switch (curveType) {
|
||||
case CurveTimeline.LINEAR:
|
||||
case LINEAR:
|
||||
let before = frames[i];
|
||||
x = frames[i + CurveTimeline2.VALUE1];
|
||||
y = frames[i + CurveTimeline2.VALUE2];
|
||||
@ -824,13 +841,13 @@ module spine {
|
||||
x += (frames[i + CurveTimeline2.ENTRIES + CurveTimeline2.VALUE1] - x) * t;
|
||||
y += (frames[i + CurveTimeline2.ENTRIES + CurveTimeline2.VALUE2] - y) * t;
|
||||
break;
|
||||
case CurveTimeline.STEPPED:
|
||||
case STEPPED:
|
||||
x = frames[i + CurveTimeline2.VALUE1];
|
||||
y = frames[i + CurveTimeline2.VALUE2];
|
||||
break;
|
||||
default:
|
||||
x = this.getBezierValue(time, i, CurveTimeline2.VALUE1, curveType - CurveTimeline.BEZIER);
|
||||
y = this.getBezierValue(time, i, CurveTimeline2.VALUE2, curveType + CurveTimeline.BEZIER_SIZE - CurveTimeline.BEZIER);
|
||||
x = this.getBezierValue(time, i, CurveTimeline2.VALUE1, curveType - BEZIER);
|
||||
y = this.getBezierValue(time, i, CurveTimeline2.VALUE2, curveType + BEZIER_SIZE - BEZIER);
|
||||
}
|
||||
|
||||
switch (blend) {
|
||||
@ -937,7 +954,6 @@ module spine {
|
||||
/** Changes a slot's {@link Slot#color}. */
|
||||
export class RGBATimeline extends CurveTimeline implements SlotTimeline {
|
||||
static ENTRIES = 5;
|
||||
|
||||
static R = 1; static G = 2; static B = 3; static A = 4;
|
||||
|
||||
slotIndex = 0;
|
||||
@ -987,7 +1003,7 @@ module spine {
|
||||
let i = Timeline.search2(frames, time, RGBATimeline.ENTRIES);
|
||||
let curveType = this.curves[i / RGBATimeline.ENTRIES];
|
||||
switch (curveType) {
|
||||
case CurveTimeline.LINEAR:
|
||||
case LINEAR:
|
||||
let before = frames[i];
|
||||
r = frames[i + RGBATimeline.R];
|
||||
g = frames[i + RGBATimeline.G];
|
||||
@ -999,17 +1015,17 @@ module spine {
|
||||
b += (frames[i + RGBATimeline.ENTRIES + RGBATimeline.B] - b) * t;
|
||||
a += (frames[i + RGBATimeline.ENTRIES + RGBATimeline.A] - a) * t;
|
||||
break;
|
||||
case CurveTimeline.STEPPED:
|
||||
case STEPPED:
|
||||
r = frames[i + RGBATimeline.R];
|
||||
g = frames[i + RGBATimeline.G];
|
||||
b = frames[i + RGBATimeline.B];
|
||||
a = frames[i + RGBATimeline.A];
|
||||
break;
|
||||
default:
|
||||
r = this.getBezierValue(time, i, RGBATimeline.R, curveType - CurveTimeline.BEZIER);
|
||||
g = this.getBezierValue(time, i, RGBATimeline.G, curveType + CurveTimeline.BEZIER_SIZE - CurveTimeline.BEZIER);
|
||||
b = this.getBezierValue(time, i, RGBATimeline.B, curveType + CurveTimeline.BEZIER_SIZE * 2 - CurveTimeline.BEZIER);
|
||||
a = this.getBezierValue(time, i, RGBATimeline.A, curveType + CurveTimeline.BEZIER_SIZE * 3 - CurveTimeline.BEZIER);
|
||||
r = this.getBezierValue(time, i, RGBATimeline.R, curveType - BEZIER);
|
||||
g = this.getBezierValue(time, i, RGBATimeline.G, curveType + BEZIER_SIZE - BEZIER);
|
||||
b = this.getBezierValue(time, i, RGBATimeline.B, curveType + BEZIER_SIZE * 2 - BEZIER);
|
||||
a = this.getBezierValue(time, i, RGBATimeline.A, curveType + BEZIER_SIZE * 3 - BEZIER);
|
||||
}
|
||||
if (alpha == 1)
|
||||
color.set(r, g, b, a);
|
||||
@ -1023,7 +1039,6 @@ module spine {
|
||||
/** Changes a slot's {@link Slot#color}. */
|
||||
export class RGBTimeline extends CurveTimeline implements SlotTimeline {
|
||||
static ENTRIES = 4;
|
||||
|
||||
static R = 1; static G = 2; static B = 3;
|
||||
|
||||
slotIndex = 0;
|
||||
@ -1074,7 +1089,7 @@ module spine {
|
||||
let i = Timeline.search2(frames, time, RGBTimeline.ENTRIES);
|
||||
let curveType = this.curves[i >> 2];
|
||||
switch (curveType) {
|
||||
case CurveTimeline.LINEAR:
|
||||
case LINEAR:
|
||||
let before = frames[i];
|
||||
r = frames[i + RGBTimeline.R];
|
||||
g = frames[i + RGBTimeline.G];
|
||||
@ -1084,15 +1099,15 @@ module spine {
|
||||
g += (frames[i + RGBTimeline.ENTRIES + RGBTimeline.G] - g) * t;
|
||||
b += (frames[i + RGBTimeline.ENTRIES + RGBTimeline.B] - b) * t;
|
||||
break;
|
||||
case CurveTimeline.STEPPED:
|
||||
case STEPPED:
|
||||
r = frames[i + RGBTimeline.R];
|
||||
g = frames[i + RGBTimeline.G];
|
||||
b = frames[i + RGBTimeline.B];
|
||||
break;
|
||||
default:
|
||||
r = this.getBezierValue(time, i, RGBTimeline.R, curveType - CurveTimeline.BEZIER);
|
||||
g = this.getBezierValue(time, i, RGBTimeline.G, curveType + CurveTimeline.BEZIER_SIZE - CurveTimeline.BEZIER);
|
||||
b = this.getBezierValue(time, i, RGBTimeline.B, curveType + CurveTimeline.BEZIER_SIZE * 2 - CurveTimeline.BEZIER);
|
||||
r = this.getBezierValue(time, i, RGBTimeline.R, curveType - BEZIER);
|
||||
g = this.getBezierValue(time, i, RGBTimeline.G, curveType + BEZIER_SIZE - BEZIER);
|
||||
b = this.getBezierValue(time, i, RGBTimeline.B, curveType + BEZIER_SIZE * 2 - BEZIER);
|
||||
}
|
||||
if (alpha == 1) {
|
||||
color.r = r;
|
||||
@ -1153,7 +1168,6 @@ module spine {
|
||||
/** Changes a slot's {@link Slot#color} and {@link Slot#darkColor} for two color tinting. */
|
||||
export class RGBA2Timeline extends CurveTimeline implements SlotTimeline{
|
||||
static ENTRIES = 8;
|
||||
|
||||
static R = 1; static G = 2; static B = 3; static A = 4; static R2 = 5; static G2 = 6; static B2 = 7;
|
||||
|
||||
slotIndex = 0;
|
||||
@ -1213,7 +1227,7 @@ module spine {
|
||||
let i = Timeline.search2(frames, time, RGBA2Timeline.ENTRIES);
|
||||
let curveType = this.curves[i >> 3];
|
||||
switch (curveType) {
|
||||
case CurveTimeline.LINEAR:
|
||||
case LINEAR:
|
||||
let before = frames[i];
|
||||
r = frames[i + RGBA2Timeline.R];
|
||||
g = frames[i + RGBA2Timeline.G];
|
||||
@ -1231,7 +1245,7 @@ module spine {
|
||||
g2 += (frames[i + RGBA2Timeline.ENTRIES + RGBA2Timeline.G2] - g2) * t;
|
||||
b2 += (frames[i + RGBA2Timeline.ENTRIES + RGBA2Timeline.B2] - b2) * t;
|
||||
break;
|
||||
case CurveTimeline.STEPPED:
|
||||
case STEPPED:
|
||||
r = frames[i + RGBA2Timeline.R];
|
||||
g = frames[i + RGBA2Timeline.G];
|
||||
b = frames[i + RGBA2Timeline.B];
|
||||
@ -1241,13 +1255,13 @@ module spine {
|
||||
b2 = frames[i + RGBA2Timeline.B2];
|
||||
break;
|
||||
default:
|
||||
r = this.getBezierValue(time, i, RGBA2Timeline.R, curveType - CurveTimeline.BEZIER);
|
||||
g = this.getBezierValue(time, i, RGBA2Timeline.G, curveType + CurveTimeline.BEZIER_SIZE - CurveTimeline.BEZIER);
|
||||
b = this.getBezierValue(time, i, RGBA2Timeline.B, curveType + CurveTimeline.BEZIER_SIZE * 2 - CurveTimeline.BEZIER);
|
||||
a = this.getBezierValue(time, i, RGBA2Timeline.A, curveType + CurveTimeline.BEZIER_SIZE * 3 - CurveTimeline.BEZIER);
|
||||
r2 = this.getBezierValue(time, i, RGBA2Timeline.R2, curveType + CurveTimeline.BEZIER_SIZE * 4 - CurveTimeline.BEZIER);
|
||||
g2 = this.getBezierValue(time, i, RGBA2Timeline.G2, curveType + CurveTimeline.BEZIER_SIZE * 5 - CurveTimeline.BEZIER);
|
||||
b2 = this.getBezierValue(time, i, RGBA2Timeline.B2, curveType + CurveTimeline.BEZIER_SIZE * 6 - CurveTimeline.BEZIER);
|
||||
r = this.getBezierValue(time, i, RGBA2Timeline.R, curveType - BEZIER);
|
||||
g = this.getBezierValue(time, i, RGBA2Timeline.G, curveType + BEZIER_SIZE - BEZIER);
|
||||
b = this.getBezierValue(time, i, RGBA2Timeline.B, curveType + BEZIER_SIZE * 2 - BEZIER);
|
||||
a = this.getBezierValue(time, i, RGBA2Timeline.A, curveType + BEZIER_SIZE * 3 - BEZIER);
|
||||
r2 = this.getBezierValue(time, i, RGBA2Timeline.R2, curveType + BEZIER_SIZE * 4 - BEZIER);
|
||||
g2 = this.getBezierValue(time, i, RGBA2Timeline.G2, curveType + BEZIER_SIZE * 5 - BEZIER);
|
||||
b2 = this.getBezierValue(time, i, RGBA2Timeline.B2, curveType + BEZIER_SIZE * 6 - BEZIER);
|
||||
}
|
||||
|
||||
if (alpha == 1) {
|
||||
@ -1271,7 +1285,6 @@ module spine {
|
||||
/** Changes a slot's {@link Slot#color} and {@link Slot#darkColor} for two color tinting. */
|
||||
export class RGB2Timeline extends CurveTimeline implements SlotTimeline{
|
||||
static ENTRIES = 7;
|
||||
|
||||
static R = 1; static G = 2; static B = 3; static R2 = 4; static G2 = 5; static B2 = 6;
|
||||
|
||||
slotIndex = 0;
|
||||
@ -1332,7 +1345,7 @@ module spine {
|
||||
let i = Timeline.search2(frames, time, RGB2Timeline.ENTRIES);
|
||||
let curveType = this.curves[i / RGB2Timeline.ENTRIES];
|
||||
switch (curveType) {
|
||||
case CurveTimeline.LINEAR:
|
||||
case LINEAR:
|
||||
let before = frames[i];
|
||||
r = frames[i + RGB2Timeline.R];
|
||||
g = frames[i + RGB2Timeline.G];
|
||||
@ -1348,7 +1361,7 @@ module spine {
|
||||
g2 += (frames[i + RGB2Timeline.ENTRIES + RGB2Timeline.G2] - g2) * t;
|
||||
b2 += (frames[i + RGB2Timeline.ENTRIES + RGB2Timeline.B2] - b2) * t;
|
||||
break;
|
||||
case CurveTimeline.STEPPED:
|
||||
case STEPPED:
|
||||
r = frames[i + RGB2Timeline.R];
|
||||
g = frames[i + RGB2Timeline.G];
|
||||
b = frames[i + RGB2Timeline.B];
|
||||
@ -1357,12 +1370,12 @@ module spine {
|
||||
b2 = frames[i + RGB2Timeline.B2];
|
||||
break;
|
||||
default:
|
||||
r = this.getBezierValue(time, i, RGB2Timeline.R, curveType - CurveTimeline.BEZIER);
|
||||
g = this.getBezierValue(time, i, RGB2Timeline.G, curveType + CurveTimeline.BEZIER_SIZE - CurveTimeline.BEZIER);
|
||||
b = this.getBezierValue(time, i, RGB2Timeline.B, curveType + CurveTimeline.BEZIER_SIZE * 2 - CurveTimeline.BEZIER);
|
||||
r2 = this.getBezierValue(time, i, RGB2Timeline.R2, curveType + CurveTimeline.BEZIER_SIZE * 3 - CurveTimeline.BEZIER);
|
||||
g2 = this.getBezierValue(time, i, RGB2Timeline.G2, curveType + CurveTimeline.BEZIER_SIZE * 4 - CurveTimeline.BEZIER);
|
||||
b2 = this.getBezierValue(time, i, RGB2Timeline.B2, curveType + CurveTimeline.BEZIER_SIZE * 5 - CurveTimeline.BEZIER);
|
||||
r = this.getBezierValue(time, i, RGB2Timeline.R, curveType - BEZIER);
|
||||
g = this.getBezierValue(time, i, RGB2Timeline.G, curveType + BEZIER_SIZE - BEZIER);
|
||||
b = this.getBezierValue(time, i, RGB2Timeline.B, curveType + BEZIER_SIZE * 2 - BEZIER);
|
||||
r2 = this.getBezierValue(time, i, RGB2Timeline.R2, curveType + BEZIER_SIZE * 3 - BEZIER);
|
||||
g2 = this.getBezierValue(time, i, RGB2Timeline.G2, curveType + BEZIER_SIZE * 4 - BEZIER);
|
||||
b2 = this.getBezierValue(time, i, RGB2Timeline.B2, curveType + BEZIER_SIZE * 5 - BEZIER);
|
||||
}
|
||||
|
||||
if (alpha == 1) {
|
||||
@ -1474,14 +1487,14 @@ module spine {
|
||||
setBezier (bezier: number, frame: number, value: number, time1: number, value1: number, cx1: number, cy1: number, cx2: number,
|
||||
cy2: number, time2: number, value2: number) {
|
||||
let curves = this.curves;
|
||||
let i = this.getFrameCount() + bezier * CurveTimeline.BEZIER_SIZE;
|
||||
if (value == 0) curves[frame] = CurveTimeline.BEZIER + i;
|
||||
let i = this.getFrameCount() + bezier * BEZIER_SIZE;
|
||||
if (value == 0) curves[frame] = BEZIER + i;
|
||||
let tmpx = (time1 - cx1 * 2 + cx2) * 0.03, tmpy = cy2 * 0.03 - cy1 * 0.06;
|
||||
let dddx = ((cx1 - cx2) * 3 - time1 + time2) * 0.006, dddy = (cy1 - cy2 + 0.33333333) * 0.018;
|
||||
let ddx = tmpx * 2 + dddx, ddy = tmpy * 2 + dddy;
|
||||
let dx = (cx1 - time1) * 0.3 + tmpx + dddx * 0.16666667, dy = cy1 * 0.3 + tmpy + dddy * 0.16666667;
|
||||
let x = time1 + dx, y = dy;
|
||||
for (let n = i + CurveTimeline.BEZIER_SIZE; i < n; i += 2) {
|
||||
for (let n = i + BEZIER_SIZE; i < n; i += 2) {
|
||||
curves[i] = x;
|
||||
curves[i + 1] = y;
|
||||
dx += ddx;
|
||||
@ -1497,18 +1510,18 @@ module spine {
|
||||
let curves = this.curves;
|
||||
let i = curves[frame];
|
||||
switch (i) {
|
||||
case CurveTimeline.LINEAR:
|
||||
let x = frames[frame];
|
||||
return (time - x) / (frames[frame + this.getFrameEntries()] - x);
|
||||
case CurveTimeline.STEPPED:
|
||||
case LINEAR:
|
||||
let x = this.frames[frame];
|
||||
return (time - x) / (this.frames[frame + this.getFrameEntries()] - x);
|
||||
case STEPPED:
|
||||
return 0;
|
||||
}
|
||||
i -= CurveTimeline.BEZIER;
|
||||
i -= BEZIER;
|
||||
if (curves[i] > time) {
|
||||
let x = frames[frame];
|
||||
let x = this.frames[frame];
|
||||
return curves[i + 1] * (time - x) / (curves[i] - x);
|
||||
}
|
||||
let n = i + CurveTimeline.BEZIER_SIZE;
|
||||
let n = i + BEZIER_SIZE;
|
||||
for (i += 2; i < n; i += 2) {
|
||||
if (curves[i] >= time) {
|
||||
let x = curves[i - 2], y = curves[i - 1];
|
||||
@ -1516,7 +1529,7 @@ module spine {
|
||||
}
|
||||
}
|
||||
let x = curves[n - 2], y = curves[n - 1];
|
||||
return y + (1 - y) * (time - x) / (frames[frame + this.getFrameEntries()] - x);
|
||||
return y + (1 - y) * (time - x) / (this.frames[frame + this.getFrameEntries()] - x);
|
||||
}
|
||||
|
||||
apply (skeleton: Skeleton, lastTime: number, time: number, firedEvents: Array<Event>, alpha: number, blend: MixBlend, direction: MixDirection) {
|
||||
@ -1777,12 +1790,12 @@ module spine {
|
||||
return;
|
||||
}
|
||||
|
||||
if (time < frames[0]) {
|
||||
if (time < this.frames[0]) {
|
||||
if (blend == MixBlend.setup || blend == MixBlend.first) Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||
return;
|
||||
}
|
||||
|
||||
let drawOrderToSetupIndex = this.drawOrders[Timeline.search(frames, time)];
|
||||
let drawOrderToSetupIndex = this.drawOrders[Timeline.search(this.frames, time)];
|
||||
if (drawOrderToSetupIndex == null)
|
||||
Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);
|
||||
else {
|
||||
@ -1798,7 +1811,6 @@ module spine {
|
||||
* {@link IkConstraint#bendDirection}, {@link IkConstraint#stretch}, and {@link IkConstraint#compress}. */
|
||||
export class IkConstraintTimeline extends CurveTimeline {
|
||||
static ENTRIES = 6;
|
||||
|
||||
static MIX = 1; static SOFTNESS = 2; static BEND_DIRECTION = 3; static COMPRESS = 4; static STRETCH = 5;
|
||||
|
||||
/** The index of the IK constraint slot in {@link Skeleton#ikConstraints} that will be changed. */
|
||||
@ -1854,7 +1866,7 @@ module spine {
|
||||
let i = Timeline.search2(frames, time, IkConstraintTimeline.ENTRIES)
|
||||
let curveType = this.curves[i / IkConstraintTimeline.ENTRIES];
|
||||
switch (curveType) {
|
||||
case CurveTimeline.LINEAR:
|
||||
case LINEAR:
|
||||
let before = frames[i];
|
||||
mix = frames[i + IkConstraintTimeline.MIX];
|
||||
softness = frames[i + IkConstraintTimeline.SOFTNESS];
|
||||
@ -1862,13 +1874,13 @@ module spine {
|
||||
mix += (frames[i + IkConstraintTimeline.ENTRIES + IkConstraintTimeline.MIX] - mix) * t;
|
||||
softness += (frames[i + IkConstraintTimeline.ENTRIES + IkConstraintTimeline.SOFTNESS] - softness) * t;
|
||||
break;
|
||||
case CurveTimeline.STEPPED:
|
||||
case STEPPED:
|
||||
mix = frames[i + IkConstraintTimeline.MIX];
|
||||
softness = frames[i + IkConstraintTimeline.SOFTNESS];
|
||||
break;
|
||||
default:
|
||||
mix = this.getBezierValue(time, i, IkConstraintTimeline.MIX, curveType - CurveTimeline.BEZIER);
|
||||
softness = this.getBezierValue(time, i, IkConstraintTimeline.SOFTNESS, curveType + CurveTimeline.BEZIER_SIZE - CurveTimeline.BEZIER);
|
||||
mix = this.getBezierValue(time, i, IkConstraintTimeline.MIX, curveType - BEZIER);
|
||||
softness = this.getBezierValue(time, i, IkConstraintTimeline.SOFTNESS, curveType + BEZIER_SIZE - BEZIER);
|
||||
}
|
||||
|
||||
if (blend == MixBlend.setup) {
|
||||
@ -1900,7 +1912,6 @@ module spine {
|
||||
* {@link TransformConstraint#scaleMix}, and {@link TransformConstraint#shearMix}. */
|
||||
export class TransformConstraintTimeline extends CurveTimeline {
|
||||
static ENTRIES = 7;
|
||||
|
||||
static ROTATE = 1; static X = 2; static Y = 3; static SCALEX = 4; static SCALEY = 5; static SHEARY = 6;
|
||||
|
||||
/** The index of the transform constraint slot in {@link Skeleton#transformConstraints} that will be changed. */
|
||||
@ -1958,18 +1969,17 @@ module spine {
|
||||
return;
|
||||
}
|
||||
|
||||
let rotate, x, y, scaleX, scaleY, shearY;
|
||||
let i = Timeline.search2(frames, time, TransformConstraintTimeline.ENTRIES);
|
||||
let curveType = this.curves[i / TransformConstraintTimeline.ENTRIES];
|
||||
let ROTATE = TransformConstraintTimeline.ROTATE;
|
||||
let X = TransformConstraintTimeline.X;
|
||||
let Y = TransformConstraintTimeline.Y;
|
||||
let SCALEX = TransformConstraintTimeline.SCALEX;
|
||||
let SCALEY = TransformConstraintTimeline.SCALEY;
|
||||
let X = TransformConstraintTimeline.X, Y = TransformConstraintTimeline.Y;
|
||||
let SCALEX = TransformConstraintTimeline.SCALEX, SCALEY = TransformConstraintTimeline.SCALEY;
|
||||
let SHEARY = TransformConstraintTimeline.SHEARY;
|
||||
let ENTRIES = TransformConstraintTimeline.ENTRIES;
|
||||
|
||||
let rotate, x, y, scaleX, scaleY, shearY;
|
||||
let i = Timeline.search2(frames, time, ENTRIES);
|
||||
let curveType = this.curves[i / ENTRIES];
|
||||
let ROTATE = TransformConstraintTimeline.ROTATE;
|
||||
switch (curveType) {
|
||||
case CurveTimeline.LINEAR:
|
||||
case LINEAR:
|
||||
let before = frames[i];
|
||||
rotate = frames[i + ROTATE];
|
||||
x = frames[i + X];
|
||||
@ -1985,7 +1995,7 @@ module spine {
|
||||
scaleY += (frames[i + ENTRIES + SCALEY] - scaleY) * t;
|
||||
shearY += (frames[i + ENTRIES + SHEARY] - shearY) * t;
|
||||
break;
|
||||
case CurveTimeline.STEPPED:
|
||||
case STEPPED:
|
||||
rotate = frames[i + ROTATE];
|
||||
x = frames[i + X];
|
||||
y = frames[i + Y];
|
||||
@ -1994,12 +2004,12 @@ module spine {
|
||||
shearY = frames[i + SHEARY];
|
||||
break;
|
||||
default:
|
||||
rotate = this.getBezierValue(time, i, ROTATE, curveType - CurveTimeline.BEZIER);
|
||||
x = this.getBezierValue(time, i, X, curveType + CurveTimeline.BEZIER_SIZE - CurveTimeline.BEZIER);
|
||||
y = this.getBezierValue(time, i, Y, curveType + CurveTimeline.BEZIER_SIZE * 2 - CurveTimeline.BEZIER);
|
||||
scaleX = this.getBezierValue(time, i, SCALEX, curveType + CurveTimeline.BEZIER_SIZE * 3 - CurveTimeline.BEZIER);
|
||||
scaleY = this.getBezierValue(time, i, SCALEY, curveType + CurveTimeline.BEZIER_SIZE * 4 - CurveTimeline.BEZIER);
|
||||
shearY = this.getBezierValue(time, i, SHEARY, curveType + CurveTimeline.BEZIER_SIZE * 5 - CurveTimeline.BEZIER);
|
||||
rotate = this.getBezierValue(time, i, ROTATE, curveType - BEZIER);
|
||||
x = this.getBezierValue(time, i, X, curveType + BEZIER_SIZE - BEZIER);
|
||||
y = this.getBezierValue(time, i, Y, curveType + BEZIER_SIZE * 2 - BEZIER);
|
||||
scaleX = this.getBezierValue(time, i, SCALEX, curveType + BEZIER_SIZE * 3 - BEZIER);
|
||||
scaleY = this.getBezierValue(time, i, SCALEY, curveType + BEZIER_SIZE * 4 - BEZIER);
|
||||
shearY = this.getBezierValue(time, i, SHEARY, curveType + BEZIER_SIZE * 5 - BEZIER);
|
||||
}
|
||||
|
||||
if (blend == MixBlend.setup) {
|
||||
@ -2148,7 +2158,7 @@ module spine {
|
||||
let i = Timeline.search2(frames, time, PathConstraintMixTimeline.ENTRIES);
|
||||
let curveType = this.curves[i >> 2];
|
||||
switch (curveType) {
|
||||
case CurveTimeline.LINEAR:
|
||||
case LINEAR:
|
||||
let before = frames[i];
|
||||
rotate = frames[i + PathConstraintMixTimeline.ROTATE];
|
||||
x = frames[i + PathConstraintMixTimeline.X];
|
||||
@ -2158,15 +2168,15 @@ module spine {
|
||||
x += (frames[i + PathConstraintMixTimeline.ENTRIES + PathConstraintMixTimeline.X] - x) * t;
|
||||
y += (frames[i + PathConstraintMixTimeline.ENTRIES + PathConstraintMixTimeline.Y] - y) * t;
|
||||
break;
|
||||
case CurveTimeline.STEPPED:
|
||||
case STEPPED:
|
||||
rotate = frames[i + PathConstraintMixTimeline.ROTATE];
|
||||
x = frames[i + PathConstraintMixTimeline.X];
|
||||
y = frames[i + PathConstraintMixTimeline.Y];
|
||||
break;
|
||||
default:
|
||||
rotate = this.getBezierValue(time, i, PathConstraintMixTimeline.ROTATE, curveType - CurveTimeline.BEZIER);
|
||||
x = this.getBezierValue(time, i, PathConstraintMixTimeline.X, curveType + CurveTimeline.BEZIER_SIZE - CurveTimeline.BEZIER);
|
||||
y = this.getBezierValue(time, i, PathConstraintMixTimeline.Y, curveType + CurveTimeline.BEZIER_SIZE * 2 - CurveTimeline.BEZIER);
|
||||
rotate = this.getBezierValue(time, i, PathConstraintMixTimeline.ROTATE, curveType - BEZIER);
|
||||
x = this.getBezierValue(time, i, PathConstraintMixTimeline.X, curveType + BEZIER_SIZE - BEZIER);
|
||||
y = this.getBezierValue(time, i, PathConstraintMixTimeline.Y, curveType + BEZIER_SIZE * 2 - BEZIER);
|
||||
}
|
||||
|
||||
if (blend == MixBlend.setup) {
|
||||
|
||||
@ -34,51 +34,11 @@ module spine {
|
||||
*
|
||||
* See [Applying Animations](http://esotericsoftware.com/spine-applying-animations/) in the Spine Runtimes Guide. */
|
||||
export class AnimationState {
|
||||
private static _emptyAnimation: Animation = null;
|
||||
|
||||
private static emptyAnimation(): Animation {
|
||||
if (AnimationState._emptyAnimation == null) AnimationState._emptyAnimation = new Animation("<empty>", [], 0);
|
||||
return AnimationState._emptyAnimation;
|
||||
if (_emptyAnimation == null) _emptyAnimation = new Animation("<empty>", [], 0);
|
||||
return _emptyAnimation;
|
||||
}
|
||||
|
||||
/** 1. A previously applied timeline has set this property.
|
||||
*
|
||||
* Result: Mix from the current pose to the timeline pose. */
|
||||
static SUBSEQUENT = 0;
|
||||
/** 1. This is the first timeline to set this property.
|
||||
* 2. The next track entry applied after this one does not have a timeline to set this property.
|
||||
*
|
||||
* Result: Mix from the setup pose to the timeline pose. */
|
||||
static FIRST = 1;
|
||||
/** 1) A previously applied timeline has set this property.<br>
|
||||
* 2) The next track entry to be applied does have a timeline to set this property.<br>
|
||||
* 3) The next track entry after that one does not have a timeline to set this property.<br>
|
||||
* Result: Mix from the current pose to the timeline pose, but do not mix out. This avoids "dipping" when crossfading
|
||||
* animations that key the same property. A subsequent timeline will set this property using a mix. */
|
||||
static HOLD_SUBSEQUENT = 2;
|
||||
/** 1) This is the first timeline to set this property.<br>
|
||||
* 2) The next track entry to be applied does have a timeline to set this property.<br>
|
||||
* 3) The next track entry after that one does not have a timeline to set this property.<br>
|
||||
* Result: Mix from the setup pose to the timeline pose, but do not mix out. This avoids "dipping" when crossfading animations
|
||||
* that key the same property. A subsequent timeline will set this property using a mix. */
|
||||
static HOLD_FIRST = 3;
|
||||
/** 1. This is the first timeline to set this property.
|
||||
* 2. The next track entry to be applied does have a timeline to set this property.
|
||||
* 3. The next track entry after that one does have a timeline to set this property.
|
||||
* 4. timelineHoldMix stores the first subsequent track entry that does not have a timeline to set this property.
|
||||
*
|
||||
* Result: The same as HOLD except the mix percentage from the timelineHoldMix track entry is used. This handles when more than
|
||||
* 2 track entries in a row have a timeline that sets the same property.
|
||||
*
|
||||
* Eg, A -> B -> C -> D where A, B, and C have a timeline setting same property, but D does not. When A is applied, to avoid
|
||||
* "dipping" A is not mixed out, however D (the first entry that doesn't set the property) mixing in is used to mix out A
|
||||
* (which affects B and C). Without using D to mix out, A would be applied fully until mixing completes, then snap into
|
||||
* place. */
|
||||
static HOLD_MIX = 4;
|
||||
|
||||
static SETUP = 1;
|
||||
static CURRENT = 2;
|
||||
|
||||
/** The AnimationStateData to look up mix durations. */
|
||||
data: AnimationStateData;
|
||||
|
||||
@ -243,7 +203,7 @@ module spine {
|
||||
|
||||
for (let ii = 0; ii < timelineCount; ii++) {
|
||||
let timeline = timelines[ii];
|
||||
let timelineBlend = timelineMode[ii] == AnimationState.SUBSEQUENT ? blend : MixBlend.setup;
|
||||
let timelineBlend = timelineMode[ii] == SUBSEQUENT ? blend : MixBlend.setup;
|
||||
if (timeline instanceof RotateTimeline) {
|
||||
this.applyRotateTimeline(timeline, skeleton, applyTime, mix, timelineBlend, timelinesRotation, ii << 1, firstFrame);
|
||||
} else if (timeline instanceof AttachmentTimeline) {
|
||||
@ -264,7 +224,7 @@ module spine {
|
||||
// Set slots attachments to the setup pose, if needed. This occurs if an animation that is mixing out sets attachments so
|
||||
// subsequent timelines see any deform, but the subsequent timelines don't set an attachment (eg they are also mixing out or
|
||||
// the time is before the first key).
|
||||
var setupState = this.unkeyedState + AnimationState.SETUP;
|
||||
var setupState = this.unkeyedState + SETUP;
|
||||
var slots = skeleton.slots;
|
||||
for (var i = 0, n = skeleton.slots.length; i < n; i++) {
|
||||
var slot = slots[i];
|
||||
@ -322,20 +282,20 @@ module spine {
|
||||
let timelineBlend: MixBlend;
|
||||
let alpha = 0;
|
||||
switch (timelineMode[i]) {
|
||||
case AnimationState.SUBSEQUENT:
|
||||
case SUBSEQUENT:
|
||||
if (!drawOrder && timeline instanceof DrawOrderTimeline) continue;
|
||||
timelineBlend = blend;
|
||||
alpha = alphaMix;
|
||||
break;
|
||||
case AnimationState.FIRST:
|
||||
case FIRST:
|
||||
timelineBlend = MixBlend.setup;
|
||||
alpha = alphaMix;
|
||||
break;
|
||||
case AnimationState.HOLD_SUBSEQUENT:
|
||||
case HOLD_SUBSEQUENT:
|
||||
timelineBlend = blend;
|
||||
alpha = alphaHold;
|
||||
break;
|
||||
case AnimationState.HOLD_FIRST:
|
||||
case HOLD_FIRST:
|
||||
timelineBlend = MixBlend.setup;
|
||||
alpha = alphaHold;
|
||||
break;
|
||||
@ -381,12 +341,12 @@ module spine {
|
||||
this.setAttachment(skeleton, slot, timeline.attachmentNames[Timeline.search(frames, time)], attachments);
|
||||
|
||||
// If an attachment wasn't set (ie before the first frame or attachments is false), set the setup attachment later.
|
||||
if (slot.attachmentState <= this.unkeyedState) slot.attachmentState = this.unkeyedState + AnimationState.SETUP;
|
||||
if (slot.attachmentState <= this.unkeyedState) slot.attachmentState = this.unkeyedState + SETUP;
|
||||
}
|
||||
|
||||
setAttachment (skeleton: Skeleton, slot: Slot, attachmentName: string, attachments: boolean) {
|
||||
slot.setAttachment(attachmentName == null ? null : skeleton.getAttachment(slot.data.index, attachmentName));
|
||||
if (attachments) slot.attachmentState = this.unkeyedState + AnimationState.CURRENT;
|
||||
if (attachments) slot.attachmentState = this.unkeyedState + CURRENT;
|
||||
}
|
||||
|
||||
applyRotateTimeline (timeline: Timeline, skeleton: Skeleton, time: number, alpha: number, blend: MixBlend,
|
||||
@ -755,7 +715,7 @@ module spine {
|
||||
|
||||
if (to != null && to.holdPrevious) {
|
||||
for (let i = 0; i < timelinesCount; i++)
|
||||
timelineMode[i] = propertyIDs.addAll(timelines[i].getPropertyIds()) ? AnimationState.HOLD_FIRST : AnimationState.HOLD_SUBSEQUENT;
|
||||
timelineMode[i] = propertyIDs.addAll(timelines[i].getPropertyIds()) ? HOLD_FIRST : HOLD_SUBSEQUENT;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -764,21 +724,21 @@ module spine {
|
||||
let timeline = timelines[i];
|
||||
let ids = timeline.getPropertyIds();
|
||||
if (!propertyIDs.addAll(ids))
|
||||
timelineMode[i] = AnimationState.SUBSEQUENT;
|
||||
timelineMode[i] = SUBSEQUENT;
|
||||
else if (to == null || timeline instanceof AttachmentTimeline || timeline instanceof DrawOrderTimeline
|
||||
|| timeline instanceof EventTimeline || !to.animation.hasTimeline(ids)) {
|
||||
timelineMode[i] = AnimationState.FIRST;
|
||||
timelineMode[i] = FIRST;
|
||||
} else {
|
||||
for (let next = to.mixingTo; next != null; next = next.mixingTo) {
|
||||
if (next.animation.hasTimeline(ids)) continue;
|
||||
if (entry.mixDuration > 0) {
|
||||
timelineMode[i] = AnimationState.HOLD_MIX;
|
||||
timelineMode[i] = HOLD_MIX;
|
||||
timelineHoldMix[i] = next;
|
||||
continue outer;
|
||||
}
|
||||
break;
|
||||
}
|
||||
timelineMode[i] = AnimationState.HOLD_FIRST;
|
||||
timelineMode[i] = HOLD_FIRST;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1176,4 +1136,44 @@ module spine {
|
||||
event (entry: TrackEntry, event: Event) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 1. A previously applied timeline has set this property.
|
||||
*
|
||||
* Result: Mix from the current pose to the timeline pose. */
|
||||
const SUBSEQUENT = 0;
|
||||
/** 1. This is the first timeline to set this property.
|
||||
* 2. The next track entry applied after this one does not have a timeline to set this property.
|
||||
*
|
||||
* Result: Mix from the setup pose to the timeline pose. */
|
||||
const FIRST = 1;
|
||||
/** 1) A previously applied timeline has set this property.<br>
|
||||
* 2) The next track entry to be applied does have a timeline to set this property.<br>
|
||||
* 3) The next track entry after that one does not have a timeline to set this property.<br>
|
||||
* Result: Mix from the current pose to the timeline pose, but do not mix out. This avoids "dipping" when crossfading
|
||||
* animations that key the same property. A subsequent timeline will set this property using a mix. */
|
||||
const HOLD_SUBSEQUENT = 2;
|
||||
/** 1) This is the first timeline to set this property.<br>
|
||||
* 2) The next track entry to be applied does have a timeline to set this property.<br>
|
||||
* 3) The next track entry after that one does not have a timeline to set this property.<br>
|
||||
* Result: Mix from the setup pose to the timeline pose, but do not mix out. This avoids "dipping" when crossfading animations
|
||||
* that key the same property. A subsequent timeline will set this property using a mix. */
|
||||
const HOLD_FIRST = 3;
|
||||
/** 1. This is the first timeline to set this property.
|
||||
* 2. The next track entry to be applied does have a timeline to set this property.
|
||||
* 3. The next track entry after that one does have a timeline to set this property.
|
||||
* 4. timelineHoldMix stores the first subsequent track entry that does not have a timeline to set this property.
|
||||
*
|
||||
* Result: The same as HOLD except the mix percentage from the timelineHoldMix track entry is used. This handles when more than
|
||||
* 2 track entries in a row have a timeline that sets the same property.
|
||||
*
|
||||
* Eg, A -> B -> C -> D where A, B, and C have a timeline setting same property, but D does not. When A is applied, to avoid
|
||||
* "dipping" A is not mixed out, however D (the first entry that doesn't set the property) mixing in is used to mix out A
|
||||
* (which affects B and C). Without using D to mix out, A would be applied fully until mixing completes, then snap into
|
||||
* place. */
|
||||
const HOLD_MIX = 4;
|
||||
|
||||
const SETUP = 1;
|
||||
const CURRENT = 2;
|
||||
|
||||
let _emptyAnimation: Animation = null;
|
||||
}
|
||||
|
||||
@ -1,39 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
module spine {
|
||||
|
||||
/** Determines how images are blended with existing pixels when drawn. */
|
||||
export enum BlendMode {
|
||||
Normal,
|
||||
Additive,
|
||||
Multiply,
|
||||
Screen
|
||||
}
|
||||
}
|
||||
@ -86,7 +86,5 @@ module spine {
|
||||
}
|
||||
|
||||
/** Determines how a bone inherits world transforms from parent bones. */
|
||||
export enum TransformMode {
|
||||
Normal, OnlyTranslation, NoRotationOrReflection, NoScale, NoScaleOrReflection
|
||||
}
|
||||
export enum TransformMode { Normal, OnlyTranslation, NoRotationOrReflection, NoScale, NoScaleOrReflection }
|
||||
}
|
||||
|
||||
@ -70,21 +70,15 @@ module spine {
|
||||
/** Controls how the first bone is positioned along the path.
|
||||
*
|
||||
* See [position](http://esotericsoftware.com/spine-path-constraints#Position) in the Spine User Guide. */
|
||||
export enum PositionMode {
|
||||
Fixed, Percent
|
||||
}
|
||||
export enum PositionMode { Fixed, Percent }
|
||||
|
||||
/** Controls how bones after the first bone are positioned along the path.
|
||||
*
|
||||
* See [spacing](http://esotericsoftware.com/spine-path-constraints#Spacing) in the Spine User Guide. */
|
||||
export enum SpacingMode {
|
||||
Length, Fixed, Percent, Proportional
|
||||
}
|
||||
export enum SpacingMode { Length, Fixed, Percent, Proportional }
|
||||
|
||||
/** Controls how bones are rotated, translated, and scaled to match the path.
|
||||
*
|
||||
* See [rotate mix](http://esotericsoftware.com/spine-path-constraints#Rotate-mix) in the Spine User Guide. */
|
||||
export enum RotateMode {
|
||||
Tangent, Chain, ChainScale
|
||||
}
|
||||
export enum RotateMode { Tangent, Chain, ChainScale }
|
||||
}
|
||||
|
||||
@ -34,39 +34,6 @@ module spine {
|
||||
* [JSON and binary data](http://esotericsoftware.com/spine-loading-skeleton-data#JSON-and-binary-data) in the Spine
|
||||
* Runtimes Guide. */
|
||||
export class SkeletonBinary {
|
||||
static AttachmentTypeValues = [ 0 /*AttachmentType.Region*/, 1/*AttachmentType.BoundingBox*/, 2/*AttachmentType.Mesh*/, 3/*AttachmentType.LinkedMesh*/, 4/*AttachmentType.Path*/, 5/*AttachmentType.Point*/, 6/*AttachmentType.Clipping*/ ];
|
||||
static TransformModeValues = [TransformMode.Normal, TransformMode.OnlyTranslation, TransformMode.NoRotationOrReflection, TransformMode.NoScale, TransformMode.NoScaleOrReflection];
|
||||
static PositionModeValues = [ PositionMode.Fixed, PositionMode.Percent ];
|
||||
static SpacingModeValues = [ SpacingMode.Length, SpacingMode.Fixed, SpacingMode.Percent];
|
||||
static RotateModeValues = [ RotateMode.Tangent, RotateMode.Chain, RotateMode.ChainScale ];
|
||||
static BlendModeValues = [ BlendMode.Normal, BlendMode.Additive, BlendMode.Multiply, BlendMode.Screen];
|
||||
|
||||
static BONE_ROTATE = 0;
|
||||
static BONE_TRANSLATE = 1;
|
||||
static BONE_TRANSLATEX = 2;
|
||||
static BONE_TRANSLATEY = 3;
|
||||
static BONE_SCALE = 4;
|
||||
static BONE_SCALEX = 5;
|
||||
static BONE_SCALEY = 6;
|
||||
static BONE_SHEAR = 7;
|
||||
static BONE_SHEARX = 8;
|
||||
static BONE_SHEARY = 9;
|
||||
|
||||
static SLOT_ATTACHMENT = 0;
|
||||
static SLOT_RGBA = 1;
|
||||
static SLOT_RGB = 2;
|
||||
static SLOT_RGBA2 = 3;
|
||||
static SLOT_RGB2 = 4;
|
||||
static SLOT_ALPHA = 5;
|
||||
|
||||
static PATH_POSITION = 0;
|
||||
static PATH_SPACING = 1;
|
||||
static PATH_MIX = 2;
|
||||
|
||||
static CURVE_LINEAR = 0;
|
||||
static CURVE_STEPPED = 1;
|
||||
static CURVE_BEZIER = 2;
|
||||
|
||||
/** Scales bone positions, image sizes, and translations as they are loaded. This allows different size images to be used at
|
||||
* runtime than were used in Spine.
|
||||
*
|
||||
@ -125,7 +92,7 @@ module spine {
|
||||
data.shearX = input.readFloat();
|
||||
data.shearY = input.readFloat();
|
||||
data.length = input.readFloat() * scale;
|
||||
data.transformMode = SkeletonBinary.TransformModeValues[input.readInt(true)];
|
||||
data.transformMode = input.readInt(true);
|
||||
data.skinRequired = input.readBoolean();
|
||||
if (nonessential) Color.rgba8888ToColor(data.color, input.readInt32());
|
||||
skeletonData.bones.push(data);
|
||||
@ -143,7 +110,7 @@ module spine {
|
||||
if (darkColor != -1) Color.rgb888ToColor(data.darkColor = new Color(), darkColor);
|
||||
|
||||
data.attachmentName = input.readStringRef();
|
||||
data.blendMode = SkeletonBinary.BlendModeValues[input.readInt(true)];
|
||||
data.blendMode = input.readInt(true);
|
||||
skeletonData.slots.push(data);
|
||||
}
|
||||
|
||||
@ -203,9 +170,9 @@ module spine {
|
||||
for (let ii = 0; ii < nn; ii++)
|
||||
data.bones.push(skeletonData.bones[input.readInt(true)]);
|
||||
data.target = skeletonData.slots[input.readInt(true)];
|
||||
data.positionMode = SkeletonBinary.PositionModeValues[input.readInt(true)];
|
||||
data.spacingMode = SkeletonBinary.SpacingModeValues[input.readInt(true)];
|
||||
data.rotateMode = SkeletonBinary.RotateModeValues[input.readInt(true)];
|
||||
data.positionMode = input.readInt(true);
|
||||
data.spacingMode = input.readInt(true);
|
||||
data.rotateMode = input.readInt(true);
|
||||
data.offsetRotation = input.readFloat();
|
||||
data.position = input.readFloat();
|
||||
if (data.positionMode == PositionMode.Fixed) data.position *= scale;
|
||||
@ -309,8 +276,7 @@ module spine {
|
||||
let name = input.readStringRef();
|
||||
if (name == null) name = attachmentName;
|
||||
|
||||
let typeIndex = input.readByte();
|
||||
switch (SkeletonBinary.AttachmentTypeValues[typeIndex]) {
|
||||
switch (input.readByte()) {
|
||||
case AttachmentType.Region: {
|
||||
let path = input.readStringRef();
|
||||
let rotation = input.readFloat();
|
||||
@ -523,14 +489,14 @@ module spine {
|
||||
let frameCount = input.readInt(true);
|
||||
let frameLast = frameCount - 1;
|
||||
switch (timelineType) {
|
||||
case SkeletonBinary.SLOT_ATTACHMENT: {
|
||||
case SLOT_ATTACHMENT: {
|
||||
let timeline = new AttachmentTimeline(frameCount, slotIndex);
|
||||
for (let frame = 0; frame < frameCount; frame++)
|
||||
timeline.setFrame(frame, input.readFloat(), input.readStringRef());
|
||||
timelines.push(timeline);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.SLOT_RGBA: {
|
||||
case SLOT_RGBA: {
|
||||
let bezierCount = input.readInt(true);
|
||||
let timeline = new RGBATimeline(frameCount, bezierCount, slotIndex);
|
||||
|
||||
@ -551,14 +517,14 @@ module spine {
|
||||
let a2 = input.readUnsignedByte() / 255.0;
|
||||
|
||||
switch (input.readByte()) {
|
||||
case SkeletonBinary.CURVE_STEPPED:
|
||||
case CURVE_STEPPED:
|
||||
timeline.setStepped(frame);
|
||||
break;
|
||||
case SkeletonBinary.CURVE_BEZIER:
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 0, time, time2, r, r2, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 1, time, time2, g, g2, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 2, time, time2, b, b2, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 3, time, time2, a, a2, 1);
|
||||
case CURVE_BEZIER:
|
||||
setBezier(input, timeline, bezier++, frame, 0, time, time2, r, r2, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 1, time, time2, g, g2, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 2, time, time2, b, b2, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 3, time, time2, a, a2, 1);
|
||||
}
|
||||
time = time2;
|
||||
r = r2;
|
||||
@ -569,7 +535,7 @@ module spine {
|
||||
timelines.push(timeline);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.SLOT_RGB: {
|
||||
case SLOT_RGB: {
|
||||
let bezierCount = input.readInt(true);
|
||||
let timeline = new RGBTimeline(frameCount, bezierCount, slotIndex);
|
||||
|
||||
@ -588,13 +554,13 @@ module spine {
|
||||
let b2 = input.readUnsignedByte() / 255.0;
|
||||
|
||||
switch (input.readByte()) {
|
||||
case SkeletonBinary.CURVE_STEPPED:
|
||||
case CURVE_STEPPED:
|
||||
timeline.setStepped(frame);
|
||||
break;
|
||||
case SkeletonBinary.CURVE_BEZIER:
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 0, time, time2, r, r2, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 1, time, time2, g, g2, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 2, time, time2, b, b2, 1);
|
||||
case CURVE_BEZIER:
|
||||
setBezier(input, timeline, bezier++, frame, 0, time, time2, r, r2, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 1, time, time2, g, g2, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 2, time, time2, b, b2, 1);
|
||||
}
|
||||
time = time2;
|
||||
r = r2;
|
||||
@ -604,7 +570,7 @@ module spine {
|
||||
timelines.push(timeline);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.SLOT_RGBA2: {
|
||||
case SLOT_RGBA2: {
|
||||
let bezierCount = input.readInt(true);
|
||||
let timeline = new RGBA2Timeline(frameCount, bezierCount, slotIndex);
|
||||
|
||||
@ -630,17 +596,17 @@ module spine {
|
||||
let nb2 = input.readUnsignedByte() / 255.0;
|
||||
|
||||
switch (input.readByte()) {
|
||||
case SkeletonBinary.CURVE_STEPPED:
|
||||
case CURVE_STEPPED:
|
||||
timeline.setStepped(frame);
|
||||
break;
|
||||
case SkeletonBinary.CURVE_BEZIER:
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 0, time, time2, r, nr, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 1, time, time2, g, ng, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 2, time, time2, b, nb, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 3, time, time2, a, na, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 4, time, time2, r2, nr2, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 5, time, time2, g2, ng2, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 6, time, time2, b2, nb2, 1);
|
||||
case CURVE_BEZIER:
|
||||
setBezier(input, timeline, bezier++, frame, 0, time, time2, r, nr, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 1, time, time2, g, ng, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 2, time, time2, b, nb, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 3, time, time2, a, na, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 4, time, time2, r2, nr2, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 5, time, time2, g2, ng2, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 6, time, time2, b2, nb2, 1);
|
||||
}
|
||||
time = time2;
|
||||
r = nr;
|
||||
@ -654,7 +620,7 @@ module spine {
|
||||
timelines.push(timeline);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.SLOT_RGB2: {
|
||||
case SLOT_RGB2: {
|
||||
let bezierCount = input.readInt(true);
|
||||
let timeline = new RGB2Timeline(frameCount, bezierCount, slotIndex);
|
||||
|
||||
@ -678,16 +644,16 @@ module spine {
|
||||
let nb2 = input.readUnsignedByte() / 255.0;
|
||||
|
||||
switch (input.readByte()) {
|
||||
case SkeletonBinary.CURVE_STEPPED:
|
||||
case CURVE_STEPPED:
|
||||
timeline.setStepped(frame);
|
||||
break;
|
||||
case SkeletonBinary.CURVE_BEZIER:
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 0, time, time2, r, nr, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 1, time, time2, g, ng, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 2, time, time2, b, nb, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 3, time, time2, r2, nr2, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 4, time, time2, g2, ng2, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 5, time, time2, b2, nb2, 1);
|
||||
case CURVE_BEZIER:
|
||||
setBezier(input, timeline, bezier++, frame, 0, time, time2, r, nr, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 1, time, time2, g, ng, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 2, time, time2, b, nb, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 3, time, time2, r2, nr2, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 4, time, time2, g2, ng2, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 5, time, time2, b2, nb2, 1);
|
||||
}
|
||||
time = time2;
|
||||
r = nr;
|
||||
@ -700,7 +666,7 @@ module spine {
|
||||
timelines.push(timeline);
|
||||
break;
|
||||
}
|
||||
case SkeletonBinary.SLOT_ALPHA: {
|
||||
case SLOT_ALPHA: {
|
||||
let timeline = new AlphaTimeline(frameCount, input.readInt(true), slotIndex);
|
||||
let time = input.readFloat(), a = input.readUnsignedByte() / 255;
|
||||
for (let frame = 0, bezier = 0;; frame++) {
|
||||
@ -709,11 +675,11 @@ module spine {
|
||||
let time2 = input.readFloat();
|
||||
let a2 = input.readUnsignedByte() / 255;
|
||||
switch (input.readByte()) {
|
||||
case SkeletonBinary.CURVE_STEPPED:
|
||||
case CURVE_STEPPED:
|
||||
timeline.setStepped(frame);
|
||||
break;
|
||||
case SkeletonBinary.CURVE_BEZIER:
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 0, time, time2, a, a2, 1);
|
||||
case CURVE_BEZIER:
|
||||
setBezier(input, timeline, bezier++, frame, 0, time, time2, a, a2, 1);
|
||||
}
|
||||
time = time2;
|
||||
a = a2;
|
||||
@ -731,35 +697,35 @@ module spine {
|
||||
for (let ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
let type = input.readByte(), frameCount = input.readInt(true), bezierCount = input.readInt(true);
|
||||
switch (type) {
|
||||
case SkeletonBinary.BONE_ROTATE:
|
||||
timelines.push(SkeletonBinary.readTimeline(input, new RotateTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
case BONE_ROTATE:
|
||||
timelines.push(readTimeline1(input, new RotateTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
break;
|
||||
case SkeletonBinary.BONE_TRANSLATE:
|
||||
timelines.push(SkeletonBinary.readTimeline2(input, new TranslateTimeline(frameCount, bezierCount, boneIndex), scale));
|
||||
case BONE_TRANSLATE:
|
||||
timelines.push(readTimeline2(input, new TranslateTimeline(frameCount, bezierCount, boneIndex), scale));
|
||||
break;
|
||||
case SkeletonBinary.BONE_TRANSLATEX:
|
||||
timelines.push(SkeletonBinary.readTimeline(input, new TranslateXTimeline(frameCount, bezierCount, boneIndex), scale));
|
||||
case BONE_TRANSLATEX:
|
||||
timelines.push(readTimeline1(input, new TranslateXTimeline(frameCount, bezierCount, boneIndex), scale));
|
||||
break;
|
||||
case SkeletonBinary.BONE_TRANSLATEY:
|
||||
timelines.push(SkeletonBinary.readTimeline(input, new TranslateYTimeline(frameCount, bezierCount, boneIndex), scale));
|
||||
case BONE_TRANSLATEY:
|
||||
timelines.push(readTimeline1(input, new TranslateYTimeline(frameCount, bezierCount, boneIndex), scale));
|
||||
break;
|
||||
case SkeletonBinary.BONE_SCALE:
|
||||
timelines.push(SkeletonBinary.readTimeline2(input, new ScaleTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
case BONE_SCALE:
|
||||
timelines.push(readTimeline2(input, new ScaleTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
break;
|
||||
case SkeletonBinary.BONE_SCALEX:
|
||||
timelines.push(SkeletonBinary.readTimeline(input, new ScaleXTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
case BONE_SCALEX:
|
||||
timelines.push(readTimeline1(input, new ScaleXTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
break;
|
||||
case SkeletonBinary.BONE_SCALEY:
|
||||
timelines.push(SkeletonBinary.readTimeline(input, new ScaleYTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
case BONE_SCALEY:
|
||||
timelines.push(readTimeline1(input, new ScaleYTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
break;
|
||||
case SkeletonBinary.BONE_SHEAR:
|
||||
timelines.push(SkeletonBinary.readTimeline2(input, new ShearTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
case BONE_SHEAR:
|
||||
timelines.push(readTimeline2(input, new ShearTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
break;
|
||||
case SkeletonBinary.BONE_SHEARX:
|
||||
timelines.push(SkeletonBinary.readTimeline(input, new ShearXTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
case BONE_SHEARX:
|
||||
timelines.push(readTimeline1(input, new ShearXTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
break;
|
||||
case SkeletonBinary.BONE_SHEARY:
|
||||
timelines.push(SkeletonBinary.readTimeline(input, new ShearYTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
case BONE_SHEARY:
|
||||
timelines.push(readTimeline1(input, new ShearYTimeline(frameCount, bezierCount, boneIndex), 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -774,12 +740,12 @@ module spine {
|
||||
if (frame == frameLast) break;
|
||||
let time2 = input.readFloat(), mix2 = input.readFloat(), softness2 = input.readFloat() * scale;
|
||||
switch (input.readByte()) {
|
||||
case SkeletonBinary.CURVE_STEPPED:
|
||||
case CURVE_STEPPED:
|
||||
timeline.setStepped(frame);
|
||||
break;
|
||||
case SkeletonBinary.CURVE_BEZIER:
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 0, time, time2, mix, mix2, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 1, time, time2, softness, softness2, scale);
|
||||
case CURVE_BEZIER:
|
||||
setBezier(input, timeline, bezier++, frame, 0, time, time2, mix, mix2, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 1, time, time2, softness, softness2, scale);
|
||||
}
|
||||
time = time2;
|
||||
mix = mix2;
|
||||
@ -800,16 +766,16 @@ module spine {
|
||||
let time2 = input.readFloat(), mixRotate2 = input.readFloat(), mixX2 = input.readFloat(), mixY2 = input.readFloat(),
|
||||
mixScaleX2 = input.readFloat(), mixScaleY2 = input.readFloat(), mixShearY2 = input.readFloat();
|
||||
switch (input.readByte()) {
|
||||
case SkeletonBinary.CURVE_STEPPED:
|
||||
case CURVE_STEPPED:
|
||||
timeline.setStepped(frame);
|
||||
break;
|
||||
case SkeletonBinary.CURVE_BEZIER:
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 0, time, time2, mixRotate, mixRotate2, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 1, time, time2, mixX, mixX2, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 2, time, time2, mixY, mixY2, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 3, time, time2, mixScaleX, mixScaleX2, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 4, time, time2, mixScaleY, mixScaleY2, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 5, time, time2, mixShearY, mixShearY2, 1);
|
||||
case CURVE_BEZIER:
|
||||
setBezier(input, timeline, bezier++, frame, 0, time, time2, mixRotate, mixRotate2, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 1, time, time2, mixX, mixX2, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 2, time, time2, mixY, mixY2, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 3, time, time2, mixScaleX, mixScaleX2, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 4, time, time2, mixScaleY, mixScaleY2, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 5, time, time2, mixShearY, mixShearY2, 1);
|
||||
}
|
||||
time = time2;
|
||||
mixRotate = mixRotate2;
|
||||
@ -828,17 +794,17 @@ module spine {
|
||||
let data = skeletonData.pathConstraints[index];
|
||||
for (let ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
switch (input.readByte()) {
|
||||
case SkeletonBinary.PATH_POSITION:
|
||||
case PATH_POSITION:
|
||||
timelines
|
||||
.push(SkeletonBinary.readTimeline(input, new PathConstraintPositionTimeline(input.readInt(true), input.readInt(true), index),
|
||||
.push(readTimeline1(input, new PathConstraintPositionTimeline(input.readInt(true), input.readInt(true), index),
|
||||
data.positionMode == PositionMode.Fixed ? scale : 1));
|
||||
break;
|
||||
case SkeletonBinary.PATH_SPACING:
|
||||
case PATH_SPACING:
|
||||
timelines
|
||||
.push(SkeletonBinary.readTimeline(input, new PathConstraintSpacingTimeline(input.readInt(true), input.readInt(true), index),
|
||||
.push(readTimeline1(input, new PathConstraintSpacingTimeline(input.readInt(true), input.readInt(true), index),
|
||||
data.spacingMode == SpacingMode.Length || data.spacingMode == SpacingMode.Fixed ? scale : 1));
|
||||
break;
|
||||
case SkeletonBinary.PATH_MIX:
|
||||
case PATH_MIX:
|
||||
let timeline = new PathConstraintMixTimeline(input.readInt(true), input.readInt(true), index);
|
||||
let time = input.readFloat(), mixRotate = input.readFloat(), mixX = input.readFloat(), mixY = input.readFloat();
|
||||
for (let frame = 0, bezier = 0, frameLast = timeline.getFrameCount() - 1;; frame++) {
|
||||
@ -847,13 +813,13 @@ module spine {
|
||||
let time2 = input.readFloat(), mixRotate2 = input.readFloat(), mixX2 = input.readFloat(),
|
||||
mixY2 = input.readFloat();
|
||||
switch (input.readByte()) {
|
||||
case SkeletonBinary.CURVE_STEPPED:
|
||||
case CURVE_STEPPED:
|
||||
timeline.setStepped(frame);
|
||||
break;
|
||||
case SkeletonBinary.CURVE_BEZIER:
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 0, time, time2, mixRotate, mixRotate2, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 1, time, time2, mixX, mixX2, 1);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 2, time, time2, mixY, mixY2, 1);
|
||||
case CURVE_BEZIER:
|
||||
setBezier(input, timeline, bezier++, frame, 0, time, time2, mixRotate, mixRotate2, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 1, time, time2, mixX, mixX2, 1);
|
||||
setBezier(input, timeline, bezier++, frame, 2, time, time2, mixY, mixY2, 1);
|
||||
}
|
||||
time = time2;
|
||||
mixRotate = mixRotate2;
|
||||
@ -910,11 +876,11 @@ module spine {
|
||||
if (frame == frameLast) break;
|
||||
let time2 = input.readFloat();
|
||||
switch(input.readByte()) {
|
||||
case SkeletonBinary.CURVE_STEPPED:
|
||||
case CURVE_STEPPED:
|
||||
timeline.setStepped(frame);
|
||||
break;
|
||||
case SkeletonBinary.CURVE_BEZIER:
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 0, time, time2, 0, 1, 1);
|
||||
case CURVE_BEZIER:
|
||||
setBezier(input, timeline, bezier++, frame, 0, time, time2, 0, 1, 1);
|
||||
}
|
||||
time = time2;
|
||||
}
|
||||
@ -980,56 +946,10 @@ module spine {
|
||||
duration = Math.max(duration, timelines[i].getDuration());
|
||||
return new Animation(name, timelines, duration);
|
||||
}
|
||||
|
||||
static readTimeline (input: BinaryInput, timeline: CurveTimeline1, scale: number): CurveTimeline1 {
|
||||
let time = input.readFloat(), value = input.readFloat() * scale;
|
||||
for (let frame = 0, bezier = 0, frameLast = timeline.getFrameCount() - 1;; frame++) {
|
||||
timeline.setFrame(frame, time, value);
|
||||
if (frame == frameLast) break;
|
||||
let time2 = input.readFloat(), value2 = input.readFloat() * scale;
|
||||
switch (input.readByte()) {
|
||||
case SkeletonBinary.CURVE_STEPPED:
|
||||
timeline.setStepped(frame);
|
||||
break;
|
||||
case SkeletonBinary.CURVE_BEZIER:
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 0, time, time2, value, value2, 1);
|
||||
}
|
||||
time = time2;
|
||||
value = value2;
|
||||
}
|
||||
return timeline;
|
||||
}
|
||||
|
||||
static readTimeline2 (input: BinaryInput, timeline: CurveTimeline2, scale: number): CurveTimeline2 {
|
||||
let time = input.readFloat(), value1 = input.readFloat() * scale, value2 = input.readFloat() * scale;
|
||||
for (let frame = 0, bezier = 0, frameLast = timeline.getFrameCount() - 1;; frame++) {
|
||||
timeline.setFrame(frame, time, value1, value2);
|
||||
if (frame == frameLast) break;
|
||||
let time2 = input.readFloat(), nvalue1 = input.readFloat() * scale, nvalue2 = input.readFloat() * scale;
|
||||
switch (input.readByte()) {
|
||||
case SkeletonBinary.CURVE_STEPPED:
|
||||
timeline.setStepped(frame);
|
||||
break;
|
||||
case SkeletonBinary.CURVE_BEZIER:
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 0, time, time2, value1, nvalue1, scale);
|
||||
SkeletonBinary.setBezier(input, timeline, bezier++, frame, 1, time, time2, value2, nvalue2, scale);
|
||||
}
|
||||
time = time2;
|
||||
value1 = nvalue1;
|
||||
value2 = nvalue2;
|
||||
}
|
||||
return timeline;
|
||||
}
|
||||
|
||||
static setBezier (input: BinaryInput, timeline: CurveTimeline, bezier: number, frame: number, value: number,
|
||||
time1: number, time2: number, value1: number, value2: number, scale: number) {
|
||||
timeline.setBezier(bezier, frame, value, time1, value1, input.readFloat(), input.readFloat() * scale, input.readFloat(), input.readFloat() * scale, time2, value2);
|
||||
}
|
||||
}
|
||||
|
||||
class BinaryInput {
|
||||
constructor(data: Uint8Array, public strings = new Array<string>(), private index: number = 0, private buffer = new DataView(data.buffer)) {
|
||||
|
||||
}
|
||||
|
||||
readByte(): number {
|
||||
@ -1139,4 +1059,77 @@ module spine {
|
||||
class Vertices {
|
||||
constructor(public bones: Array<number> = null, public vertices: Array<number> | Float32Array = null) { }
|
||||
}
|
||||
|
||||
enum AttachmentType { Region, BoundingBox, Mesh, LinkedMesh, Path, Point, Clipping }
|
||||
|
||||
function readTimeline1 (input: BinaryInput, timeline: CurveTimeline1, scale: number): CurveTimeline1 {
|
||||
let time = input.readFloat(), value = input.readFloat() * scale;
|
||||
for (let frame = 0, bezier = 0, frameLast = timeline.getFrameCount() - 1;; frame++) {
|
||||
timeline.setFrame(frame, time, value);
|
||||
if (frame == frameLast) break;
|
||||
let time2 = input.readFloat(), value2 = input.readFloat() * scale;
|
||||
switch (input.readByte()) {
|
||||
case CURVE_STEPPED:
|
||||
timeline.setStepped(frame);
|
||||
break;
|
||||
case CURVE_BEZIER:
|
||||
setBezier(input, timeline, bezier++, frame, 0, time, time2, value, value2, 1);
|
||||
}
|
||||
time = time2;
|
||||
value = value2;
|
||||
}
|
||||
return timeline;
|
||||
}
|
||||
|
||||
function readTimeline2 (input: BinaryInput, timeline: CurveTimeline2, scale: number): CurveTimeline2 {
|
||||
let time = input.readFloat(), value1 = input.readFloat() * scale, value2 = input.readFloat() * scale;
|
||||
for (let frame = 0, bezier = 0, frameLast = timeline.getFrameCount() - 1;; frame++) {
|
||||
timeline.setFrame(frame, time, value1, value2);
|
||||
if (frame == frameLast) break;
|
||||
let time2 = input.readFloat(), nvalue1 = input.readFloat() * scale, nvalue2 = input.readFloat() * scale;
|
||||
switch (input.readByte()) {
|
||||
case CURVE_STEPPED:
|
||||
timeline.setStepped(frame);
|
||||
break;
|
||||
case CURVE_BEZIER:
|
||||
setBezier(input, timeline, bezier++, frame, 0, time, time2, value1, nvalue1, scale);
|
||||
setBezier(input, timeline, bezier++, frame, 1, time, time2, value2, nvalue2, scale);
|
||||
}
|
||||
time = time2;
|
||||
value1 = nvalue1;
|
||||
value2 = nvalue2;
|
||||
}
|
||||
return timeline;
|
||||
}
|
||||
|
||||
function setBezier (input: BinaryInput, timeline: CurveTimeline, bezier: number, frame: number, value: number,
|
||||
time1: number, time2: number, value1: number, value2: number, scale: number) {
|
||||
timeline.setBezier(bezier, frame, value, time1, value1, input.readFloat(), input.readFloat() * scale, input.readFloat(), input.readFloat() * scale, time2, value2);
|
||||
}
|
||||
|
||||
const BONE_ROTATE = 0;
|
||||
const BONE_TRANSLATE = 1;
|
||||
const BONE_TRANSLATEX = 2;
|
||||
const BONE_TRANSLATEY = 3;
|
||||
const BONE_SCALE = 4;
|
||||
const BONE_SCALEX = 5;
|
||||
const BONE_SCALEY = 6;
|
||||
const BONE_SHEAR = 7;
|
||||
const BONE_SHEARX = 8;
|
||||
const BONE_SHEARY = 9;
|
||||
|
||||
const SLOT_ATTACHMENT = 0;
|
||||
const SLOT_RGBA = 1;
|
||||
const SLOT_RGB = 2;
|
||||
const SLOT_RGBA2 = 3;
|
||||
const SLOT_RGB2 = 4;
|
||||
const SLOT_ALPHA = 5;
|
||||
|
||||
const PATH_POSITION = 0;
|
||||
const PATH_SPACING = 1;
|
||||
const PATH_MIX = 2;
|
||||
|
||||
const CURVE_LINEAR = 0;
|
||||
const CURVE_STEPPED = 1;
|
||||
const CURVE_BEZIER = 2;
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ module spine {
|
||||
data.scaleY = getValue(boneMap, "scaleY", 1);
|
||||
data.shearX = getValue(boneMap, "shearX", 0);
|
||||
data.shearY = getValue(boneMap, "shearY", 0);
|
||||
data.transformMode = SkeletonJson.transformModeFromString(getValue(boneMap, "transform", "normal"));
|
||||
data.transformMode = Utils.enumValue(TransformMode, getValue(boneMap, "transform", "Normal"));
|
||||
data.skinRequired = getValue(boneMap, "skin", false);
|
||||
|
||||
let color = getValue(boneMap, "color", null);
|
||||
@ -110,13 +110,10 @@ module spine {
|
||||
if (color != null) data.color.setFromString(color);
|
||||
|
||||
let dark: string = getValue(slotMap, "dark", null);
|
||||
if (dark != null) {
|
||||
data.darkColor = new Color(1, 1, 1, 1);
|
||||
data.darkColor.setFromString(dark);
|
||||
}
|
||||
if (dark != null) data.darkColor = Color.fromString(dark);
|
||||
|
||||
data.attachmentName = getValue(slotMap, "attachment", null);
|
||||
data.blendMode = SkeletonJson.blendModeFromString(getValue(slotMap, "blend", "normal"));
|
||||
data.blendMode = Utils.enumValue(BlendMode, getValue(slotMap, "blend", "normal"));
|
||||
skeletonData.slots.push(data);
|
||||
}
|
||||
}
|
||||
@ -209,9 +206,9 @@ module spine {
|
||||
data.target = skeletonData.findSlot(targetName);
|
||||
if (data.target == null) throw new Error("Path target slot not found: " + targetName);
|
||||
|
||||
data.positionMode = SkeletonJson.positionModeFromString(getValue(constraintMap, "positionMode", "percent"));
|
||||
data.spacingMode = SkeletonJson.spacingModeFromString(getValue(constraintMap, "spacingMode", "length"));
|
||||
data.rotateMode = SkeletonJson.rotateModeFromString(getValue(constraintMap, "rotateMode", "tangent"));
|
||||
data.positionMode = Utils.enumValue(PositionMode, getValue(constraintMap, "positionMode", "Percent"));
|
||||
data.spacingMode = Utils.enumValue(SpacingMode, getValue(constraintMap, "spacingMode", "Length"));
|
||||
data.rotateMode = Utils.enumValue(RotateMode, getValue(constraintMap, "rotateMode", "Tangent"));
|
||||
data.offsetRotation = getValue(constraintMap, "rotation", 0);
|
||||
data.position = getValue(constraintMap, "position", 0);
|
||||
if (data.positionMode == PositionMode.Fixed) data.position *= scale;
|
||||
@ -484,14 +481,14 @@ module spine {
|
||||
let timeline = new RGBATimeline(timelineMap.length, timelineMap.length << 2, slotIndex);
|
||||
let keyMap = timelineMap[0];
|
||||
let time = getValue(keyMap, "time", 0);
|
||||
let color = new Color().setFromString(keyMap.color);
|
||||
let color = Color.fromString(keyMap.color);
|
||||
|
||||
for (let frame = 0, bezier = 0;; frame++) {
|
||||
timeline.setFrame(frame, time, color.r, color.g, color.b, color.a);
|
||||
if (timelineMap.length == frame + 1) break;
|
||||
let nextMap = timelineMap[frame + 1];
|
||||
let time2 = getValue(nextMap, "time", 0);
|
||||
let newColor = new Color().setFromString(nextMap.color);
|
||||
let newColor = Color.fromString(nextMap.color);
|
||||
let curve = keyMap.curve;
|
||||
if (curve) {
|
||||
bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, color.r, newColor.r, 1);
|
||||
@ -510,14 +507,14 @@ module spine {
|
||||
let timeline = new RGBTimeline(timelineMap.length, timelineMap.length * 3, slotIndex);
|
||||
let keyMap = timelineMap[0];
|
||||
let time = getValue(keyMap, "time", 0);
|
||||
let color = new Color().setFromString(keyMap.color);
|
||||
let color = Color.fromString(keyMap.color);
|
||||
|
||||
for (let frame = 0, bezier = 0;; frame++) {
|
||||
timeline.setFrame(frame, time, color.r, color.g, color.b);
|
||||
if (timelineMap.length == frame + 1) break;
|
||||
let nextMap = timelineMap[frame + 1];
|
||||
let time2 = getValue(nextMap, "time", 0);
|
||||
let newColor = new Color().setFromString(nextMap.color);
|
||||
let newColor = Color.fromString(nextMap.color);
|
||||
let curve = keyMap.curve;
|
||||
if (curve) {
|
||||
bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, color.r, newColor.r, 1);
|
||||
@ -532,22 +529,22 @@ module spine {
|
||||
timelines.push(timeline);
|
||||
|
||||
} else if (timelineName == "alpha") {
|
||||
timelines.push(readTimeline(timelineMap, new AlphaTimeline(timelineMap.length, timelineMap.length, slotIndex), 0, 1));
|
||||
timelines.push(readTimeline1(timelineMap, new AlphaTimeline(timelineMap.length, timelineMap.length, slotIndex), 0, 1));
|
||||
} else if (timelineName == "rgba2") {
|
||||
let timeline = new RGBA2Timeline(timelineMap.length, timelineMap.length * 7, slotIndex);
|
||||
|
||||
let keyMap = timelineMap[0];
|
||||
let time = getValue(keyMap, "time", 0);
|
||||
let color = new Color().setFromString(keyMap.light);
|
||||
let color2 = new Color().setFromString(keyMap.dark);
|
||||
let color = Color.fromString(keyMap.light);
|
||||
let color2 = Color.fromString(keyMap.dark);
|
||||
|
||||
for (let frame = 0, bezier = 0;; frame++) {
|
||||
timeline.setFrame(frame, time, color.r, color.g, color.b, color.a, color2.r, color2.g, color2.b);
|
||||
if (timelineMap.length == frame + 1) break;
|
||||
let nextMap = timelineMap[frame + 1];
|
||||
let time2 = getValue(nextMap, "time", 0);
|
||||
let newColor = new Color().setFromString(nextMap.light);
|
||||
let newColor2 = new Color().setFromString(nextMap.dark);
|
||||
let newColor = Color.fromString(nextMap.light);
|
||||
let newColor2 = Color.fromString(nextMap.dark);
|
||||
let curve = keyMap.curve;
|
||||
if (curve) {
|
||||
bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, color.r, newColor.r, 1);
|
||||
@ -571,16 +568,16 @@ module spine {
|
||||
|
||||
let keyMap = timelineMap[0];
|
||||
let time = getValue(keyMap, "time", 0);
|
||||
let color = new Color().setFromString(keyMap.light);
|
||||
let color2 = new Color().setFromString(keyMap.dark);
|
||||
let color = Color.fromString(keyMap.light);
|
||||
let color2 = Color.fromString(keyMap.dark);
|
||||
|
||||
for (let frame = 0, bezier = 0;; frame++) {
|
||||
timeline.setFrame(frame, time, color.r, color.g, color.b, color2.r, color2.g, color2.b);
|
||||
if (timelineMap.length == frame + 1) break;
|
||||
let nextMap = timelineMap[frame + 1];
|
||||
let time2 = getValue(nextMap, "time", 0);
|
||||
let newColor = new Color().setFromString(nextMap.light);
|
||||
let newColor2 = new Color().setFromString(nextMap.dark);
|
||||
let newColor = Color.fromString(nextMap.light);
|
||||
let newColor2 = Color.fromString(nextMap.dark);
|
||||
let curve = keyMap.curve;
|
||||
if (curve) {
|
||||
bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, color.r, newColor.r, 1);
|
||||
@ -615,34 +612,34 @@ module spine {
|
||||
if (timelineMap.length == 0) continue;
|
||||
|
||||
if (timelineName === "rotate") {
|
||||
timelines.push(readTimeline(timelineMap, new RotateTimeline(timelineMap.length, timelineMap.length, boneIndex), 0, 1));
|
||||
timelines.push(readTimeline1(timelineMap, new RotateTimeline(timelineMap.length, timelineMap.length, boneIndex), 0, 1));
|
||||
} else if (timelineName === "translate") {
|
||||
let timeline = new TranslateTimeline(timelineMap.length, timelineMap.length << 1, boneIndex);
|
||||
timelines.push(readTimeline2(timelineMap, timeline, "x", "y", 0, scale));
|
||||
} else if (timelineName === "translatex") {
|
||||
let timeline = new TranslateXTimeline(timelineMap.length, timelineMap.length, boneIndex);
|
||||
timelines.push(readTimeline(timelineMap, timeline, 0, scale));
|
||||
timelines.push(readTimeline1(timelineMap, timeline, 0, scale));
|
||||
} else if (timelineName === "translatey") {
|
||||
let timeline = new TranslateYTimeline(timelineMap.length, timelineMap.length, boneIndex);
|
||||
timelines.push(readTimeline(timelineMap, timeline, 0, scale));
|
||||
timelines.push(readTimeline1(timelineMap, timeline, 0, scale));
|
||||
} else if (timelineName === "scale") {
|
||||
let timeline = new ScaleTimeline(timelineMap.length, timelineMap.length << 1, boneIndex);
|
||||
timelines.push(readTimeline2(timelineMap, timeline, "x", "y", 1, 1));
|
||||
} else if (timelineName === "scalex") {
|
||||
let timeline = new ScaleXTimeline(timelineMap.length, timelineMap.length, boneIndex);
|
||||
timelines.push(readTimeline(timelineMap, timeline, 1, 1));
|
||||
timelines.push(readTimeline1(timelineMap, timeline, 1, 1));
|
||||
} else if (timelineName === "scaley") {
|
||||
let timeline = new ScaleYTimeline(timelineMap.length, timelineMap.length, boneIndex);
|
||||
timelines.push(readTimeline(timelineMap, timeline, 1, 1));
|
||||
timelines.push(readTimeline1(timelineMap, timeline, 1, 1));
|
||||
} else if (timelineName === "shear") {
|
||||
let timeline = new ShearTimeline(timelineMap.length, timelineMap.length << 1, boneIndex);
|
||||
timelines.push(readTimeline2(timelineMap, timeline, "x", "y", 0, 1));
|
||||
} else if (timelineName === "shearx") {
|
||||
let timeline = new ShearXTimeline(timelineMap.length, timelineMap.length, boneIndex);
|
||||
timelines.push(readTimeline(timelineMap, timeline, 0, 1));
|
||||
timelines.push(readTimeline1(timelineMap, timeline, 0, 1));
|
||||
} else if (timelineName === "sheary") {
|
||||
let timeline = new ShearYTimeline(timelineMap.length, timelineMap.length, boneIndex);
|
||||
timelines.push(readTimeline(timelineMap, timeline, 0, 1));
|
||||
timelines.push(readTimeline1(timelineMap, timeline, 0, 1));
|
||||
} else
|
||||
throw new Error("Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")");
|
||||
}
|
||||
@ -755,10 +752,10 @@ module spine {
|
||||
|
||||
if (timelineName === "position") {
|
||||
let timeline = new PathConstraintPositionTimeline(timelineMap.length, timelineMap.length, index);
|
||||
timelines.push(readTimeline(timelineMap, timeline, 0, data.positionMode == PositionMode.Fixed ? scale : 1));
|
||||
timelines.push(readTimeline1(timelineMap, timeline, 0, data.positionMode == PositionMode.Fixed ? scale : 1));
|
||||
} else if (timelineName === "spacing") {
|
||||
let timeline = new PathConstraintSpacingTimeline(timelineMap.length, timelineMap.length, index);
|
||||
timelines.push(readTimeline(timelineMap, timeline, 0, data.spacingMode == SpacingMode.Length || data.spacingMode == SpacingMode.Fixed ? scale : 1));
|
||||
timelines.push(readTimeline1(timelineMap, timeline, 0, data.spacingMode == SpacingMode.Length || data.spacingMode == SpacingMode.Fixed ? scale : 1));
|
||||
} else if (timelineName === "mix") {
|
||||
let timeline = new PathConstraintMixTimeline(timelineMap.size, timelineMap.size * 3, index);
|
||||
let time = getValue(keyMap, "time", 0);
|
||||
@ -913,115 +910,6 @@ module spine {
|
||||
|
||||
skeletonData.animations.push(new Animation(name, timelines, duration));
|
||||
}
|
||||
|
||||
static private readTimeline (keys: any[], timeline: CurveTimeline1, defaultValue: number, scale: number) {
|
||||
let keyMap = keys[0];
|
||||
let time = getValue(keyMap, "time", 0);
|
||||
let value = getValue(keyMap, "value", defaultValue) * scale;
|
||||
let bezier = 0;
|
||||
for (let frame = 0;; frame++) {
|
||||
timeline.setFrame(frame, time, value);
|
||||
let nextMap = keys[frame + 1];
|
||||
if (!nextMap) break;
|
||||
let time2 = getValue(nextMap, "time", 0);
|
||||
let value2 = getValue(nextMap, "value", defaultValue) * scale;
|
||||
let curve = keyMap.curve;
|
||||
if (curve) bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, value, value2, scale);
|
||||
time = time2;
|
||||
value = value2;
|
||||
keyMap = nextMap;
|
||||
}
|
||||
return timeline;
|
||||
}
|
||||
|
||||
static private readTimeline2 (keys: any[], timeline: CurveTimeline2, name1: string, name2: string, defaultValue: number, scale: number) {
|
||||
let keyMap = keys[0];
|
||||
let time = getValue(keyMap, "time", 0);
|
||||
let value1 = getValue(keyMap, name1, defaultValue) * scale;
|
||||
let value2 = getValue(keyMap, name2, defaultValue) * scale;
|
||||
let bezier = 0;
|
||||
for (let frame = 0;; frame++) {
|
||||
timeline.setFrame(frame, time, value1, value2);
|
||||
let nextMap = keys[frame + 1];
|
||||
if (!nextMap) break;
|
||||
let time2 = getValue(nextMap, "time", 0);
|
||||
let nvalue1 = getValue(nextMap, name1, defaultValue) * scale;
|
||||
let nvalue2 = getValue(nextMap, name2, defaultValue) * scale;
|
||||
let curve = keyMap.curve;
|
||||
if (curve != null) {
|
||||
bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, value1, nvalue1, scale);
|
||||
bezier = readCurve(curve, timeline, bezier, frame, 1, time, time2, value2, nvalue2, scale);
|
||||
}
|
||||
time = time2;
|
||||
value1 = nvalue1;
|
||||
value2 = nvalue2;
|
||||
keyMap = nextMap;
|
||||
}
|
||||
timeline.shrink(bezier);
|
||||
return timeline;
|
||||
}
|
||||
|
||||
static private readCurve (curve: any, timeline: CurveTimeline, bezier: number, frame: number, value: number, time1: number, time2: number,
|
||||
value1: number, value2: number, scale: number) {
|
||||
if (curve == "stepped") {
|
||||
if (value != 0) timeline.setStepped(frame);
|
||||
} else {
|
||||
let i = value << 2;
|
||||
let cx1 = curve[i++];
|
||||
let cy1 = curve[i++] * scale;
|
||||
let cx2 = curve[i++];
|
||||
let cy2 = curve[i++] * scale;
|
||||
timeline.setBezier(bezier++, frame, value, time1, value1, cx1, cy1, cx2, cy2, time2, value2);
|
||||
}
|
||||
return bezier;
|
||||
}
|
||||
|
||||
static private getValue (map: any, property: string, defaultValue: any) {
|
||||
return map[property] !== undefined ? map[property] : defaultValue;
|
||||
}
|
||||
|
||||
static private blendModeFromString (str: string) {
|
||||
str = str.toLowerCase();
|
||||
if (str == "normal") return BlendMode.Normal;
|
||||
if (str == "additive") return BlendMode.Additive;
|
||||
if (str == "multiply") return BlendMode.Multiply;
|
||||
if (str == "screen") return BlendMode.Screen;
|
||||
throw new Error(`Unknown blend mode: ${str}`);
|
||||
}
|
||||
|
||||
static private positionModeFromString (str: string) {
|
||||
str = str.toLowerCase();
|
||||
if (str == "fixed") return PositionMode.Fixed;
|
||||
if (str == "percent") return PositionMode.Percent;
|
||||
throw new Error(`Unknown position mode: ${str}`);
|
||||
}
|
||||
|
||||
static private spacingModeFromString (str: string) {
|
||||
str = str.toLowerCase();
|
||||
if (str == "length") return SpacingMode.Length;
|
||||
if (str == "fixed") return SpacingMode.Fixed;
|
||||
if (str == "percent") return SpacingMode.Percent;
|
||||
if (str == "proportional") return SpacingMode.Proportional;
|
||||
throw new Error(`Unknown spacing mode: ${str}`);
|
||||
}
|
||||
|
||||
static private rotateModeFromString (str: string) {
|
||||
str = str.toLowerCase();
|
||||
if (str == "tangent") return RotateMode.Tangent;
|
||||
if (str == "chain") return RotateMode.Chain;
|
||||
if (str == "chainscale") return RotateMode.ChainScale;
|
||||
throw new Error(`Unknown rotate mode: ${str}`);
|
||||
}
|
||||
|
||||
static private transformModeFromString(str: string) {
|
||||
str = str.toLowerCase();
|
||||
if (str == "normal") return TransformMode.Normal;
|
||||
if (str == "onlytranslation") return TransformMode.OnlyTranslation;
|
||||
if (str == "norotationorreflection") return TransformMode.NoRotationOrReflection;
|
||||
if (str == "noscale") return TransformMode.NoScale;
|
||||
if (str == "noscaleorreflection") return TransformMode.NoScaleOrReflection;
|
||||
throw new Error(`Unknown transform mode: ${str}`);
|
||||
}
|
||||
}
|
||||
|
||||
class LinkedMesh {
|
||||
@ -1038,4 +926,70 @@ module spine {
|
||||
this.inheritDeform = inheritDeform;
|
||||
}
|
||||
}
|
||||
|
||||
function readTimeline1 (keys: any[], timeline: CurveTimeline1, defaultValue: number, scale: number) {
|
||||
let keyMap = keys[0];
|
||||
let time = getValue(keyMap, "time", 0);
|
||||
let value = getValue(keyMap, "value", defaultValue) * scale;
|
||||
let bezier = 0;
|
||||
for (let frame = 0;; frame++) {
|
||||
timeline.setFrame(frame, time, value);
|
||||
let nextMap = keys[frame + 1];
|
||||
if (!nextMap) break;
|
||||
let time2 = getValue(nextMap, "time", 0);
|
||||
let value2 = getValue(nextMap, "value", defaultValue) * scale;
|
||||
let curve = keyMap.curve;
|
||||
if (curve) bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, value, value2, scale);
|
||||
time = time2;
|
||||
value = value2;
|
||||
keyMap = nextMap;
|
||||
}
|
||||
return timeline;
|
||||
}
|
||||
|
||||
function readTimeline2 (keys: any[], timeline: CurveTimeline2, name1: string, name2: string, defaultValue: number, scale: number) {
|
||||
let keyMap = keys[0];
|
||||
let time = getValue(keyMap, "time", 0);
|
||||
let value1 = getValue(keyMap, name1, defaultValue) * scale;
|
||||
let value2 = getValue(keyMap, name2, defaultValue) * scale;
|
||||
let bezier = 0;
|
||||
for (let frame = 0;; frame++) {
|
||||
timeline.setFrame(frame, time, value1, value2);
|
||||
let nextMap = keys[frame + 1];
|
||||
if (!nextMap) break;
|
||||
let time2 = getValue(nextMap, "time", 0);
|
||||
let nvalue1 = getValue(nextMap, name1, defaultValue) * scale;
|
||||
let nvalue2 = getValue(nextMap, name2, defaultValue) * scale;
|
||||
let curve = keyMap.curve;
|
||||
if (curve != null) {
|
||||
bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, value1, nvalue1, scale);
|
||||
bezier = readCurve(curve, timeline, bezier, frame, 1, time, time2, value2, nvalue2, scale);
|
||||
}
|
||||
time = time2;
|
||||
value1 = nvalue1;
|
||||
value2 = nvalue2;
|
||||
keyMap = nextMap;
|
||||
}
|
||||
timeline.shrink(bezier);
|
||||
return timeline;
|
||||
}
|
||||
|
||||
function readCurve (curve: any, timeline: CurveTimeline, bezier: number, frame: number, value: number, time1: number, time2: number,
|
||||
value1: number, value2: number, scale: number) {
|
||||
if (curve == "stepped") {
|
||||
if (value != 0) timeline.setStepped(frame);
|
||||
} else {
|
||||
let i = value << 2;
|
||||
let cx1 = curve[i++];
|
||||
let cy1 = curve[i++] * scale;
|
||||
let cx2 = curve[i++];
|
||||
let cy2 = curve[i++] * scale;
|
||||
timeline.setBezier(bezier++, frame, value, time1, value1, cx1, cy1, cx2, cy2, time2, value2);
|
||||
}
|
||||
return bezier;
|
||||
}
|
||||
|
||||
function getValue (map: any, property: string, defaultValue: any) {
|
||||
return map[property] !== undefined ? map[property] : defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,7 +31,6 @@ module spine {
|
||||
|
||||
/** Stores the setup pose for a {@link Slot}. */
|
||||
export class SlotData {
|
||||
|
||||
/** The index of the slot in {@link Skeleton#getSlots()}. */
|
||||
index: number;
|
||||
|
||||
@ -64,4 +63,7 @@ module spine {
|
||||
this.boneData = boneData;
|
||||
}
|
||||
}
|
||||
|
||||
/** Determines how images are blended with existing pixels when drawn. */
|
||||
export enum BlendMode { Normal, Additive, Multiply, Screen }
|
||||
}
|
||||
|
||||
@ -42,28 +42,6 @@ module spine {
|
||||
abstract setFilters (minFilter: TextureFilter, magFilter: TextureFilter): void;
|
||||
abstract setWraps (uWrap: TextureWrap, vWrap: TextureWrap): void;
|
||||
abstract dispose (): void;
|
||||
|
||||
public static filterFromString (text: string): TextureFilter {
|
||||
switch (text.toLowerCase()) {
|
||||
case "nearest": return TextureFilter.Nearest;
|
||||
case "linear": return TextureFilter.Linear;
|
||||
case "mipmap": return TextureFilter.MipMap;
|
||||
case "mipmapnearestnearest": return TextureFilter.MipMapNearestNearest;
|
||||
case "mipmaplinearnearest": return TextureFilter.MipMapLinearNearest;
|
||||
case "mipmapnearestlinear": return TextureFilter.MipMapNearestLinear;
|
||||
case "mipmaplinearlinear": return TextureFilter.MipMapLinearLinear;
|
||||
default: throw new Error(`Unknown texture filter ${text}`);
|
||||
}
|
||||
}
|
||||
|
||||
public static wrapFromString (text: string): TextureWrap {
|
||||
switch (text.toLowerCase()) {
|
||||
case "mirroredtepeat": return TextureWrap.MirroredRepeat;
|
||||
case "clamptoedge": return TextureWrap.ClampToEdge;
|
||||
case "repeat": return TextureWrap.Repeat;
|
||||
default: throw new Error(`Unknown texture wrap ${text}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export enum TextureFilter {
|
||||
|
||||
@ -54,8 +54,8 @@ module spine {
|
||||
// page.format = Format[tuple[0]]; we don't need format in WebGL
|
||||
};
|
||||
pageFields["filter"] = () => {
|
||||
page.minFilter = Texture.filterFromString(entry[1]);
|
||||
page.magFilter = Texture.filterFromString(entry[2]);
|
||||
page.minFilter = Utils.enumValue(TextureFilter, entry[1]);
|
||||
page.magFilter = Utils.enumValue(TextureFilter, entry[2]);
|
||||
};
|
||||
pageFields["repeat"] = () => {
|
||||
if (entry[1].indexOf('x') != -1) page.uWrap = TextureWrap.Repeat;
|
||||
@ -153,7 +153,7 @@ module spine {
|
||||
else {
|
||||
if (names == null) {
|
||||
names = [];
|
||||
values = []
|
||||
values = [];
|
||||
}
|
||||
names.push(entry[0]);
|
||||
let entryValues: number[] = [];
|
||||
|
||||
@ -165,6 +165,10 @@ module spine {
|
||||
color.g = ((value & 0x0000ff00) >>> 8) / 255;
|
||||
color.b = ((value & 0x000000ff)) / 255;
|
||||
}
|
||||
|
||||
static fromString (hex : string) : Color {
|
||||
return new Color().setFromString(hex);
|
||||
}
|
||||
}
|
||||
|
||||
export class MathUtils {
|
||||
@ -318,6 +322,10 @@ module spine {
|
||||
if (array[i] == element) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static enumValue (type: any, name: string) {
|
||||
return type[name[0].toUpperCase() + name.slice(1)];
|
||||
}
|
||||
}
|
||||
|
||||
export class DebugUtils {
|
||||
|
||||
@ -1,34 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
module spine {
|
||||
export enum AttachmentType {
|
||||
Region, BoundingBox, Mesh, LinkedMesh, Path, Point, Clipping
|
||||
}
|
||||
}
|
||||
@ -33,51 +33,6 @@ module spine {
|
||||
*
|
||||
* See [Region attachments](http://esotericsoftware.com/spine-regions) in the Spine User Guide. */
|
||||
export class RegionAttachment extends Attachment {
|
||||
static OX1 = 0;
|
||||
static OY1 = 1;
|
||||
static OX2 = 2;
|
||||
static OY2 = 3;
|
||||
static OX3 = 4;
|
||||
static OY3 = 5;
|
||||
static OX4 = 6;
|
||||
static OY4 = 7;
|
||||
|
||||
static X1 = 0;
|
||||
static Y1 = 1;
|
||||
static C1R = 2;
|
||||
static C1G = 3;
|
||||
static C1B = 4;
|
||||
static C1A = 5;
|
||||
static U1 = 6;
|
||||
static V1 = 7;
|
||||
|
||||
static X2 = 8;
|
||||
static Y2 = 9;
|
||||
static C2R = 10;
|
||||
static C2G = 11;
|
||||
static C2B = 12;
|
||||
static C2A = 13;
|
||||
static U2 = 14;
|
||||
static V2 = 15;
|
||||
|
||||
static X3 = 16;
|
||||
static Y3 = 17;
|
||||
static C3R = 18;
|
||||
static C3G = 19;
|
||||
static C3B = 20;
|
||||
static C3A = 21;
|
||||
static U3 = 22;
|
||||
static V3 = 23;
|
||||
|
||||
static X4 = 24;
|
||||
static Y4 = 25;
|
||||
static C4R = 26;
|
||||
static C4G = 27;
|
||||
static C4B = 28;
|
||||
static C4A = 29;
|
||||
static U4 = 30;
|
||||
static V4 = 31;
|
||||
|
||||
/** The local x translation. */
|
||||
x = 0;
|
||||
|
||||
@ -142,14 +97,14 @@ module spine {
|
||||
let localY2Cos = localY2 * cos + this.y;
|
||||
let localY2Sin = localY2 * sin;
|
||||
let offset = this.offset;
|
||||
offset[RegionAttachment.OX1] = localXCos - localYSin;
|
||||
offset[RegionAttachment.OY1] = localYCos + localXSin;
|
||||
offset[RegionAttachment.OX2] = localXCos - localY2Sin;
|
||||
offset[RegionAttachment.OY2] = localY2Cos + localXSin;
|
||||
offset[RegionAttachment.OX3] = localX2Cos - localY2Sin;
|
||||
offset[RegionAttachment.OY3] = localY2Cos + localX2Sin;
|
||||
offset[RegionAttachment.OX4] = localX2Cos - localYSin;
|
||||
offset[RegionAttachment.OY4] = localYCos + localX2Sin;
|
||||
offset[0] = localXCos - localYSin;
|
||||
offset[1] = localYCos + localXSin;
|
||||
offset[2] = localXCos - localY2Sin;
|
||||
offset[3] = localY2Cos + localXSin;
|
||||
offset[4] = localX2Cos - localY2Sin;
|
||||
offset[5] = localY2Cos + localX2Sin;
|
||||
offset[6] = localX2Cos - localYSin;
|
||||
offset[7] = localYCos + localX2Sin;
|
||||
}
|
||||
|
||||
setRegion (region: TextureRegion) : void {
|
||||
@ -189,26 +144,26 @@ module spine {
|
||||
let a = bone.a, b = bone.b, c = bone.c, d = bone.d;
|
||||
let offsetX = 0, offsetY = 0;
|
||||
|
||||
offsetX = vertexOffset[RegionAttachment.OX1];
|
||||
offsetY = vertexOffset[RegionAttachment.OY1];
|
||||
offsetX = vertexOffset[0];
|
||||
offsetY = vertexOffset[1];
|
||||
worldVertices[offset] = offsetX * a + offsetY * b + x; // br
|
||||
worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
|
||||
offset += stride;
|
||||
|
||||
offsetX = vertexOffset[RegionAttachment.OX2];
|
||||
offsetY = vertexOffset[RegionAttachment.OY2];
|
||||
offsetX = vertexOffset[2];
|
||||
offsetY = vertexOffset[3];
|
||||
worldVertices[offset] = offsetX * a + offsetY * b + x; // bl
|
||||
worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
|
||||
offset += stride;
|
||||
|
||||
offsetX = vertexOffset[RegionAttachment.OX3];
|
||||
offsetY = vertexOffset[RegionAttachment.OY3];
|
||||
offsetX = vertexOffset[4];
|
||||
offsetY = vertexOffset[5];
|
||||
worldVertices[offset] = offsetX * a + offsetY * b + x; // ul
|
||||
worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
|
||||
offset += stride;
|
||||
|
||||
offsetX = vertexOffset[RegionAttachment.OX4];
|
||||
offsetY = vertexOffset[RegionAttachment.OY4];
|
||||
offsetX = vertexOffset[6];
|
||||
offsetY = vertexOffset[7];
|
||||
worldVertices[offset] = offsetX * a + offsetY * b + x; // ur
|
||||
worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
|
||||
}
|
||||
@ -230,5 +185,41 @@ module spine {
|
||||
copy.color.setFromColor(this.color);
|
||||
return copy;
|
||||
}
|
||||
|
||||
static X1 = 0;
|
||||
static Y1 = 1;
|
||||
static C1R = 2;
|
||||
static C1G = 3;
|
||||
static C1B = 4;
|
||||
static C1A = 5;
|
||||
static U1 = 6;
|
||||
static V1 = 7;
|
||||
|
||||
static X2 = 8;
|
||||
static Y2 = 9;
|
||||
static C2R = 10;
|
||||
static C2G = 11;
|
||||
static C2B = 12;
|
||||
static C2A = 13;
|
||||
static U2 = 14;
|
||||
static V2 = 15;
|
||||
|
||||
static X3 = 16;
|
||||
static Y3 = 17;
|
||||
static C3R = 18;
|
||||
static C3G = 19;
|
||||
static C3B = 20;
|
||||
static C3A = 21;
|
||||
static U3 = 22;
|
||||
static V3 = 23;
|
||||
|
||||
static X4 = 24;
|
||||
static Y4 = 25;
|
||||
static C4R = 26;
|
||||
static C4G = 27;
|
||||
static C4B = 28;
|
||||
static C4A = 29;
|
||||
static U4 = 30;
|
||||
static V4 = 31;
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,6 +33,7 @@ var shapes;
|
||||
var lastFrameTime;
|
||||
var skeletons = {};
|
||||
var activeSkeleton = "spineboy";
|
||||
var pow2 = new spine.Pow(2);
|
||||
var swirlEffect = new spine.SwirlEffect(0);
|
||||
var jitterEffect = new spine.JitterEffect(20, 20);
|
||||
var swirlTime = 0;
|
||||
@ -83,42 +84,46 @@ function init () {
|
||||
assetManager.loadTextureAtlas("assets/stretchyman-pma.atlas");
|
||||
assetManager.loadBinary("assets/coin-pro.skel");
|
||||
assetManager.loadTextureAtlas("assets/coin-pma.atlas");
|
||||
assetManager.loadBinary("assets/mix-and-match-pro.skel");
|
||||
assetManager.loadText("assets/mix-and-match-pro.json");
|
||||
assetManager.loadTextureAtlas("assets/mix-and-match-pma.atlas");
|
||||
requestAnimationFrame(load);
|
||||
}
|
||||
|
||||
function load () {
|
||||
// Wait until the AssetManager has loaded all resources, then load the skeletons.
|
||||
if (assetManager.isLoadingComplete()) {
|
||||
skeletons["raptor"] = loadSkeleton("raptor-pro", "walk", true);
|
||||
skeletons["spineboy"] = loadSkeleton("spineboy-pro", "run", true);
|
||||
skeletons["tank"] = loadSkeleton("tank-pro", "drive", true);
|
||||
skeletons["goblins"] = loadSkeleton("goblins-pro", "walk", true, "goblin");
|
||||
skeletons["vine"] = loadSkeleton("vine-pro", "grow", true);
|
||||
skeletons["stretchyman"] = loadSkeleton("stretchyman-pro", "sneak", true);
|
||||
skeletons["coin"] = loadSkeleton("coin-pro", "animation", true);
|
||||
skeletons["coin"] = loadSkeleton("coin-pro.skel", "animation", true);
|
||||
skeletons["goblins"] = loadSkeleton("goblins-pro.skel", "walk", true, "goblin");
|
||||
skeletons["mix-and-match-skel"] = loadSkeleton("mix-and-match-pro.skel", "dance", true, "full-skins/girl-blue-cape");
|
||||
skeletons["mix-and-match-json"] = loadSkeleton("mix-and-match-pro.json", "dance", true, "full-skins/girl-blue-cape");
|
||||
skeletons["raptor"] = loadSkeleton("raptor-pro.skel", "walk", true);
|
||||
skeletons["spineboy"] = loadSkeleton("spineboy-pro.skel", "run", true);
|
||||
skeletons["stretchyman"] = loadSkeleton("stretchyman-pro.skel", "sneak", true);
|
||||
skeletons["tank"] = loadSkeleton("tank-pro.skel", "drive", true);
|
||||
skeletons["vine"] = loadSkeleton("vine-pro.skel", "grow", true);
|
||||
setupUI();
|
||||
lastFrameTime = Date.now() / 1000;
|
||||
requestAnimationFrame(render); // Loading is done, call render every frame.
|
||||
} else {
|
||||
} else
|
||||
requestAnimationFrame(load);
|
||||
}
|
||||
}
|
||||
|
||||
function loadSkeleton (name, initialAnimation, premultipliedAlpha, skin) {
|
||||
if (skin === undefined) skin = "default";
|
||||
|
||||
// Load the texture atlas using name.atlas from the AssetManager.
|
||||
var atlas = assetManager.get("assets/" + name.replace("-ess", "").replace("-pro", "") + (premultipliedAlpha ? "-pma": "") + ".atlas");
|
||||
var atlas = assetManager.get("assets/" + name.replace(/(?:-ess|-pro)\.(skel|json)/, "") + (premultipliedAlpha ? "-pma": "") + ".atlas");
|
||||
|
||||
// Create a AtlasAttachmentLoader that resolves region, mesh, boundingbox and path attachments
|
||||
// Create an AtlasAttachmentLoader that resolves region, mesh, boundingbox and path attachments
|
||||
var atlasLoader = new spine.AtlasAttachmentLoader(atlas);
|
||||
|
||||
// Create a SkeletonBinary instance for parsing the .skel file.
|
||||
var skeletonBinary = new spine.SkeletonBinary(atlasLoader);
|
||||
// Create a skeleton loader instance for parsing the skeleton data file.
|
||||
var skeletonLoader = name.endsWith(".skel") ? new spine.SkeletonBinary(atlasLoader) : new spine.SkeletonJson(atlasLoader);
|
||||
|
||||
// Set the scale to apply during parsing, parse the file, and create a new skeleton.
|
||||
skeletonBinary.scale = 1;
|
||||
var skeletonData = skeletonBinary.readSkeletonData(assetManager.get("assets/" + name + ".skel"));
|
||||
skeletonLoader.scale = 1;
|
||||
var skeletonData = skeletonLoader.readSkeletonData(assetManager.get("assets/" + name));
|
||||
var skeleton = new spine.Skeleton(skeletonData);
|
||||
skeleton.setSkinByName(skin);
|
||||
var bounds = calculateSetupPoseBounds(skeleton);
|
||||
@ -126,33 +131,43 @@ function loadSkeleton (name, initialAnimation, premultipliedAlpha, skin) {
|
||||
// Create an AnimationState, and set the initial animation in looping mode.
|
||||
var animationStateData = new spine.AnimationStateData(skeleton.data);
|
||||
var animationState = new spine.AnimationState(animationStateData);
|
||||
if (name == "spineboy") {
|
||||
animationStateData.setMix("walk", "jump", 0.4)
|
||||
if (name == "spineboy-pro.skel") {
|
||||
animationStateData.setMix("walk", "run", 1.5)
|
||||
animationStateData.setMix("run", "jump", 0.2)
|
||||
animationStateData.setMix("jump", "run", 0.4);
|
||||
animationState.setAnimation(0, "walk", true);
|
||||
var jumpEntry = animationState.addAnimation(0, "jump", false, 3);
|
||||
animationState.setEmptyAnimation(0, 0);
|
||||
var entry = animationState.addAnimation(0, "walk", true, 0);
|
||||
entry.mixDuration = 1;
|
||||
animationState.addAnimation(0, "run", true, 1.5);
|
||||
animationState.addAnimation(0, "jump", false, 2);
|
||||
animationState.addAnimation(0, "run", true, 0);
|
||||
} else {
|
||||
animationState.addEmptyAnimation(0, 1, 1);
|
||||
entry = animationState.addAnimation(0, "walk", true, 1.5);
|
||||
entry.mixDuration = 1;
|
||||
} else
|
||||
animationState.setAnimation(0, initialAnimation, true);
|
||||
|
||||
function log (message) {
|
||||
if ($('#debug').is(':checked')) console.log(message);
|
||||
}
|
||||
animationState.addListener({
|
||||
start: function(track) {
|
||||
console.log("Animation on track " + track.trackIndex + " started");
|
||||
log("Animation on track " + track.trackIndex + " started");
|
||||
},
|
||||
interrupt: function(track) {
|
||||
console.log("Animation on track " + track.trackIndex + " interrupted");
|
||||
log("Animation on track " + track.trackIndex + " interrupted");
|
||||
},
|
||||
end: function(track) {
|
||||
console.log("Animation on track " + track.trackIndex + " ended");
|
||||
log("Animation on track " + track.trackIndex + " ended");
|
||||
},
|
||||
disposed: function(track) {
|
||||
console.log("Animation on track " + track.trackIndex + " disposed");
|
||||
log("Animation on track " + track.trackIndex + " disposed");
|
||||
},
|
||||
complete: function(track) {
|
||||
console.log("Animation on track " + track.trackIndex + " completed");
|
||||
log("Animation on track " + track.trackIndex + " completed");
|
||||
},
|
||||
event: function(track, event) {
|
||||
console.log("Event on track " + track.trackIndex + ": " + JSON.stringify(event));
|
||||
log("Event on track " + track.trackIndex + ": " + JSON.stringify(event));
|
||||
}
|
||||
})
|
||||
|
||||
@ -273,14 +288,13 @@ function render () {
|
||||
swirlTime += delta;
|
||||
var percent = swirlTime % 2;
|
||||
if (percent > 1) percent = 1 - (percent -1 );
|
||||
swirlEffect.angle = 120 * percent - 60;
|
||||
swirlEffect.angle = pow2.apply(-60, 60, percent);
|
||||
swirlEffect.centerX = bounds.offset.x + bounds.size.x / 2;
|
||||
swirlEffect.centerY = bounds.offset.y + bounds.size.y / 2;
|
||||
swirlEffect.radius = Math.sqrt(bounds.size.x * bounds.size.x + bounds.size.y * bounds.size.y);
|
||||
swirlEffect.radius = Math.sqrt(bounds.size.x * bounds.size.x + bounds.size.y * bounds.size.y) * 0.75;
|
||||
skeletonRenderer.vertexEffect = swirlEffect;
|
||||
} else if (effect == "Jitter") {
|
||||
} else if (effect == "Jitter")
|
||||
skeletonRenderer.vertexEffect = jitterEffect;
|
||||
}
|
||||
|
||||
skeletonRenderer.premultipliedAlpha = premultipliedAlpha;
|
||||
skeletonRenderer.draw(batcher, skeleton);
|
||||
@ -317,7 +331,7 @@ function resize () {
|
||||
var centerY = bounds.offset.y + bounds.size.y / 2;
|
||||
var scaleX = bounds.size.x / canvas.width;
|
||||
var scaleY = bounds.size.y / canvas.height;
|
||||
var scale = Math.max(scaleX, scaleY) * 1.2;
|
||||
var scale = Math.max(scaleX, scaleY) * 2;
|
||||
if (scale < 1) scale = 1;
|
||||
var width = canvas.width * scale;
|
||||
var height = canvas.height * scale;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user