var BatchChar = require('../BatchChar'); var Utils = require('../../../renderer/webgl/Utils'); var BitmapTextWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix){ var text = src._text; var textLength = _AN_Read_length('length', text); if (textLength === 0) { return ; } 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 roundPixels = camera.roundPixels; var cameraAlpha = camera.alpha; var charColors = src.charColors; var tintEffect = (src._isTinted && src.tintFill); var tintTL = Utils.getTintAppendFloatAlpha(src._tintTL, cameraAlpha * src._alphaTL); var tintTR = Utils.getTintAppendFloatAlpha(src._tintTR, cameraAlpha * src._alphaTR); var tintBL = Utils.getTintAppendFloatAlpha(src._tintBL, cameraAlpha * src._alphaBL); var tintBR = Utils.getTintAppendFloatAlpha(src._tintBR, cameraAlpha * src._alphaBR); var dropShadowX = src.dropShadowX; var dropShadowY = src.dropShadowY; var dropShadow = (dropShadowX !== 0 || dropShadowY !== 0); if (dropShadow) { var blackTL = Utils.getTintAppendFloatAlpha(src.dropShadowColor, cameraAlpha * src.dropShadowAlpha * src._alphaTL); var blackTR = Utils.getTintAppendFloatAlpha(src.dropShadowColor, cameraAlpha * src.dropShadowAlpha * src._alphaTR); var blackBL = Utils.getTintAppendFloatAlpha(src.dropShadowColor, cameraAlpha * src.dropShadowAlpha * src._alphaBL); var blackBR = Utils.getTintAppendFloatAlpha(src.dropShadowColor, cameraAlpha * src.dropShadowAlpha * src._alphaBR); } var texture = src.frame.glTexture; var textureUnit = pipeline.setGameObject(src); var bounds = src.getTextBounds(false ); var characters = bounds.characters; for (var i = 0; i < _AN_Read_length('length', characters); i++ ){ var char = characters[i]; var glyph = char.glyph; if (char.code === 32 || glyph.width === 0 || glyph.height === 0) { continue ; } if (dropShadow) { BatchChar(pipeline, src, char, glyph, dropShadowX, dropShadowY, calcMatrix, roundPixels, blackTL, blackTR, blackBL, blackBR, 0, texture, textureUnit); } if (charColors[char.i]) { var color = charColors[char.i]; var ctintEffect = color.tintEffect; var ctintTL = Utils.getTintAppendFloatAlpha(color.tintTL, cameraAlpha * src._alphaTL); var ctintTR = Utils.getTintAppendFloatAlpha(color.tintTR, cameraAlpha * src._alphaTR); var ctintBL = Utils.getTintAppendFloatAlpha(color.tintBL, cameraAlpha * src._alphaBL); var ctintBR = Utils.getTintAppendFloatAlpha(color.tintBR, cameraAlpha * src._alphaBR); BatchChar(pipeline, src, char, glyph, 0, 0, calcMatrix, roundPixels, ctintTL, ctintTR, ctintBL, ctintBR, ctintEffect, texture, textureUnit); } else { BatchChar(pipeline, src, char, glyph, 0, 0, calcMatrix, roundPixels, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, textureUnit); } } } ; module.exports = BitmapTextWebGLRenderer;