UNPKG

pixi.js

Version:

PixiJS — The HTML5 Creation Engine =============

80 lines (77 loc) 2.54 kB
'use strict'; "use strict"; class BatchableSprite { constructor() { // batch specific.. this.vertexSize = 4; this.indexSize = 6; this.location = 0; // location in the buffer this.batcher = null; this.batch = null; this.roundPixels = 0; } get blendMode() { return this.renderable.groupBlendMode; } packAttributes(float32View, uint32View, index, textureId) { const sprite = this.renderable; const texture = this.texture; const wt = sprite.groupTransform; const a = wt.a; const b = wt.b; const c = wt.c; const d = wt.d; const tx = wt.tx; const ty = wt.ty; const bounds = this.bounds; const w0 = bounds.maxX; const w1 = bounds.minX; const h0 = bounds.maxY; const h1 = bounds.minY; const uvs = texture.uvs; const argb = sprite.groupColorAlpha; const textureIdAndRound = textureId << 16 | this.roundPixels & 65535; float32View[index + 0] = a * w1 + c * h1 + tx; float32View[index + 1] = d * h1 + b * w1 + ty; float32View[index + 2] = uvs.x0; float32View[index + 3] = uvs.y0; uint32View[index + 4] = argb; uint32View[index + 5] = textureIdAndRound; float32View[index + 6] = a * w0 + c * h1 + tx; float32View[index + 7] = d * h1 + b * w0 + ty; float32View[index + 8] = uvs.x1; float32View[index + 9] = uvs.y1; uint32View[index + 10] = argb; uint32View[index + 11] = textureIdAndRound; float32View[index + 12] = a * w0 + c * h0 + tx; float32View[index + 13] = d * h0 + b * w0 + ty; float32View[index + 14] = uvs.x2; float32View[index + 15] = uvs.y2; uint32View[index + 16] = argb; uint32View[index + 17] = textureIdAndRound; float32View[index + 18] = a * w1 + c * h0 + tx; float32View[index + 19] = d * h0 + b * w1 + ty; float32View[index + 20] = uvs.x3; float32View[index + 21] = uvs.y3; uint32View[index + 22] = argb; uint32View[index + 23] = textureIdAndRound; } packIndex(indexBuffer, index, indicesOffset) { indexBuffer[index] = indicesOffset + 0; indexBuffer[index + 1] = indicesOffset + 1; indexBuffer[index + 2] = indicesOffset + 2; indexBuffer[index + 3] = indicesOffset + 0; indexBuffer[index + 4] = indicesOffset + 2; indexBuffer[index + 5] = indicesOffset + 3; } reset() { this.renderable = null; this.texture = null; this.batcher = null; this.batch = null; this.bounds = null; } } exports.BatchableSprite = BatchableSprite; //# sourceMappingURL=BatchableSprite.js.map