2016-12-07 02:28:22 +00:00
|
|
|
|
2017-02-21 00:38:22 +00:00
|
|
|
var ImageWebGLRenderer = function (renderer, src, interpolationPercentage, camera)
|
2016-12-07 02:28:22 +00:00
|
|
|
{
|
2017-02-23 03:10:48 +00:00
|
|
|
if (this.renderMask !== this.renderFlags)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-21 19:21:03 +00:00
|
|
|
//--------------------
|
|
|
|
// Inlined quad push
|
|
|
|
//--------------------
|
|
|
|
|
2016-12-07 02:28:22 +00:00
|
|
|
var frame = src.frame;
|
2017-01-31 17:04:31 +00:00
|
|
|
var alpha = 16777216;
|
2017-01-31 21:40:29 +00:00
|
|
|
var spriteBatch = renderer.spriteBatch;
|
2017-03-02 02:06:13 +00:00
|
|
|
// var anchorX = src.anchorX;
|
|
|
|
// var anchorY = src.anchorY;
|
2017-02-22 16:44:14 +00:00
|
|
|
//var vertexColor = src.color._glTint;
|
2017-01-31 21:40:29 +00:00
|
|
|
var vertexDataBuffer = spriteBatch.vertexDataBuffer;
|
|
|
|
var vertexBufferF32 = vertexDataBuffer.floatView;
|
|
|
|
var vertexBufferU32 = vertexDataBuffer.uintView;
|
2017-02-21 19:21:03 +00:00
|
|
|
var vertexOffset = 0;
|
2017-01-31 21:40:29 +00:00
|
|
|
var uvs = frame.uvs;
|
|
|
|
var width = frame.width;
|
|
|
|
var height = frame.height;
|
2017-02-22 16:44:14 +00:00
|
|
|
var translateX = src.x - camera.scrollX;
|
|
|
|
var translateY = src.y - camera.scrollY;
|
|
|
|
var scaleX = src.scaleX;
|
|
|
|
var scaleY = src.scaleY;
|
|
|
|
var rotation = src.rotation;
|
2017-02-21 00:38:22 +00:00
|
|
|
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];
|
2017-03-02 02:06:13 +00:00
|
|
|
var x = -src.originX + frame.x;
|
|
|
|
var y = -src.originY + frame.y;
|
2017-01-31 21:40:29 +00:00
|
|
|
var xw = x + width;
|
|
|
|
var yh = y + height;
|
2017-02-21 00:38:22 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
renderer.setBatch(spriteBatch, frame.texture.source[frame.sourceIndex].glTexture);
|
2017-02-21 19:21:03 +00:00
|
|
|
vertexOffset = vertexDataBuffer.allocate(40);
|
|
|
|
spriteBatch.elementCount += 6;
|
|
|
|
|
2017-01-31 21:40:29 +00:00
|
|
|
vertexBufferF32[vertexOffset++] = tx;
|
|
|
|
vertexBufferF32[vertexOffset++] = ty;
|
2017-02-21 00:38:22 +00:00
|
|
|
vertexBufferF32[vertexOffset++] = uvs.x0;
|
|
|
|
vertexBufferF32[vertexOffset++] = uvs.y0;
|
|
|
|
vertexBufferF32[vertexOffset++] = translateX;
|
|
|
|
vertexBufferF32[vertexOffset++] = translateY;
|
|
|
|
vertexBufferF32[vertexOffset++] = scaleX;
|
|
|
|
vertexBufferF32[vertexOffset++] = scaleY;
|
|
|
|
vertexBufferF32[vertexOffset++] = rotation;
|
2017-02-22 16:44:14 +00:00
|
|
|
vertexBufferU32[vertexOffset++] = 0xFFFFFF; //vertexColor.topLeft;
|
2017-02-23 03:10:48 +00:00
|
|
|
|
2017-02-21 00:38:22 +00:00
|
|
|
vertexBufferF32[vertexOffset++] = tx;
|
|
|
|
vertexBufferF32[vertexOffset++] = tyh;
|
2017-01-31 21:40:29 +00:00
|
|
|
vertexBufferF32[vertexOffset++] = uvs.x1;
|
|
|
|
vertexBufferF32[vertexOffset++] = uvs.y1;
|
2017-02-21 00:38:22 +00:00
|
|
|
vertexBufferF32[vertexOffset++] = translateX;
|
|
|
|
vertexBufferF32[vertexOffset++] = translateY;
|
|
|
|
vertexBufferF32[vertexOffset++] = scaleX;
|
|
|
|
vertexBufferF32[vertexOffset++] = scaleY;
|
|
|
|
vertexBufferF32[vertexOffset++] = rotation;
|
2017-02-22 16:44:14 +00:00
|
|
|
vertexBufferU32[vertexOffset++] = 0xFFFFFF; //vertexColor.bottomLeft;
|
2017-02-23 03:10:48 +00:00
|
|
|
|
2017-02-21 00:38:22 +00:00
|
|
|
vertexBufferF32[vertexOffset++] = txw;
|
|
|
|
vertexBufferF32[vertexOffset++] = tyh;
|
2017-01-31 21:40:29 +00:00
|
|
|
vertexBufferF32[vertexOffset++] = uvs.x2;
|
|
|
|
vertexBufferF32[vertexOffset++] = uvs.y2;
|
2017-02-21 00:38:22 +00:00
|
|
|
vertexBufferF32[vertexOffset++] = translateX;
|
|
|
|
vertexBufferF32[vertexOffset++] = translateY;
|
|
|
|
vertexBufferF32[vertexOffset++] = scaleX;
|
|
|
|
vertexBufferF32[vertexOffset++] = scaleY;
|
|
|
|
vertexBufferF32[vertexOffset++] = rotation;
|
2017-02-22 16:44:14 +00:00
|
|
|
vertexBufferU32[vertexOffset++] = 0xFFFFFF; //vertexColor.bottomRight;
|
2017-02-23 03:10:48 +00:00
|
|
|
|
2017-02-21 00:38:22 +00:00
|
|
|
vertexBufferF32[vertexOffset++] = txw;
|
|
|
|
vertexBufferF32[vertexOffset++] = ty;
|
2017-01-31 21:40:29 +00:00
|
|
|
vertexBufferF32[vertexOffset++] = uvs.x3;
|
|
|
|
vertexBufferF32[vertexOffset++] = uvs.y3;
|
2017-02-21 00:38:22 +00:00
|
|
|
vertexBufferF32[vertexOffset++] = translateX;
|
|
|
|
vertexBufferF32[vertexOffset++] = translateY;
|
|
|
|
vertexBufferF32[vertexOffset++] = scaleX;
|
|
|
|
vertexBufferF32[vertexOffset++] = scaleY;
|
|
|
|
vertexBufferF32[vertexOffset++] = rotation;
|
2017-02-22 16:44:14 +00:00
|
|
|
vertexBufferU32[vertexOffset++] = 0xFFFFFF; //vertexColor.topRight;
|
2016-12-07 02:28:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = ImageWebGLRenderer;
|