Skip to content

Commit e14b572

Browse files
committed
adapt mesh render clolor
1 parent fef59ea commit e14b572

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

Diff for: extensions/spine/CCSkeletonWebGLRenderCmd.js

+25-9
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,18 @@ proto._uploadRegionAttachmentData = function(attachment, slot, premultipliedAlph
239239

240240
var uvs = attachment.uvs;
241241

242+
// get the colors data
242243
var skeleton = slot.bone.skeleton;
243244
var skeletonColor = skeleton.color;
244245
var slotColor = slot.color;
245246
var regionColor = attachment.color;
246247
var alpha = skeletonColor.a * slotColor.a * regionColor.a;
247248
var multiplier = premultipliedAlpha ? alpha : 1;
248249
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);
250+
colors.set(skeletonColor.r * slotColor.r * regionColor.r * multiplier,
251+
skeletonColor.g * slotColor.g * regionColor.g * multiplier,
252+
skeletonColor.b * slotColor.b * regionColor.b * multiplier,
253+
alpha);
250254

251255
var wt = this._worldTransform,
252256
wa = wt.a, wb = wt.b, wc = wt.c, wd = wt.d,
@@ -294,11 +298,23 @@ proto._uploadMeshAttachmentData = function(attachment, slot, premultipliedAlpha,
294298
wx = wt.tx, wy = wt.ty,
295299
z = this._node.vertexZ;
296300
// get the vertex data
297-
// 3.5 var vertices = attachment.updateWorldVertices(slot, premultipliedAlpha);
298-
// FIXME, NOT USED THIS FUNCTION?
299301
var verticesLength = attachment.worldVerticesLength;
300302
var vertices = spine.Utils.setArraySize(new Array(), verticesLength, 0);
301303
attachment.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2);
304+
305+
var uvs = attachment.uvs;
306+
307+
// get the colors data
308+
var skeleton = slot.bone.skeleton;
309+
var skeletonColor = skeleton.color, slotColor = slot.color, meshColor = attachment.color;
310+
var alpha = skeletonColor.a * slotColor.a * meshColor.a;
311+
var multiplier = premultipliedAlpha ? alpha : 1;
312+
var colors = attachment.tempColor;
313+
colors.set(skeletonColor.r * slotColor.r * meshColor.r * multiplier,
314+
skeletonColor.g * slotColor.g * meshColor.g * multiplier,
315+
skeletonColor.b * slotColor.b * meshColor.b * multiplier,
316+
alpha);
317+
302318
var offset = vertexDataOffset;
303319
var nodeColor = this._displayedColor;
304320
var nodeR = nodeColor.r,
@@ -310,18 +326,18 @@ proto._uploadMeshAttachmentData = function(attachment, slot, premultipliedAlpha,
310326
vy = vertices[i + 1];
311327
var x = vx * wa + vy * wb + wx,
312328
y = vx * wc + vy * wd + wy;
313-
var r = vertices[i + 2] * nodeR,
314-
g = vertices[i + 3] * nodeG,
315-
b = vertices[i + 4] * nodeB,
316-
a = vertices[i + 5] * nodeA;
329+
var r = colors.r * nodeR,
330+
g = colors.g * nodeG,
331+
b = colors.b * nodeB,
332+
a = colors.a * nodeA;
317333
var color = ((a<<24) | (b<<16) | (g<<8) | r);
318334

319335
f32buffer[offset] = x;
320336
f32buffer[offset + 1] = y;
321337
f32buffer[offset + 2] = z;
322338
ui32buffer[offset + 3] = color;
323-
f32buffer[offset + 4] = vertices[i + 6];
324-
f32buffer[offset + 5] = vertices[i + 7];
339+
f32buffer[offset + 4] = uvs[i];
340+
f32buffer[offset + 5] = uvs[i + 1];
325341
offset += 6;
326342
}
327343
};

0 commit comments

Comments
 (0)