var Utils = require('../../renderer/webgl/Utils'); var MeshWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix){ var pipeline = this.pipeline; renderer.setPipeline(pipeline, src); var camMatrix = pipeline._tempMatrix1; var spriteMatrix = pipeline._tempMatrix2; var calcMatrix = pipeline._tempMatrix3; spriteMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); camMatrix.copyFrom(camera.matrix); if (parentMatrix) { camMatrix.multiplyWithOffset(parentMatrix, - camera.scrollX * src.scrollFactorX, - camera.scrollY * src.scrollFactorY); spriteMatrix.e = src.x; spriteMatrix.f = src.y; camMatrix.multiply(spriteMatrix, calcMatrix); } else { spriteMatrix.e -= camera.scrollX * src.scrollFactorX; spriteMatrix.f -= camera.scrollY * src.scrollFactorY; camMatrix.multiply(spriteMatrix, calcMatrix); } var frame = src.frame; var texture = frame.glTexture; var vertices = src.vertices; var uvs = src.uv; var colors = src.colors; var alphas = src.alphas; var meshVerticesLength = _AN_Read_length('length', vertices); var vertexCount = Math.floor(meshVerticesLength * 0.5); if (pipeline.vertexCount + vertexCount > pipeline.vertexCapacity) { pipeline.flush(); } pipeline.setTexture2D(texture, 0); var vertexViewF32 = pipeline.vertexViewF32; var vertexViewU32 = pipeline.vertexViewU32; var vertexOffset = (pipeline.vertexCount * pipeline.vertexComponentCount) - 1; var colorIndex = 0; var tintEffect = src.tintFill; for (var i = 0; i < meshVerticesLength; i += 2){ var x = vertices[i + 0]; var y = vertices[i + 1]; var tx = x * calcMatrix.a + y * calcMatrix.c + calcMatrix.e; var ty = x * calcMatrix.b + y * calcMatrix.d + calcMatrix.f; if (camera.roundPixels) { tx = Math.round(tx); ty = Math.round(ty); } vertexViewF32[++vertexOffset] = tx; vertexViewF32[++vertexOffset] = ty; vertexViewF32[++vertexOffset] = uvs[i + 0]; vertexViewF32[++vertexOffset] = uvs[i + 1]; vertexViewF32[++vertexOffset] = tintEffect; vertexViewU32[++vertexOffset] = Utils.getTintAppendFloatAlpha(colors[colorIndex], camera.alpha * alphas[colorIndex]); colorIndex++ ; } pipeline.vertexCount += vertexCount; } ; module.exports = MeshWebGLRenderer;