@esotericsoftware/spine-webgl 4.2.11 → 4.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/GLTexture.js +1 -3
- package/dist/PolygonBatcher.js +1 -1
- package/dist/Shader.js +77 -77
- package/dist/SkeletonRenderer.js +4 -4
- package/dist/iife/spine-webgl.js +95 -92
- package/dist/iife/spine-webgl.js.map +2 -2
- package/dist/iife/spine-webgl.min.js +78 -78
- package/package.json +2 -2
package/dist/iife/spine-webgl.js
CHANGED
|
@@ -4815,12 +4815,15 @@ var spine = (() => {
|
|
|
4815
4815
|
this.width = 0;
|
|
4816
4816
|
this.height = 0;
|
|
4817
4817
|
this.pma = false;
|
|
4818
|
+
this.regions = new Array();
|
|
4818
4819
|
this.name = name;
|
|
4819
4820
|
}
|
|
4820
4821
|
setTexture(texture) {
|
|
4821
4822
|
this.texture = texture;
|
|
4822
4823
|
texture.setFilters(this.minFilter, this.magFilter);
|
|
4823
4824
|
texture.setWraps(this.uWrap, this.vWrap);
|
|
4825
|
+
for (let region of this.regions)
|
|
4826
|
+
region.texture = texture;
|
|
4824
4827
|
}
|
|
4825
4828
|
};
|
|
4826
4829
|
var TextureAtlasRegion = class extends TextureRegion {
|
|
@@ -4838,6 +4841,7 @@ var spine = (() => {
|
|
|
4838
4841
|
this.values = null;
|
|
4839
4842
|
this.page = page;
|
|
4840
4843
|
this.name = name;
|
|
4844
|
+
page.regions.push(this);
|
|
4841
4845
|
}
|
|
4842
4846
|
};
|
|
4843
4847
|
|
|
@@ -4882,8 +4886,8 @@ var spine = (() => {
|
|
|
4882
4886
|
let n = this.uvs.length;
|
|
4883
4887
|
let u = this.region.u, v = this.region.v, width = 0, height = 0;
|
|
4884
4888
|
if (this.region instanceof TextureAtlasRegion) {
|
|
4885
|
-
let region = this.region,
|
|
4886
|
-
let textureWidth =
|
|
4889
|
+
let region = this.region, page = region.page;
|
|
4890
|
+
let textureWidth = page.width, textureHeight = page.height;
|
|
4887
4891
|
switch (region.degrees) {
|
|
4888
4892
|
case 90:
|
|
4889
4893
|
u -= (region.originalHeight - region.offsetY - region.height) / textureWidth;
|
|
@@ -5071,7 +5075,6 @@ var spine = (() => {
|
|
|
5071
5075
|
this.height = 0;
|
|
5072
5076
|
/** The color to tint the region attachment. */
|
|
5073
5077
|
this.color = new Color(1, 1, 1, 1);
|
|
5074
|
-
this.rendererObject = null;
|
|
5075
5078
|
this.region = null;
|
|
5076
5079
|
this.sequence = null;
|
|
5077
5080
|
/** For each of the 4 vertices, a pair of <code>x,y</code> values that is the local position of the vertex.
|
|
@@ -5185,7 +5188,6 @@ var spine = (() => {
|
|
|
5185
5188
|
copy() {
|
|
5186
5189
|
let copy = new _RegionAttachment(this.name, this.path);
|
|
5187
5190
|
copy.region = this.region;
|
|
5188
|
-
copy.rendererObject = this.rendererObject;
|
|
5189
5191
|
copy.x = this.x;
|
|
5190
5192
|
copy.y = this.y;
|
|
5191
5193
|
copy.scaleX = this.scaleX;
|
|
@@ -5247,7 +5249,6 @@ var spine = (() => {
|
|
|
5247
5249
|
if (region == null)
|
|
5248
5250
|
throw new Error("Region not found in atlas: " + path + " (sequence: " + name + ")");
|
|
5249
5251
|
regions[i] = region;
|
|
5250
|
-
regions[i].renderObject = regions[i];
|
|
5251
5252
|
}
|
|
5252
5253
|
}
|
|
5253
5254
|
newRegionAttachment(skin, name, path, sequence) {
|
|
@@ -5258,7 +5259,6 @@ var spine = (() => {
|
|
|
5258
5259
|
let region = this.atlas.findRegion(path);
|
|
5259
5260
|
if (!region)
|
|
5260
5261
|
throw new Error("Region not found in atlas: " + path + " (region attachment: " + name + ")");
|
|
5261
|
-
region.renderObject = region;
|
|
5262
5262
|
attachment.region = region;
|
|
5263
5263
|
}
|
|
5264
5264
|
return attachment;
|
|
@@ -5271,7 +5271,6 @@ var spine = (() => {
|
|
|
5271
5271
|
let region = this.atlas.findRegion(path);
|
|
5272
5272
|
if (!region)
|
|
5273
5273
|
throw new Error("Region not found in atlas: " + path + " (mesh attachment: " + name + ")");
|
|
5274
|
-
region.renderObject = region;
|
|
5275
5274
|
attachment.region = region;
|
|
5276
5275
|
}
|
|
5277
5276
|
return attachment;
|
|
@@ -6083,7 +6082,7 @@ var spine = (() => {
|
|
|
6083
6082
|
ty = targetY - bone.worldY;
|
|
6084
6083
|
break;
|
|
6085
6084
|
case 2 /* NoRotationOrReflection */:
|
|
6086
|
-
let s = Math.abs(pa * pd - pb * pc) / (pa * pa + pc * pc);
|
|
6085
|
+
let s = Math.abs(pa * pd - pb * pc) / Math.max(1e-4, pa * pa + pc * pc);
|
|
6087
6086
|
let sa = pa / bone.skeleton.scaleX;
|
|
6088
6087
|
let sc = pc / bone.skeleton.scaleY;
|
|
6089
6088
|
pb = -sc * s * bone.skeleton.scaleX;
|
|
@@ -6092,8 +6091,13 @@ var spine = (() => {
|
|
|
6092
6091
|
default:
|
|
6093
6092
|
let x = targetX - p.worldX, y = targetY - p.worldY;
|
|
6094
6093
|
let d = pa * pd - pb * pc;
|
|
6095
|
-
|
|
6096
|
-
|
|
6094
|
+
if (Math.abs(d) <= 1e-4) {
|
|
6095
|
+
tx = 0;
|
|
6096
|
+
ty = 0;
|
|
6097
|
+
} else {
|
|
6098
|
+
tx = (x * pd - y * pb) / d - bone.ax;
|
|
6099
|
+
ty = (y * pa - x * pc) / d - bone.ay;
|
|
6100
|
+
}
|
|
6097
6101
|
}
|
|
6098
6102
|
rotationIK += Math.atan2(ty, tx) * MathUtils.radDeg;
|
|
6099
6103
|
if (bone.ascaleX < 0)
|
|
@@ -6168,7 +6172,8 @@ var spine = (() => {
|
|
|
6168
6172
|
b = pp.b;
|
|
6169
6173
|
c = pp.c;
|
|
6170
6174
|
d = pp.d;
|
|
6171
|
-
let id =
|
|
6175
|
+
let id = a * d - b * c, x = cwx - pp.worldX, y = cwy - pp.worldY;
|
|
6176
|
+
id = Math.abs(id) <= 1e-4 ? 0 : 1 / id;
|
|
6172
6177
|
let dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py;
|
|
6173
6178
|
let l1 = Math.sqrt(dx * dx + dy * dy), l2 = child.data.length * csx, a1, a2;
|
|
6174
6179
|
if (l1 < 1e-4) {
|
|
@@ -10891,7 +10896,6 @@ var spine = (() => {
|
|
|
10891
10896
|
}
|
|
10892
10897
|
static validateMagFilter(magFilter) {
|
|
10893
10898
|
switch (magFilter) {
|
|
10894
|
-
case 9987 /* MipMap */:
|
|
10895
10899
|
case 9987 /* MipMapLinearLinear */:
|
|
10896
10900
|
case 9985 /* MipMapLinearNearest */:
|
|
10897
10901
|
case 9986 /* MipMapNearestLinear */:
|
|
@@ -10903,7 +10907,6 @@ var spine = (() => {
|
|
|
10903
10907
|
}
|
|
10904
10908
|
static usesMipMaps(filter) {
|
|
10905
10909
|
switch (filter) {
|
|
10906
|
-
case 9987 /* MipMap */:
|
|
10907
10910
|
case 9987 /* MipMapLinearLinear */:
|
|
10908
10911
|
case 9985 /* MipMapLinearNearest */:
|
|
10909
10912
|
case 9986 /* MipMapNearestLinear */:
|
|
@@ -11787,99 +11790,99 @@ var spine = (() => {
|
|
|
11787
11790
|
}
|
|
11788
11791
|
static newColoredTextured(context) {
|
|
11789
11792
|
let vs = `
|
|
11790
|
-
|
|
11791
|
-
|
|
11792
|
-
|
|
11793
|
-
|
|
11794
|
-
|
|
11795
|
-
|
|
11793
|
+
attribute vec4 ${_Shader.POSITION};
|
|
11794
|
+
attribute vec4 ${_Shader.COLOR};
|
|
11795
|
+
attribute vec2 ${_Shader.TEXCOORDS};
|
|
11796
|
+
uniform mat4 ${_Shader.MVP_MATRIX};
|
|
11797
|
+
varying vec4 v_color;
|
|
11798
|
+
varying vec2 v_texCoords;
|
|
11796
11799
|
|
|
11797
|
-
|
|
11798
|
-
|
|
11799
|
-
|
|
11800
|
-
|
|
11801
|
-
|
|
11802
|
-
|
|
11800
|
+
void main () {
|
|
11801
|
+
v_color = ${_Shader.COLOR};
|
|
11802
|
+
v_texCoords = ${_Shader.TEXCOORDS};
|
|
11803
|
+
gl_Position = ${_Shader.MVP_MATRIX} * ${_Shader.POSITION};
|
|
11804
|
+
}
|
|
11805
|
+
`;
|
|
11803
11806
|
let fs = `
|
|
11804
|
-
|
|
11805
|
-
|
|
11806
|
-
|
|
11807
|
-
|
|
11808
|
-
|
|
11809
|
-
|
|
11810
|
-
|
|
11811
|
-
|
|
11812
|
-
|
|
11807
|
+
#ifdef GL_ES
|
|
11808
|
+
#define LOWP lowp
|
|
11809
|
+
precision mediump float;
|
|
11810
|
+
#else
|
|
11811
|
+
#define LOWP
|
|
11812
|
+
#endif
|
|
11813
|
+
varying LOWP vec4 v_color;
|
|
11814
|
+
varying vec2 v_texCoords;
|
|
11815
|
+
uniform sampler2D u_texture;
|
|
11813
11816
|
|
|
11814
|
-
|
|
11815
|
-
|
|
11816
|
-
|
|
11817
|
-
|
|
11817
|
+
void main () {
|
|
11818
|
+
gl_FragColor = v_color * texture2D(u_texture, v_texCoords);
|
|
11819
|
+
}
|
|
11820
|
+
`;
|
|
11818
11821
|
return new _Shader(context, vs, fs);
|
|
11819
11822
|
}
|
|
11820
11823
|
static newTwoColoredTextured(context) {
|
|
11821
11824
|
let vs = `
|
|
11822
|
-
|
|
11823
|
-
|
|
11824
|
-
|
|
11825
|
-
|
|
11826
|
-
|
|
11827
|
-
|
|
11828
|
-
|
|
11829
|
-
|
|
11825
|
+
attribute vec4 ${_Shader.POSITION};
|
|
11826
|
+
attribute vec4 ${_Shader.COLOR};
|
|
11827
|
+
attribute vec4 ${_Shader.COLOR2};
|
|
11828
|
+
attribute vec2 ${_Shader.TEXCOORDS};
|
|
11829
|
+
uniform mat4 ${_Shader.MVP_MATRIX};
|
|
11830
|
+
varying vec4 v_light;
|
|
11831
|
+
varying vec4 v_dark;
|
|
11832
|
+
varying vec2 v_texCoords;
|
|
11830
11833
|
|
|
11831
|
-
|
|
11832
|
-
|
|
11833
|
-
|
|
11834
|
-
|
|
11835
|
-
|
|
11836
|
-
|
|
11837
|
-
|
|
11834
|
+
void main () {
|
|
11835
|
+
v_light = ${_Shader.COLOR};
|
|
11836
|
+
v_dark = ${_Shader.COLOR2};
|
|
11837
|
+
v_texCoords = ${_Shader.TEXCOORDS};
|
|
11838
|
+
gl_Position = ${_Shader.MVP_MATRIX} * ${_Shader.POSITION};
|
|
11839
|
+
}
|
|
11840
|
+
`;
|
|
11838
11841
|
let fs = `
|
|
11839
|
-
|
|
11840
|
-
|
|
11841
|
-
|
|
11842
|
-
|
|
11843
|
-
|
|
11844
|
-
|
|
11845
|
-
|
|
11846
|
-
|
|
11847
|
-
|
|
11848
|
-
|
|
11842
|
+
#ifdef GL_ES
|
|
11843
|
+
#define LOWP lowp
|
|
11844
|
+
precision mediump float;
|
|
11845
|
+
#else
|
|
11846
|
+
#define LOWP
|
|
11847
|
+
#endif
|
|
11848
|
+
varying LOWP vec4 v_light;
|
|
11849
|
+
varying LOWP vec4 v_dark;
|
|
11850
|
+
varying vec2 v_texCoords;
|
|
11851
|
+
uniform sampler2D u_texture;
|
|
11849
11852
|
|
|
11850
|
-
|
|
11851
|
-
|
|
11852
|
-
|
|
11853
|
-
|
|
11854
|
-
|
|
11855
|
-
|
|
11853
|
+
void main () {
|
|
11854
|
+
vec4 texColor = texture2D(u_texture, v_texCoords);
|
|
11855
|
+
gl_FragColor.a = texColor.a * v_light.a;
|
|
11856
|
+
gl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;
|
|
11857
|
+
}
|
|
11858
|
+
`;
|
|
11856
11859
|
return new _Shader(context, vs, fs);
|
|
11857
11860
|
}
|
|
11858
11861
|
static newColored(context) {
|
|
11859
11862
|
let vs = `
|
|
11860
|
-
|
|
11861
|
-
|
|
11862
|
-
|
|
11863
|
-
|
|
11863
|
+
attribute vec4 ${_Shader.POSITION};
|
|
11864
|
+
attribute vec4 ${_Shader.COLOR};
|
|
11865
|
+
uniform mat4 ${_Shader.MVP_MATRIX};
|
|
11866
|
+
varying vec4 v_color;
|
|
11864
11867
|
|
|
11865
|
-
|
|
11866
|
-
|
|
11867
|
-
|
|
11868
|
-
|
|
11869
|
-
|
|
11868
|
+
void main () {
|
|
11869
|
+
v_color = ${_Shader.COLOR};
|
|
11870
|
+
gl_Position = ${_Shader.MVP_MATRIX} * ${_Shader.POSITION};
|
|
11871
|
+
}
|
|
11872
|
+
`;
|
|
11870
11873
|
let fs = `
|
|
11871
|
-
|
|
11872
|
-
|
|
11873
|
-
|
|
11874
|
-
|
|
11875
|
-
|
|
11876
|
-
|
|
11877
|
-
|
|
11874
|
+
#ifdef GL_ES
|
|
11875
|
+
#define LOWP lowp
|
|
11876
|
+
precision mediump float;
|
|
11877
|
+
#else
|
|
11878
|
+
#define LOWP
|
|
11879
|
+
#endif
|
|
11880
|
+
varying LOWP vec4 v_color;
|
|
11878
11881
|
|
|
11879
|
-
|
|
11880
|
-
|
|
11881
|
-
|
|
11882
|
-
|
|
11882
|
+
void main () {
|
|
11883
|
+
gl_FragColor = v_color;
|
|
11884
|
+
}
|
|
11885
|
+
`;
|
|
11883
11886
|
return new _Shader(context, vs, fs);
|
|
11884
11887
|
}
|
|
11885
11888
|
};
|
|
@@ -12760,7 +12763,7 @@ var spine = (() => {
|
|
|
12760
12763
|
region.computeWorldVertices(slot, renderable.vertices, 0, clippedVertexSize);
|
|
12761
12764
|
triangles = _SkeletonRenderer.QUAD_TRIANGLES;
|
|
12762
12765
|
uvs = region.uvs;
|
|
12763
|
-
texture = region.region.
|
|
12766
|
+
texture = region.region.texture;
|
|
12764
12767
|
attachmentColor = region.color;
|
|
12765
12768
|
} else if (attachment instanceof MeshAttachment) {
|
|
12766
12769
|
let mesh = attachment;
|
|
@@ -12772,7 +12775,7 @@ var spine = (() => {
|
|
|
12772
12775
|
}
|
|
12773
12776
|
mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, renderable.vertices, 0, clippedVertexSize);
|
|
12774
12777
|
triangles = mesh.triangles;
|
|
12775
|
-
texture = mesh.region.
|
|
12778
|
+
texture = mesh.region.texture;
|
|
12776
12779
|
uvs = mesh.uvs;
|
|
12777
12780
|
attachmentColor = mesh.color;
|
|
12778
12781
|
} else if (attachment instanceof ClippingAttachment) {
|
|
@@ -12822,7 +12825,7 @@ var spine = (() => {
|
|
|
12822
12825
|
let clippedVertices = new Float32Array(clipper.clippedVertices);
|
|
12823
12826
|
let clippedTriangles = clipper.clippedTriangles;
|
|
12824
12827
|
if (transformer)
|
|
12825
|
-
transformer(
|
|
12828
|
+
transformer(clippedVertices, clippedVertices.length, vertexSize);
|
|
12826
12829
|
batcher.draw(texture, clippedVertices, clippedTriangles);
|
|
12827
12830
|
} else {
|
|
12828
12831
|
let verts = renderable.vertices;
|