2017-02-21 19:21:03 +00:00
|
|
|
var BlitterWebGLRenderer = function (renderer, src, interpolationPercentage, camera)
|
2017-01-22 22:54:06 +00:00
|
|
|
{
|
2017-02-22 16:44:14 +00:00
|
|
|
var worldAlpha = 1; //src.color.worldAlpha;
|
2017-02-13 23:57:32 +00:00
|
|
|
var list = src.getRenderList();
|
2017-02-21 19:21:03 +00:00
|
|
|
var blitterBatch = renderer.blitterBatch;
|
|
|
|
var cameraMatrix = camera.matrix.matrix;
|
|
|
|
var a = cameraMatrix[0];
|
|
|
|
var b = cameraMatrix[1];
|
|
|
|
var c = cameraMatrix[2];
|
|
|
|
var d = cameraMatrix[3];
|
|
|
|
var e = cameraMatrix[4];
|
|
|
|
var f = cameraMatrix[5];
|
|
|
|
var cameraScrollX = camera.scrollX;
|
|
|
|
var cameraScrollY = camera.scrollY;
|
2017-01-22 22:54:06 +00:00
|
|
|
// Skip rendering?
|
|
|
|
|
2017-02-22 16:44:14 +00:00
|
|
|
if (!src.visible || worldAlpha === 0 || list.length === 0)
|
2017-02-01 00:43:38 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2017-01-22 22:54:06 +00:00
|
|
|
|
2017-02-01 00:43:38 +00:00
|
|
|
// Render bobs
|
2017-02-13 21:50:41 +00:00
|
|
|
|
2017-02-21 19:21:03 +00:00
|
|
|
for (var i = 0, l = list.length; i < l; i++)
|
2017-01-22 22:54:06 +00:00
|
|
|
{
|
2017-02-13 23:57:32 +00:00
|
|
|
var bob = list[i];
|
2017-02-21 19:21:03 +00:00
|
|
|
var frame = bob.frame;
|
|
|
|
var alpha = bob.alpha;
|
|
|
|
var vertexDataBuffer = blitterBatch.vertexDataBuffer;
|
|
|
|
var vertexBuffer = vertexDataBuffer.floatView;
|
|
|
|
var vertexOffset = 0;
|
|
|
|
var uvs = frame.uvs;
|
|
|
|
var width = frame.width;
|
|
|
|
var height = frame.height;
|
|
|
|
var x = bob.x + frame.x - cameraScrollX;
|
|
|
|
var y = bob.y + frame.y - cameraScrollY;
|
|
|
|
var xw = x + width;
|
|
|
|
var yh = y + height;
|
|
|
|
var tx = x * a + y * c + e;
|
|
|
|
var ty = x * b + y * d + f;
|
|
|
|
var txw = xw * a + yh * c + e;
|
|
|
|
var tyh = xw * b + yh * d + f;
|
|
|
|
|
|
|
|
if (blitterBatch.elementCount >= blitterBatch.maxParticles)
|
|
|
|
{
|
|
|
|
blitterBatch.flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
renderer.setBatch(blitterBatch, frame.texture.source[frame.sourceIndex].glTexture);
|
|
|
|
vertexOffset = vertexDataBuffer.allocate(20);
|
|
|
|
blitterBatch.elementCount += 6;
|
|
|
|
x += frame.x;
|
|
|
|
y += frame.y;
|
2017-01-22 22:54:06 +00:00
|
|
|
|
2017-02-21 19:21:03 +00:00
|
|
|
vertexBuffer[vertexOffset++] = tx;
|
|
|
|
vertexBuffer[vertexOffset++] = ty;
|
|
|
|
vertexBuffer[vertexOffset++] = uvs.x0;
|
|
|
|
vertexBuffer[vertexOffset++] = uvs.y0;
|
|
|
|
vertexBuffer[vertexOffset++] = alpha;
|
|
|
|
vertexBuffer[vertexOffset++] = tx;
|
|
|
|
vertexBuffer[vertexOffset++] = tyh;
|
|
|
|
vertexBuffer[vertexOffset++] = uvs.x1;
|
|
|
|
vertexBuffer[vertexOffset++] = uvs.y1;
|
|
|
|
vertexBuffer[vertexOffset++] = alpha;
|
|
|
|
vertexBuffer[vertexOffset++] = txw;
|
|
|
|
vertexBuffer[vertexOffset++] = tyh;
|
|
|
|
vertexBuffer[vertexOffset++] = uvs.x2;
|
|
|
|
vertexBuffer[vertexOffset++] = uvs.y2;
|
|
|
|
vertexBuffer[vertexOffset++] = alpha;
|
|
|
|
vertexBuffer[vertexOffset++] = txw;
|
|
|
|
vertexBuffer[vertexOffset++] = ty;
|
|
|
|
vertexBuffer[vertexOffset++] = uvs.x3;
|
|
|
|
vertexBuffer[vertexOffset++] = uvs.y3;
|
|
|
|
vertexBuffer[vertexOffset++] = alpha;
|
2017-01-22 22:54:06 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = BlitterWebGLRenderer;
|