Skip to content

Commit fef59ea

Browse files
committed
adapt region render color
1 parent 72e75f3 commit fef59ea

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

Diff for: extensions/spine/CCSkeletonWebGLRenderCmd.js

+14-7
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,20 @@ proto._uploadRegionAttachmentData = function(attachment, slot, premultipliedAlph
233233
nodeG = nodeColor.g,
234234
nodeB = nodeColor.b,
235235
nodeA = this._displayedOpacity;
236-
// 3.5 var vertices = attachment.updateWorldVertices(slot, premultipliedAlpha);
237-
// FIXME: lose premultipliedAlpha? alpha impl innner, "vertices, 0, 8);" -> "vertices, 0, 2);"
236+
238237
var vertices = spine.Utils.setArraySize(new Array(), 8, 0);
239238
attachment.computeWorldVertices(slot.bone, vertices, 0, 2);
240239

241240
var uvs = attachment.uvs;
242-
var color = attachment.color;
241+
242+
var skeleton = slot.bone.skeleton;
243+
var skeletonColor = skeleton.color;
244+
var slotColor = slot.color;
245+
var regionColor = attachment.color;
246+
var alpha = skeletonColor.a * slotColor.a * regionColor.a;
247+
var multiplier = premultipliedAlpha ? alpha : 1;
248+
var colors = attachment.tempColor;
249+
colors.set(skeletonColor.r * slotColor.r * regionColor.r * multiplier, skeletonColor.g * slotColor.g * regionColor.g * multiplier, skeletonColor.b * slotColor.b * regionColor.b * multiplier, alpha);
243250

244251
var wt = this._worldTransform,
245252
wa = wt.a, wb = wt.b, wc = wt.c, wd = wt.d,
@@ -255,10 +262,10 @@ proto._uploadRegionAttachmentData = function(attachment, slot, premultipliedAlph
255262
vy = vertices[srcIdx * 2 + 1];
256263
var x = vx * wa + vy * wc + wx,
257264
y = vx * wb + vy * wd + wy;
258-
var r = color.r * nodeR,
259-
g = color.g * nodeG,
260-
b = color.b * nodeB,
261-
a = color.a * nodeA;
265+
var r = colors.r * nodeR,
266+
g = colors.g * nodeG,
267+
b = colors.b * nodeB,
268+
a = colors.a * nodeA;
262269
var color = ((a<<24) | (b<<16) | (g<<8) | r);
263270
f32buffer[offset] = x;
264271
f32buffer[offset + 1] = y;

0 commit comments

Comments
 (0)