[ts] Fixed SwirlEffect

This commit is contained in:
badlogic 2017-06-21 16:08:17 +02:00
parent 5aebd65c01
commit 40010cb228
21 changed files with 11206 additions and 10239 deletions

View File

@ -962,6 +962,21 @@ declare module spine {
static signum(value: number): number; static signum(value: number): number;
static toInt(x: number): number; static toInt(x: number): number;
static cbrt(x: number): number; static cbrt(x: number): number;
static randomTriangular(min: number, max: number): number;
static randomTriangularWith(min: number, max: number, mode: number): number;
}
abstract class Interpolation {
protected abstract applyInternal(a: number): number;
apply(start: number, end: number, a: number): number;
}
class Pow extends Interpolation {
protected power: number;
constructor(power: number);
applyInternal(a: number): number;
}
class PowOut extends Pow {
constructor(power: number);
applyInternal(a: number): number;
} }
class Utils { class Utils {
static SUPPORTS_TYPED_ARRAYS: boolean; static SUPPORTS_TYPED_ARRAYS: boolean;
@ -1019,6 +1034,13 @@ declare module spine {
getMean(): number; getMean(): number;
} }
} }
declare module spine {
interface VertexEffect {
begin(skeleton: Skeleton): void;
transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void;
end(): void;
}
}
declare module spine { declare module spine {
abstract class Attachment { abstract class Attachment {
name: string; name: string;
@ -1169,6 +1191,31 @@ declare module spine {
computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void; computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
} }
} }
declare module spine {
class JitterEffect implements VertexEffect {
jitterX: number;
jitterY: number;
constructor(jitterX: number, jitterY: number);
begin(skeleton: Skeleton): void;
transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void;
end(): void;
}
}
declare module spine {
class SwirlEffect implements VertexEffect {
static interpolation: PowOut;
centerX: number;
centerY: number;
radius: number;
angle: number;
private worldX;
private worldY;
constructor(radius: number);
begin(skeleton: Skeleton): void;
transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void;
end(): void;
}
}
declare module spine.canvas { declare module spine.canvas {
class AssetManager extends spine.AssetManager { class AssetManager extends spine.AssetManager {
constructor(pathPrefix?: string); constructor(pathPrefix?: string);
@ -1571,6 +1618,7 @@ declare module spine.webgl {
class SkeletonRenderer { class SkeletonRenderer {
static QUAD_TRIANGLES: number[]; static QUAD_TRIANGLES: number[];
premultipliedAlpha: boolean; premultipliedAlpha: boolean;
vertexEffect: VertexEffect;
private tempColor; private tempColor;
private tempColor2; private tempColor2;
private vertices; private vertices;
@ -1578,6 +1626,10 @@ declare module spine.webgl {
private twoColorTint; private twoColorTint;
private renderable; private renderable;
private clipper; private clipper;
private temp;
private temp2;
private temp3;
private temp4;
constructor(context: ManagedWebGLRenderingContext, twoColorTint?: boolean); constructor(context: ManagedWebGLRenderingContext, twoColorTint?: boolean);
draw(batcher: PolygonBatcher, skeleton: Skeleton): void; draw(batcher: PolygonBatcher, skeleton: Skeleton): void;
} }

View File

@ -5747,6 +5747,16 @@ var spine;
var y = Math.pow(Math.abs(x), 1 / 3); var y = Math.pow(Math.abs(x), 1 / 3);
return x < 0 ? -y : y; return x < 0 ? -y : y;
}; };
MathUtils.randomTriangular = function (min, max) {
return MathUtils.randomTriangularWith(min, max, (min + max) * 0.5);
};
MathUtils.randomTriangularWith = function (min, max, mode) {
var u = Math.random();
var d = max - min;
if (u <= (mode - min) / d)
return min + Math.sqrt(u * d * (mode - min));
return max - Math.sqrt((1 - u) * d * (max - mode));
};
return MathUtils; return MathUtils;
}()); }());
MathUtils.PI = 3.1415927; MathUtils.PI = 3.1415927;
@ -5756,6 +5766,42 @@ var spine;
MathUtils.degreesToRadians = MathUtils.PI / 180; MathUtils.degreesToRadians = MathUtils.PI / 180;
MathUtils.degRad = MathUtils.degreesToRadians; MathUtils.degRad = MathUtils.degreesToRadians;
spine.MathUtils = MathUtils; spine.MathUtils = MathUtils;
var Interpolation = (function () {
function Interpolation() {
}
Interpolation.prototype.apply = function (start, end, a) {
return start + (end - start) * this.applyInternal(a);
};
return Interpolation;
}());
spine.Interpolation = Interpolation;
var Pow = (function (_super) {
__extends(Pow, _super);
function Pow(power) {
var _this = _super.call(this) || this;
_this.power = 2;
_this.power = power;
return _this;
}
Pow.prototype.applyInternal = function (a) {
if (a <= 0.5)
return Math.pow(a * 2, this.power) / 2;
return Math.pow((a - 1) * 2, this.power) / (this.power % 2 == 0 ? -2 : 2) + 1;
};
return Pow;
}(Interpolation));
spine.Pow = Pow;
var PowOut = (function (_super) {
__extends(PowOut, _super);
function PowOut(power) {
return _super.call(this, power) || this;
}
PowOut.prototype.applyInternal = function (a) {
return Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1;
};
return PowOut;
}(Pow));
spine.PowOut = PowOut;
var Utils = (function () { var Utils = (function () {
function Utils() { function Utils() {
} }
@ -6317,6 +6363,63 @@ var spine;
spine.RegionAttachment = RegionAttachment; spine.RegionAttachment = RegionAttachment;
})(spine || (spine = {})); })(spine || (spine = {}));
var spine; var spine;
(function (spine) {
var JitterEffect = (function () {
function JitterEffect(jitterX, jitterY) {
this.jitterX = 0;
this.jitterY = 0;
this.jitterX = jitterX;
this.jitterY = jitterY;
}
JitterEffect.prototype.begin = function (skeleton) {
};
JitterEffect.prototype.transform = function (position, uv, light, dark) {
position.x += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY);
position.y += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY);
};
JitterEffect.prototype.end = function () {
};
return JitterEffect;
}());
spine.JitterEffect = JitterEffect;
})(spine || (spine = {}));
var spine;
(function (spine) {
var SwirlEffect = (function () {
function SwirlEffect(radius) {
this.centerX = 0;
this.centerY = 0;
this.radius = 0;
this.angle = 0;
this.worldX = 0;
this.worldY = 0;
this.radius = radius;
}
SwirlEffect.prototype.begin = function (skeleton) {
this.worldX = skeleton.x + this.centerX;
this.worldY = skeleton.y + this.centerY;
};
SwirlEffect.prototype.transform = function (position, uv, light, dark) {
var radAngle = this.angle * spine.MathUtils.degreesToRadians;
var x = position.x - this.worldX;
var y = position.y - this.worldY;
var dist = Math.sqrt(x * x + y * y);
if (dist < this.radius) {
var theta = SwirlEffect.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius);
var cos = Math.cos(theta);
var sin = Math.sin(theta);
position.x = cos * x - sin * y + this.worldX;
position.y = sin * x + cos * y + this.worldY;
}
};
SwirlEffect.prototype.end = function () {
};
return SwirlEffect;
}());
SwirlEffect.interpolation = new spine.PowOut(2);
spine.SwirlEffect = SwirlEffect;
})(spine || (spine = {}));
var spine;
(function (spine) { (function (spine) {
var canvas; var canvas;
(function (canvas) { (function (canvas) {
@ -8674,12 +8777,17 @@ var spine;
function SkeletonRenderer(context, twoColorTint) { function SkeletonRenderer(context, twoColorTint) {
if (twoColorTint === void 0) { twoColorTint = true; } if (twoColorTint === void 0) { twoColorTint = true; }
this.premultipliedAlpha = false; this.premultipliedAlpha = false;
this.vertexEffect = null;
this.tempColor = new spine.Color(); this.tempColor = new spine.Color();
this.tempColor2 = new spine.Color(); this.tempColor2 = new spine.Color();
this.vertexSize = 2 + 2 + 4; this.vertexSize = 2 + 2 + 4;
this.twoColorTint = false; this.twoColorTint = false;
this.renderable = new Renderable(null, 0, 0); this.renderable = new Renderable(null, 0, 0);
this.clipper = new spine.SkeletonClipping(); this.clipper = new spine.SkeletonClipping();
this.temp = new spine.Vector2();
this.temp2 = new spine.Vector2();
this.temp3 = new spine.Color();
this.temp4 = new spine.Color();
this.twoColorTint = twoColorTint; this.twoColorTint = twoColorTint;
if (twoColorTint) if (twoColorTint)
this.vertexSize += 4; this.vertexSize += 4;
@ -8690,6 +8798,10 @@ var spine;
var premultipliedAlpha = this.premultipliedAlpha; var premultipliedAlpha = this.premultipliedAlpha;
var twoColorTint = this.twoColorTint; var twoColorTint = this.twoColorTint;
var blendMode = null; var blendMode = null;
var tempPos = this.temp;
var tempUv = this.temp2;
var tempLight = this.temp3;
var tempDark = this.temp4;
var renderable = this.renderable; var renderable = this.renderable;
var uvs = null; var uvs = null;
var triangles = null; var triangles = null;
@ -8764,8 +8876,54 @@ var spine;
} }
else { else {
var verts = renderable.vertices; var verts = renderable.vertices;
if (this.vertexEffect != null) {
var vertexEffect = this.vertexEffect;
if (!twoColorTint) { if (!twoColorTint) {
for (var v = 2, u = 0, n_3 = renderable.numFloats; v < n_3; v += vertexSize, u += 2) { for (var v = 0, u = 0, n_3 = renderable.numFloats; v < n_3; v += vertexSize, u += 2) {
tempPos.x = verts[v];
tempPos.y = verts[v + 1];
tempUv.x = uvs[u];
tempUv.y = uvs[u + 1];
tempLight.setFromColor(finalColor);
tempDark.set(0, 0, 0, 0);
vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
verts[v] = tempPos.x;
verts[v + 1] = tempPos.y;
verts[v + 2] = tempLight.r;
verts[v + 3] = tempLight.g;
verts[v + 4] = tempLight.b;
verts[v + 5] = tempLight.a;
verts[v + 6] = tempUv.x;
verts[v + 7] = tempUv.y;
}
}
else {
for (var v = 0, u = 0, n_4 = renderable.numFloats; v < n_4; v += vertexSize, u += 2) {
tempPos.x = verts[v];
tempPos.y = verts[v + 1];
tempUv.x = uvs[u];
tempUv.y = uvs[u + 1];
tempLight.setFromColor(finalColor);
tempDark.setFromColor(darkColor);
vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
verts[v] = tempPos.x;
verts[v + 1] = tempPos.y;
verts[v + 2] = tempLight.r;
verts[v + 3] = tempLight.g;
verts[v + 4] = tempLight.b;
verts[v + 5] = tempLight.a;
verts[v + 6] = tempUv.x;
verts[v + 7] = tempUv.y;
verts[v + 8] = tempDark.r;
verts[v + 9] = tempDark.g;
verts[v + 10] = tempDark.b;
verts[v + 11] = tempDark.a;
}
}
}
else {
if (!twoColorTint) {
for (var v = 2, u = 0, n_5 = renderable.numFloats; v < n_5; v += vertexSize, u += 2) {
verts[v] = finalColor.r; verts[v] = finalColor.r;
verts[v + 1] = finalColor.g; verts[v + 1] = finalColor.g;
verts[v + 2] = finalColor.b; verts[v + 2] = finalColor.b;
@ -8775,7 +8933,7 @@ var spine;
} }
} }
else { else {
for (var v = 2, u = 0, n_4 = renderable.numFloats; v < n_4; v += vertexSize, u += 2) { for (var v = 2, u = 0, n_6 = renderable.numFloats; v < n_6; v += vertexSize, u += 2) {
verts[v] = finalColor.r; verts[v] = finalColor.r;
verts[v + 1] = finalColor.g; verts[v + 1] = finalColor.g;
verts[v + 2] = finalColor.b; verts[v + 2] = finalColor.b;
@ -8788,6 +8946,7 @@ var spine;
verts[v + 9] = darkColor.a; verts[v + 9] = darkColor.a;
} }
} }
}
var view = renderable.vertices.subarray(0, renderable.numFloats); var view = renderable.vertices.subarray(0, renderable.numFloats);
batcher.draw(texture, view, triangles); batcher.draw(texture, view, triangles);
} }
@ -9153,7 +9312,7 @@ var spine;
} }
else { else {
var verts = vertices; var verts = vertices;
for (var v = 2, u = 0, n_5 = numFloats; v < n_5; v += vertexSize, u += 2) { for (var v = 2, u = 0, n_7 = numFloats; v < n_7; v += vertexSize, u += 2) {
verts[v] = color.r; verts[v] = color.r;
verts[v + 1] = color.g; verts[v + 1] = color.g;
verts[v + 2] = color.b; verts[v + 2] = color.b;

File diff suppressed because one or more lines are too long

View File

@ -962,6 +962,21 @@ declare module spine {
static signum(value: number): number; static signum(value: number): number;
static toInt(x: number): number; static toInt(x: number): number;
static cbrt(x: number): number; static cbrt(x: number): number;
static randomTriangular(min: number, max: number): number;
static randomTriangularWith(min: number, max: number, mode: number): number;
}
abstract class Interpolation {
protected abstract applyInternal(a: number): number;
apply(start: number, end: number, a: number): number;
}
class Pow extends Interpolation {
protected power: number;
constructor(power: number);
applyInternal(a: number): number;
}
class PowOut extends Pow {
constructor(power: number);
applyInternal(a: number): number;
} }
class Utils { class Utils {
static SUPPORTS_TYPED_ARRAYS: boolean; static SUPPORTS_TYPED_ARRAYS: boolean;
@ -1019,6 +1034,13 @@ declare module spine {
getMean(): number; getMean(): number;
} }
} }
declare module spine {
interface VertexEffect {
begin(skeleton: Skeleton): void;
transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void;
end(): void;
}
}
declare module spine { declare module spine {
abstract class Attachment { abstract class Attachment {
name: string; name: string;
@ -1169,6 +1191,31 @@ declare module spine {
computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void; computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
} }
} }
declare module spine {
class JitterEffect implements VertexEffect {
jitterX: number;
jitterY: number;
constructor(jitterX: number, jitterY: number);
begin(skeleton: Skeleton): void;
transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void;
end(): void;
}
}
declare module spine {
class SwirlEffect implements VertexEffect {
static interpolation: PowOut;
centerX: number;
centerY: number;
radius: number;
angle: number;
private worldX;
private worldY;
constructor(radius: number);
begin(skeleton: Skeleton): void;
transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void;
end(): void;
}
}
declare module spine.canvas { declare module spine.canvas {
class AssetManager extends spine.AssetManager { class AssetManager extends spine.AssetManager {
constructor(pathPrefix?: string); constructor(pathPrefix?: string);

View File

@ -5747,6 +5747,16 @@ var spine;
var y = Math.pow(Math.abs(x), 1 / 3); var y = Math.pow(Math.abs(x), 1 / 3);
return x < 0 ? -y : y; return x < 0 ? -y : y;
}; };
MathUtils.randomTriangular = function (min, max) {
return MathUtils.randomTriangularWith(min, max, (min + max) * 0.5);
};
MathUtils.randomTriangularWith = function (min, max, mode) {
var u = Math.random();
var d = max - min;
if (u <= (mode - min) / d)
return min + Math.sqrt(u * d * (mode - min));
return max - Math.sqrt((1 - u) * d * (max - mode));
};
return MathUtils; return MathUtils;
}()); }());
MathUtils.PI = 3.1415927; MathUtils.PI = 3.1415927;
@ -5756,6 +5766,42 @@ var spine;
MathUtils.degreesToRadians = MathUtils.PI / 180; MathUtils.degreesToRadians = MathUtils.PI / 180;
MathUtils.degRad = MathUtils.degreesToRadians; MathUtils.degRad = MathUtils.degreesToRadians;
spine.MathUtils = MathUtils; spine.MathUtils = MathUtils;
var Interpolation = (function () {
function Interpolation() {
}
Interpolation.prototype.apply = function (start, end, a) {
return start + (end - start) * this.applyInternal(a);
};
return Interpolation;
}());
spine.Interpolation = Interpolation;
var Pow = (function (_super) {
__extends(Pow, _super);
function Pow(power) {
var _this = _super.call(this) || this;
_this.power = 2;
_this.power = power;
return _this;
}
Pow.prototype.applyInternal = function (a) {
if (a <= 0.5)
return Math.pow(a * 2, this.power) / 2;
return Math.pow((a - 1) * 2, this.power) / (this.power % 2 == 0 ? -2 : 2) + 1;
};
return Pow;
}(Interpolation));
spine.Pow = Pow;
var PowOut = (function (_super) {
__extends(PowOut, _super);
function PowOut(power) {
return _super.call(this, power) || this;
}
PowOut.prototype.applyInternal = function (a) {
return Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1;
};
return PowOut;
}(Pow));
spine.PowOut = PowOut;
var Utils = (function () { var Utils = (function () {
function Utils() { function Utils() {
} }
@ -6317,6 +6363,63 @@ var spine;
spine.RegionAttachment = RegionAttachment; spine.RegionAttachment = RegionAttachment;
})(spine || (spine = {})); })(spine || (spine = {}));
var spine; var spine;
(function (spine) {
var JitterEffect = (function () {
function JitterEffect(jitterX, jitterY) {
this.jitterX = 0;
this.jitterY = 0;
this.jitterX = jitterX;
this.jitterY = jitterY;
}
JitterEffect.prototype.begin = function (skeleton) {
};
JitterEffect.prototype.transform = function (position, uv, light, dark) {
position.x += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY);
position.y += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY);
};
JitterEffect.prototype.end = function () {
};
return JitterEffect;
}());
spine.JitterEffect = JitterEffect;
})(spine || (spine = {}));
var spine;
(function (spine) {
var SwirlEffect = (function () {
function SwirlEffect(radius) {
this.centerX = 0;
this.centerY = 0;
this.radius = 0;
this.angle = 0;
this.worldX = 0;
this.worldY = 0;
this.radius = radius;
}
SwirlEffect.prototype.begin = function (skeleton) {
this.worldX = skeleton.x + this.centerX;
this.worldY = skeleton.y + this.centerY;
};
SwirlEffect.prototype.transform = function (position, uv, light, dark) {
var radAngle = this.angle * spine.MathUtils.degreesToRadians;
var x = position.x - this.worldX;
var y = position.y - this.worldY;
var dist = Math.sqrt(x * x + y * y);
if (dist < this.radius) {
var theta = SwirlEffect.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius);
var cos = Math.cos(theta);
var sin = Math.sin(theta);
position.x = cos * x - sin * y + this.worldX;
position.y = sin * x + cos * y + this.worldY;
}
};
SwirlEffect.prototype.end = function () {
};
return SwirlEffect;
}());
SwirlEffect.interpolation = new spine.PowOut(2);
spine.SwirlEffect = SwirlEffect;
})(spine || (spine = {}));
var spine;
(function (spine) { (function (spine) {
var canvas; var canvas;
(function (canvas) { (function (canvas) {

File diff suppressed because one or more lines are too long

View File

@ -962,6 +962,21 @@ declare module spine {
static signum(value: number): number; static signum(value: number): number;
static toInt(x: number): number; static toInt(x: number): number;
static cbrt(x: number): number; static cbrt(x: number): number;
static randomTriangular(min: number, max: number): number;
static randomTriangularWith(min: number, max: number, mode: number): number;
}
abstract class Interpolation {
protected abstract applyInternal(a: number): number;
apply(start: number, end: number, a: number): number;
}
class Pow extends Interpolation {
protected power: number;
constructor(power: number);
applyInternal(a: number): number;
}
class PowOut extends Pow {
constructor(power: number);
applyInternal(a: number): number;
} }
class Utils { class Utils {
static SUPPORTS_TYPED_ARRAYS: boolean; static SUPPORTS_TYPED_ARRAYS: boolean;
@ -1019,6 +1034,13 @@ declare module spine {
getMean(): number; getMean(): number;
} }
} }
declare module spine {
interface VertexEffect {
begin(skeleton: Skeleton): void;
transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void;
end(): void;
}
}
declare module spine { declare module spine {
abstract class Attachment { abstract class Attachment {
name: string; name: string;
@ -1169,3 +1191,28 @@ declare module spine {
computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void; computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
} }
} }
declare module spine {
class JitterEffect implements VertexEffect {
jitterX: number;
jitterY: number;
constructor(jitterX: number, jitterY: number);
begin(skeleton: Skeleton): void;
transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void;
end(): void;
}
}
declare module spine {
class SwirlEffect implements VertexEffect {
static interpolation: PowOut;
centerX: number;
centerY: number;
radius: number;
angle: number;
private worldX;
private worldY;
constructor(radius: number);
begin(skeleton: Skeleton): void;
transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void;
end(): void;
}
}

View File

@ -5747,6 +5747,16 @@ var spine;
var y = Math.pow(Math.abs(x), 1 / 3); var y = Math.pow(Math.abs(x), 1 / 3);
return x < 0 ? -y : y; return x < 0 ? -y : y;
}; };
MathUtils.randomTriangular = function (min, max) {
return MathUtils.randomTriangularWith(min, max, (min + max) * 0.5);
};
MathUtils.randomTriangularWith = function (min, max, mode) {
var u = Math.random();
var d = max - min;
if (u <= (mode - min) / d)
return min + Math.sqrt(u * d * (mode - min));
return max - Math.sqrt((1 - u) * d * (max - mode));
};
return MathUtils; return MathUtils;
}()); }());
MathUtils.PI = 3.1415927; MathUtils.PI = 3.1415927;
@ -5756,6 +5766,42 @@ var spine;
MathUtils.degreesToRadians = MathUtils.PI / 180; MathUtils.degreesToRadians = MathUtils.PI / 180;
MathUtils.degRad = MathUtils.degreesToRadians; MathUtils.degRad = MathUtils.degreesToRadians;
spine.MathUtils = MathUtils; spine.MathUtils = MathUtils;
var Interpolation = (function () {
function Interpolation() {
}
Interpolation.prototype.apply = function (start, end, a) {
return start + (end - start) * this.applyInternal(a);
};
return Interpolation;
}());
spine.Interpolation = Interpolation;
var Pow = (function (_super) {
__extends(Pow, _super);
function Pow(power) {
var _this = _super.call(this) || this;
_this.power = 2;
_this.power = power;
return _this;
}
Pow.prototype.applyInternal = function (a) {
if (a <= 0.5)
return Math.pow(a * 2, this.power) / 2;
return Math.pow((a - 1) * 2, this.power) / (this.power % 2 == 0 ? -2 : 2) + 1;
};
return Pow;
}(Interpolation));
spine.Pow = Pow;
var PowOut = (function (_super) {
__extends(PowOut, _super);
function PowOut(power) {
return _super.call(this, power) || this;
}
PowOut.prototype.applyInternal = function (a) {
return Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1;
};
return PowOut;
}(Pow));
spine.PowOut = PowOut;
var Utils = (function () { var Utils = (function () {
function Utils() { function Utils() {
} }
@ -6316,4 +6362,61 @@ var spine;
RegionAttachment.V4 = 31; RegionAttachment.V4 = 31;
spine.RegionAttachment = RegionAttachment; spine.RegionAttachment = RegionAttachment;
})(spine || (spine = {})); })(spine || (spine = {}));
var spine;
(function (spine) {
var JitterEffect = (function () {
function JitterEffect(jitterX, jitterY) {
this.jitterX = 0;
this.jitterY = 0;
this.jitterX = jitterX;
this.jitterY = jitterY;
}
JitterEffect.prototype.begin = function (skeleton) {
};
JitterEffect.prototype.transform = function (position, uv, light, dark) {
position.x += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY);
position.y += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY);
};
JitterEffect.prototype.end = function () {
};
return JitterEffect;
}());
spine.JitterEffect = JitterEffect;
})(spine || (spine = {}));
var spine;
(function (spine) {
var SwirlEffect = (function () {
function SwirlEffect(radius) {
this.centerX = 0;
this.centerY = 0;
this.radius = 0;
this.angle = 0;
this.worldX = 0;
this.worldY = 0;
this.radius = radius;
}
SwirlEffect.prototype.begin = function (skeleton) {
this.worldX = skeleton.x + this.centerX;
this.worldY = skeleton.y + this.centerY;
};
SwirlEffect.prototype.transform = function (position, uv, light, dark) {
var radAngle = this.angle * spine.MathUtils.degreesToRadians;
var x = position.x - this.worldX;
var y = position.y - this.worldY;
var dist = Math.sqrt(x * x + y * y);
if (dist < this.radius) {
var theta = SwirlEffect.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius);
var cos = Math.cos(theta);
var sin = Math.sin(theta);
position.x = cos * x - sin * y + this.worldX;
position.y = sin * x + cos * y + this.worldY;
}
};
SwirlEffect.prototype.end = function () {
};
return SwirlEffect;
}());
SwirlEffect.interpolation = new spine.PowOut(2);
spine.SwirlEffect = SwirlEffect;
})(spine || (spine = {}));
//# sourceMappingURL=spine-core.js.map //# sourceMappingURL=spine-core.js.map

File diff suppressed because one or more lines are too long

View File

@ -962,6 +962,21 @@ declare module spine {
static signum(value: number): number; static signum(value: number): number;
static toInt(x: number): number; static toInt(x: number): number;
static cbrt(x: number): number; static cbrt(x: number): number;
static randomTriangular(min: number, max: number): number;
static randomTriangularWith(min: number, max: number, mode: number): number;
}
abstract class Interpolation {
protected abstract applyInternal(a: number): number;
apply(start: number, end: number, a: number): number;
}
class Pow extends Interpolation {
protected power: number;
constructor(power: number);
applyInternal(a: number): number;
}
class PowOut extends Pow {
constructor(power: number);
applyInternal(a: number): number;
} }
class Utils { class Utils {
static SUPPORTS_TYPED_ARRAYS: boolean; static SUPPORTS_TYPED_ARRAYS: boolean;
@ -1019,6 +1034,13 @@ declare module spine {
getMean(): number; getMean(): number;
} }
} }
declare module spine {
interface VertexEffect {
begin(skeleton: Skeleton): void;
transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void;
end(): void;
}
}
declare module spine { declare module spine {
abstract class Attachment { abstract class Attachment {
name: string; name: string;
@ -1169,6 +1191,31 @@ declare module spine {
computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void; computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
} }
} }
declare module spine {
class JitterEffect implements VertexEffect {
jitterX: number;
jitterY: number;
constructor(jitterX: number, jitterY: number);
begin(skeleton: Skeleton): void;
transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void;
end(): void;
}
}
declare module spine {
class SwirlEffect implements VertexEffect {
static interpolation: PowOut;
centerX: number;
centerY: number;
radius: number;
angle: number;
private worldX;
private worldY;
constructor(radius: number);
begin(skeleton: Skeleton): void;
transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void;
end(): void;
}
}
declare module spine.threejs { declare module spine.threejs {
class AssetManager extends spine.AssetManager { class AssetManager extends spine.AssetManager {
constructor(pathPrefix?: string); constructor(pathPrefix?: string);

View File

@ -5747,6 +5747,16 @@ var spine;
var y = Math.pow(Math.abs(x), 1 / 3); var y = Math.pow(Math.abs(x), 1 / 3);
return x < 0 ? -y : y; return x < 0 ? -y : y;
}; };
MathUtils.randomTriangular = function (min, max) {
return MathUtils.randomTriangularWith(min, max, (min + max) * 0.5);
};
MathUtils.randomTriangularWith = function (min, max, mode) {
var u = Math.random();
var d = max - min;
if (u <= (mode - min) / d)
return min + Math.sqrt(u * d * (mode - min));
return max - Math.sqrt((1 - u) * d * (max - mode));
};
return MathUtils; return MathUtils;
}()); }());
MathUtils.PI = 3.1415927; MathUtils.PI = 3.1415927;
@ -5756,6 +5766,42 @@ var spine;
MathUtils.degreesToRadians = MathUtils.PI / 180; MathUtils.degreesToRadians = MathUtils.PI / 180;
MathUtils.degRad = MathUtils.degreesToRadians; MathUtils.degRad = MathUtils.degreesToRadians;
spine.MathUtils = MathUtils; spine.MathUtils = MathUtils;
var Interpolation = (function () {
function Interpolation() {
}
Interpolation.prototype.apply = function (start, end, a) {
return start + (end - start) * this.applyInternal(a);
};
return Interpolation;
}());
spine.Interpolation = Interpolation;
var Pow = (function (_super) {
__extends(Pow, _super);
function Pow(power) {
var _this = _super.call(this) || this;
_this.power = 2;
_this.power = power;
return _this;
}
Pow.prototype.applyInternal = function (a) {
if (a <= 0.5)
return Math.pow(a * 2, this.power) / 2;
return Math.pow((a - 1) * 2, this.power) / (this.power % 2 == 0 ? -2 : 2) + 1;
};
return Pow;
}(Interpolation));
spine.Pow = Pow;
var PowOut = (function (_super) {
__extends(PowOut, _super);
function PowOut(power) {
return _super.call(this, power) || this;
}
PowOut.prototype.applyInternal = function (a) {
return Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1;
};
return PowOut;
}(Pow));
spine.PowOut = PowOut;
var Utils = (function () { var Utils = (function () {
function Utils() { function Utils() {
} }
@ -6317,6 +6363,63 @@ var spine;
spine.RegionAttachment = RegionAttachment; spine.RegionAttachment = RegionAttachment;
})(spine || (spine = {})); })(spine || (spine = {}));
var spine; var spine;
(function (spine) {
var JitterEffect = (function () {
function JitterEffect(jitterX, jitterY) {
this.jitterX = 0;
this.jitterY = 0;
this.jitterX = jitterX;
this.jitterY = jitterY;
}
JitterEffect.prototype.begin = function (skeleton) {
};
JitterEffect.prototype.transform = function (position, uv, light, dark) {
position.x += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY);
position.y += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY);
};
JitterEffect.prototype.end = function () {
};
return JitterEffect;
}());
spine.JitterEffect = JitterEffect;
})(spine || (spine = {}));
var spine;
(function (spine) {
var SwirlEffect = (function () {
function SwirlEffect(radius) {
this.centerX = 0;
this.centerY = 0;
this.radius = 0;
this.angle = 0;
this.worldX = 0;
this.worldY = 0;
this.radius = radius;
}
SwirlEffect.prototype.begin = function (skeleton) {
this.worldX = skeleton.x + this.centerX;
this.worldY = skeleton.y + this.centerY;
};
SwirlEffect.prototype.transform = function (position, uv, light, dark) {
var radAngle = this.angle * spine.MathUtils.degreesToRadians;
var x = position.x - this.worldX;
var y = position.y - this.worldY;
var dist = Math.sqrt(x * x + y * y);
if (dist < this.radius) {
var theta = SwirlEffect.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius);
var cos = Math.cos(theta);
var sin = Math.sin(theta);
position.x = cos * x - sin * y + this.worldX;
position.y = sin * x + cos * y + this.worldY;
}
};
SwirlEffect.prototype.end = function () {
};
return SwirlEffect;
}());
SwirlEffect.interpolation = new spine.PowOut(2);
spine.SwirlEffect = SwirlEffect;
})(spine || (spine = {}));
var spine;
(function (spine) { (function (spine) {
var threejs; var threejs;
(function (threejs) { (function (threejs) {

File diff suppressed because one or more lines are too long

View File

@ -965,6 +965,19 @@ declare module spine {
static randomTriangular(min: number, max: number): number; static randomTriangular(min: number, max: number): number;
static randomTriangularWith(min: number, max: number, mode: number): number; static randomTriangularWith(min: number, max: number, mode: number): number;
} }
abstract class Interpolation {
protected abstract applyInternal(a: number): number;
apply(start: number, end: number, a: number): number;
}
class Pow extends Interpolation {
protected power: number;
constructor(power: number);
applyInternal(a: number): number;
}
class PowOut extends Pow {
constructor(power: number);
applyInternal(a: number): number;
}
class Utils { class Utils {
static SUPPORTS_TYPED_ARRAYS: boolean; static SUPPORTS_TYPED_ARRAYS: boolean;
static arrayCopy<T>(source: ArrayLike<T>, sourceStart: number, dest: ArrayLike<T>, destStart: number, numElements: number): void; static arrayCopy<T>(source: ArrayLike<T>, sourceStart: number, dest: ArrayLike<T>, destStart: number, numElements: number): void;
@ -1190,6 +1203,7 @@ declare module spine {
} }
declare module spine { declare module spine {
class SwirlEffect implements VertexEffect { class SwirlEffect implements VertexEffect {
static interpolation: PowOut;
centerX: number; centerX: number;
centerY: number; centerY: number;
radius: number; radius: number;

View File

@ -5766,6 +5766,42 @@ var spine;
MathUtils.degreesToRadians = MathUtils.PI / 180; MathUtils.degreesToRadians = MathUtils.PI / 180;
MathUtils.degRad = MathUtils.degreesToRadians; MathUtils.degRad = MathUtils.degreesToRadians;
spine.MathUtils = MathUtils; spine.MathUtils = MathUtils;
var Interpolation = (function () {
function Interpolation() {
}
Interpolation.prototype.apply = function (start, end, a) {
return start + (end - start) * this.applyInternal(a);
};
return Interpolation;
}());
spine.Interpolation = Interpolation;
var Pow = (function (_super) {
__extends(Pow, _super);
function Pow(power) {
var _this = _super.call(this) || this;
_this.power = 2;
_this.power = power;
return _this;
}
Pow.prototype.applyInternal = function (a) {
if (a <= 0.5)
return Math.pow(a * 2, this.power) / 2;
return Math.pow((a - 1) * 2, this.power) / (this.power % 2 == 0 ? -2 : 2) + 1;
};
return Pow;
}(Interpolation));
spine.Pow = Pow;
var PowOut = (function (_super) {
__extends(PowOut, _super);
function PowOut(power) {
return _super.call(this, power) || this;
}
PowOut.prototype.applyInternal = function (a) {
return Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1;
};
return PowOut;
}(Pow));
spine.PowOut = PowOut;
var Utils = (function () { var Utils = (function () {
function Utils() { function Utils() {
} }
@ -6369,7 +6405,7 @@ var spine;
var y = position.y - this.worldY; var y = position.y - this.worldY;
var dist = Math.sqrt(x * x + y * y); var dist = Math.sqrt(x * x + y * y);
if (dist < this.radius) { if (dist < this.radius) {
var theta = radAngle * (Math.pow(((this.radius - dist) / this.radius) - 1, 2) * (2 % 2 == 0 ? -1 : 1) + 1); var theta = SwirlEffect.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius);
var cos = Math.cos(theta); var cos = Math.cos(theta);
var sin = Math.sin(theta); var sin = Math.sin(theta);
position.x = cos * x - sin * y + this.worldX; position.x = cos * x - sin * y + this.worldX;
@ -6380,6 +6416,7 @@ var spine;
}; };
return SwirlEffect; return SwirlEffect;
}()); }());
SwirlEffect.interpolation = new spine.PowOut(2);
spine.SwirlEffect = SwirlEffect; spine.SwirlEffect = SwirlEffect;
})(spine || (spine = {})); })(spine || (spine = {}));
var spine; var spine;

File diff suppressed because one or more lines are too long

View File

@ -962,6 +962,21 @@ declare module spine {
static signum(value: number): number; static signum(value: number): number;
static toInt(x: number): number; static toInt(x: number): number;
static cbrt(x: number): number; static cbrt(x: number): number;
static randomTriangular(min: number, max: number): number;
static randomTriangularWith(min: number, max: number, mode: number): number;
}
abstract class Interpolation {
protected abstract applyInternal(a: number): number;
apply(start: number, end: number, a: number): number;
}
class Pow extends Interpolation {
protected power: number;
constructor(power: number);
applyInternal(a: number): number;
}
class PowOut extends Pow {
constructor(power: number);
applyInternal(a: number): number;
} }
class Utils { class Utils {
static SUPPORTS_TYPED_ARRAYS: boolean; static SUPPORTS_TYPED_ARRAYS: boolean;
@ -1019,6 +1034,13 @@ declare module spine {
getMean(): number; getMean(): number;
} }
} }
declare module spine {
interface VertexEffect {
begin(skeleton: Skeleton): void;
transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void;
end(): void;
}
}
declare module spine { declare module spine {
abstract class Attachment { abstract class Attachment {
name: string; name: string;
@ -1169,6 +1191,31 @@ declare module spine {
computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void; computeWorldVertices(bone: Bone, worldVertices: ArrayLike<number>, offset: number, stride: number): void;
} }
} }
declare module spine {
class JitterEffect implements VertexEffect {
jitterX: number;
jitterY: number;
constructor(jitterX: number, jitterY: number);
begin(skeleton: Skeleton): void;
transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void;
end(): void;
}
}
declare module spine {
class SwirlEffect implements VertexEffect {
static interpolation: PowOut;
centerX: number;
centerY: number;
radius: number;
angle: number;
private worldX;
private worldY;
constructor(radius: number);
begin(skeleton: Skeleton): void;
transform(position: Vector2, uv: Vector2, light: Color, dark: Color): void;
end(): void;
}
}
declare module spine.webgl { declare module spine.webgl {
class AssetManager extends spine.AssetManager { class AssetManager extends spine.AssetManager {
constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, pathPrefix?: string); constructor(context: ManagedWebGLRenderingContext | WebGLRenderingContext, pathPrefix?: string);
@ -1540,6 +1587,7 @@ declare module spine.webgl {
class SkeletonRenderer { class SkeletonRenderer {
static QUAD_TRIANGLES: number[]; static QUAD_TRIANGLES: number[];
premultipliedAlpha: boolean; premultipliedAlpha: boolean;
vertexEffect: VertexEffect;
private tempColor; private tempColor;
private tempColor2; private tempColor2;
private vertices; private vertices;
@ -1547,6 +1595,10 @@ declare module spine.webgl {
private twoColorTint; private twoColorTint;
private renderable; private renderable;
private clipper; private clipper;
private temp;
private temp2;
private temp3;
private temp4;
constructor(context: ManagedWebGLRenderingContext, twoColorTint?: boolean); constructor(context: ManagedWebGLRenderingContext, twoColorTint?: boolean);
draw(batcher: PolygonBatcher, skeleton: Skeleton): void; draw(batcher: PolygonBatcher, skeleton: Skeleton): void;
} }

View File

@ -5747,6 +5747,16 @@ var spine;
var y = Math.pow(Math.abs(x), 1 / 3); var y = Math.pow(Math.abs(x), 1 / 3);
return x < 0 ? -y : y; return x < 0 ? -y : y;
}; };
MathUtils.randomTriangular = function (min, max) {
return MathUtils.randomTriangularWith(min, max, (min + max) * 0.5);
};
MathUtils.randomTriangularWith = function (min, max, mode) {
var u = Math.random();
var d = max - min;
if (u <= (mode - min) / d)
return min + Math.sqrt(u * d * (mode - min));
return max - Math.sqrt((1 - u) * d * (max - mode));
};
return MathUtils; return MathUtils;
}()); }());
MathUtils.PI = 3.1415927; MathUtils.PI = 3.1415927;
@ -5756,6 +5766,42 @@ var spine;
MathUtils.degreesToRadians = MathUtils.PI / 180; MathUtils.degreesToRadians = MathUtils.PI / 180;
MathUtils.degRad = MathUtils.degreesToRadians; MathUtils.degRad = MathUtils.degreesToRadians;
spine.MathUtils = MathUtils; spine.MathUtils = MathUtils;
var Interpolation = (function () {
function Interpolation() {
}
Interpolation.prototype.apply = function (start, end, a) {
return start + (end - start) * this.applyInternal(a);
};
return Interpolation;
}());
spine.Interpolation = Interpolation;
var Pow = (function (_super) {
__extends(Pow, _super);
function Pow(power) {
var _this = _super.call(this) || this;
_this.power = 2;
_this.power = power;
return _this;
}
Pow.prototype.applyInternal = function (a) {
if (a <= 0.5)
return Math.pow(a * 2, this.power) / 2;
return Math.pow((a - 1) * 2, this.power) / (this.power % 2 == 0 ? -2 : 2) + 1;
};
return Pow;
}(Interpolation));
spine.Pow = Pow;
var PowOut = (function (_super) {
__extends(PowOut, _super);
function PowOut(power) {
return _super.call(this, power) || this;
}
PowOut.prototype.applyInternal = function (a) {
return Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1;
};
return PowOut;
}(Pow));
spine.PowOut = PowOut;
var Utils = (function () { var Utils = (function () {
function Utils() { function Utils() {
} }
@ -6317,6 +6363,63 @@ var spine;
spine.RegionAttachment = RegionAttachment; spine.RegionAttachment = RegionAttachment;
})(spine || (spine = {})); })(spine || (spine = {}));
var spine; var spine;
(function (spine) {
var JitterEffect = (function () {
function JitterEffect(jitterX, jitterY) {
this.jitterX = 0;
this.jitterY = 0;
this.jitterX = jitterX;
this.jitterY = jitterY;
}
JitterEffect.prototype.begin = function (skeleton) {
};
JitterEffect.prototype.transform = function (position, uv, light, dark) {
position.x += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY);
position.y += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY);
};
JitterEffect.prototype.end = function () {
};
return JitterEffect;
}());
spine.JitterEffect = JitterEffect;
})(spine || (spine = {}));
var spine;
(function (spine) {
var SwirlEffect = (function () {
function SwirlEffect(radius) {
this.centerX = 0;
this.centerY = 0;
this.radius = 0;
this.angle = 0;
this.worldX = 0;
this.worldY = 0;
this.radius = radius;
}
SwirlEffect.prototype.begin = function (skeleton) {
this.worldX = skeleton.x + this.centerX;
this.worldY = skeleton.y + this.centerY;
};
SwirlEffect.prototype.transform = function (position, uv, light, dark) {
var radAngle = this.angle * spine.MathUtils.degreesToRadians;
var x = position.x - this.worldX;
var y = position.y - this.worldY;
var dist = Math.sqrt(x * x + y * y);
if (dist < this.radius) {
var theta = SwirlEffect.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius);
var cos = Math.cos(theta);
var sin = Math.sin(theta);
position.x = cos * x - sin * y + this.worldX;
position.y = sin * x + cos * y + this.worldY;
}
};
SwirlEffect.prototype.end = function () {
};
return SwirlEffect;
}());
SwirlEffect.interpolation = new spine.PowOut(2);
spine.SwirlEffect = SwirlEffect;
})(spine || (spine = {}));
var spine;
(function (spine) { (function (spine) {
var webgl; var webgl;
(function (webgl) { (function (webgl) {
@ -8420,12 +8523,17 @@ var spine;
function SkeletonRenderer(context, twoColorTint) { function SkeletonRenderer(context, twoColorTint) {
if (twoColorTint === void 0) { twoColorTint = true; } if (twoColorTint === void 0) { twoColorTint = true; }
this.premultipliedAlpha = false; this.premultipliedAlpha = false;
this.vertexEffect = null;
this.tempColor = new spine.Color(); this.tempColor = new spine.Color();
this.tempColor2 = new spine.Color(); this.tempColor2 = new spine.Color();
this.vertexSize = 2 + 2 + 4; this.vertexSize = 2 + 2 + 4;
this.twoColorTint = false; this.twoColorTint = false;
this.renderable = new Renderable(null, 0, 0); this.renderable = new Renderable(null, 0, 0);
this.clipper = new spine.SkeletonClipping(); this.clipper = new spine.SkeletonClipping();
this.temp = new spine.Vector2();
this.temp2 = new spine.Vector2();
this.temp3 = new spine.Color();
this.temp4 = new spine.Color();
this.twoColorTint = twoColorTint; this.twoColorTint = twoColorTint;
if (twoColorTint) if (twoColorTint)
this.vertexSize += 4; this.vertexSize += 4;
@ -8436,6 +8544,10 @@ var spine;
var premultipliedAlpha = this.premultipliedAlpha; var premultipliedAlpha = this.premultipliedAlpha;
var twoColorTint = this.twoColorTint; var twoColorTint = this.twoColorTint;
var blendMode = null; var blendMode = null;
var tempPos = this.temp;
var tempUv = this.temp2;
var tempLight = this.temp3;
var tempDark = this.temp4;
var renderable = this.renderable; var renderable = this.renderable;
var uvs = null; var uvs = null;
var triangles = null; var triangles = null;
@ -8510,8 +8622,54 @@ var spine;
} }
else { else {
var verts = renderable.vertices; var verts = renderable.vertices;
if (this.vertexEffect != null) {
var vertexEffect = this.vertexEffect;
if (!twoColorTint) { if (!twoColorTint) {
for (var v = 2, u = 0, n_3 = renderable.numFloats; v < n_3; v += vertexSize, u += 2) { for (var v = 0, u = 0, n_3 = renderable.numFloats; v < n_3; v += vertexSize, u += 2) {
tempPos.x = verts[v];
tempPos.y = verts[v + 1];
tempUv.x = uvs[u];
tempUv.y = uvs[u + 1];
tempLight.setFromColor(finalColor);
tempDark.set(0, 0, 0, 0);
vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
verts[v] = tempPos.x;
verts[v + 1] = tempPos.y;
verts[v + 2] = tempLight.r;
verts[v + 3] = tempLight.g;
verts[v + 4] = tempLight.b;
verts[v + 5] = tempLight.a;
verts[v + 6] = tempUv.x;
verts[v + 7] = tempUv.y;
}
}
else {
for (var v = 0, u = 0, n_4 = renderable.numFloats; v < n_4; v += vertexSize, u += 2) {
tempPos.x = verts[v];
tempPos.y = verts[v + 1];
tempUv.x = uvs[u];
tempUv.y = uvs[u + 1];
tempLight.setFromColor(finalColor);
tempDark.setFromColor(darkColor);
vertexEffect.transform(tempPos, tempUv, tempLight, tempDark);
verts[v] = tempPos.x;
verts[v + 1] = tempPos.y;
verts[v + 2] = tempLight.r;
verts[v + 3] = tempLight.g;
verts[v + 4] = tempLight.b;
verts[v + 5] = tempLight.a;
verts[v + 6] = tempUv.x;
verts[v + 7] = tempUv.y;
verts[v + 8] = tempDark.r;
verts[v + 9] = tempDark.g;
verts[v + 10] = tempDark.b;
verts[v + 11] = tempDark.a;
}
}
}
else {
if (!twoColorTint) {
for (var v = 2, u = 0, n_5 = renderable.numFloats; v < n_5; v += vertexSize, u += 2) {
verts[v] = finalColor.r; verts[v] = finalColor.r;
verts[v + 1] = finalColor.g; verts[v + 1] = finalColor.g;
verts[v + 2] = finalColor.b; verts[v + 2] = finalColor.b;
@ -8521,7 +8679,7 @@ var spine;
} }
} }
else { else {
for (var v = 2, u = 0, n_4 = renderable.numFloats; v < n_4; v += vertexSize, u += 2) { for (var v = 2, u = 0, n_6 = renderable.numFloats; v < n_6; v += vertexSize, u += 2) {
verts[v] = finalColor.r; verts[v] = finalColor.r;
verts[v + 1] = finalColor.g; verts[v + 1] = finalColor.g;
verts[v + 2] = finalColor.b; verts[v + 2] = finalColor.b;
@ -8534,6 +8692,7 @@ var spine;
verts[v + 9] = darkColor.a; verts[v + 9] = darkColor.a;
} }
} }
}
var view = renderable.vertices.subarray(0, renderable.numFloats); var view = renderable.vertices.subarray(0, renderable.numFloats);
batcher.draw(texture, view, triangles); batcher.draw(texture, view, triangles);
} }

File diff suppressed because one or more lines are too long

View File

@ -171,6 +171,37 @@ module spine {
} }
} }
export abstract class Interpolation {
protected abstract applyInternal (a: number): number;
apply(start: number, end: number, a: number): number {
return start + (end - start) * this.applyInternal(a);
}
}
export class Pow extends Interpolation {
protected power = 2;
constructor (power: number) {
super();
this.power = power;
}
applyInternal (a: number): number {
if (a <= 0.5) return Math.pow(a * 2, this.power) / 2;
return Math.pow((a - 1) * 2, this.power) / (this.power % 2 == 0 ? -2 : 2) + 1;
}
}
export class PowOut extends Pow {
constructor (power: number) {
super(power);
}
applyInternal (a: number) : number {
return Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1;
}
}
export class Utils { export class Utils {
static SUPPORTS_TYPED_ARRAYS = typeof(Float32Array) !== "undefined"; static SUPPORTS_TYPED_ARRAYS = typeof(Float32Array) !== "undefined";

View File

@ -30,7 +30,7 @@
module spine { module spine {
export class SwirlEffect implements VertexEffect { export class SwirlEffect implements VertexEffect {
static interpolation = new PowOut(2);
centerX = 0; centerX = 0;
centerY = 0; centerY = 0;
radius = 0; radius = 0;
@ -53,7 +53,7 @@ module spine {
let y = position.y - this.worldY; let y = position.y - this.worldY;
let dist = Math.sqrt(x * x + y * y); let dist = Math.sqrt(x * x + y * y);
if (dist < this.radius) { if (dist < this.radius) {
let theta = radAngle * (Math.pow(((this.radius - dist) / this.radius) - 1, 2) * (2 % 2 == 0 ? -1 : 1) + 1); let theta = SwirlEffect.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius);
let cos = Math.cos(theta); let cos = Math.cos(theta);
let sin = Math.sin(theta); let sin = Math.sin(theta);
position.x = cos * x - sin * y + this.worldX; position.x = cos * x - sin * y + this.worldX;

View File

@ -12,7 +12,7 @@
</body> </body>
<script> <script>
var FILE = "raptor"; var FILE = "raptor-pro";
var ANIMATION = "walk"; var ANIMATION = "walk";
var NUM_SKELETONS = 1; var NUM_SKELETONS = 1;
var SCALE = 0.5; var SCALE = 0.5;
@ -23,6 +23,9 @@ var timeKeeper;
var label = document.getElementById("label"); var label = document.getElementById("label");
var updateMean = new spine.WindowedMean(); var updateMean = new spine.WindowedMean();
var renderMean = new spine.WindowedMean(); var renderMean = new spine.WindowedMean();
var swirlEffect = new spine.SwirlEffect();
var swirlTime = 0;
var interpolation = new spine.Pow(2);
function init() { function init() {
canvas = document.getElementById("canvas"); canvas = document.getElementById("canvas");
@ -36,13 +39,18 @@ function init() {
renderer.skeletonDebugRenderer.drawMeshHull = false; renderer.skeletonDebugRenderer.drawMeshHull = false;
renderer.skeletonDebugRenderer.drawRegionAttachments = false; renderer.skeletonDebugRenderer.drawRegionAttachments = false;
renderer.skeletonDebugRenderer.drawBoundingBoxes = false; renderer.skeletonDebugRenderer.drawBoundingBoxes = false;
renderer.skeletonRenderer.vertexEffect = swirlEffect;
swirlEffect.centerX = 0;
swirlEffect.centerY = 200;
swirlEffect.radius = 500;
assetManager = new spine.webgl.AssetManager(context, "assets/"); assetManager = new spine.webgl.AssetManager(context, "assets/");
var textureLoader = function(img) { return new spine.webgl.GLTexture(gl, img); }; var textureLoader = function(img) { return new spine.webgl.GLTexture(gl, img); };
input = new spine.webgl.Input(canvas); input = new spine.webgl.Input(canvas);
assetManager.loadTexture(FILE + ".png"); assetManager.loadTexture(FILE.replace("-pro", "").replace("-oss", "") + ".png");
assetManager.loadText(FILE + ".atlas"); assetManager.loadText(FILE.replace("-pro", "").replace("-oss", "") + ".atlas");
assetManager.loadText(FILE + ".json"); assetManager.loadText(FILE + ".json");
timeKeeper = new spine.TimeKeeper(); timeKeeper = new spine.TimeKeeper();
@ -52,7 +60,7 @@ function init() {
function load() { function load() {
timeKeeper.update(); timeKeeper.update();
if (assetManager.isLoadingComplete()) { if (assetManager.isLoadingComplete()) {
var atlas = new spine.TextureAtlas(assetManager.get(FILE + ".atlas"), function(path) { var atlas = new spine.TextureAtlas(assetManager.get(FILE.replace("-pro", "").replace("-oss", "") + ".atlas"), function(path) {
return assetManager.get(path); return assetManager.get(path);
}); });
var atlasLoader = new spine.AtlasAttachmentLoader(atlas); var atlasLoader = new spine.AtlasAttachmentLoader(atlas);
@ -89,6 +97,11 @@ function render() {
var delta = timeKeeper.delta; var delta = timeKeeper.delta;
delta = 0.016; delta = 0.016;
swirlTime += delta;
var percent = swirlTime % 2;
if (percent > 1) percent = 1 - (percent - 1);
swirlEffect.angle = interpolation.apply(-60, 60, percent);
for (var i = 0; i < skeletons.length; i++) { for (var i = 0; i < skeletons.length; i++) {
var state = skeletons[i].state; var state = skeletons[i].state;
var skeleton = skeletons[i].skeleton; var skeleton = skeletons[i].skeleton;