UNPKG

pixi.js

Version:

<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">

87 lines (84 loc) 2.38 kB
'use strict'; "use strict"; class BatchableMesh { constructor() { this.batcherName = "default"; this.packAsQuad = false; this.indexOffset = 0; this.attributeOffset = 0; this.roundPixels = 0; this._batcher = null; this._batch = null; this._textureMatrixUpdateId = -1; this._uvUpdateId = -1; } get blendMode() { return this.renderable.groupBlendMode; } get topology() { return this._topology || this.geometry.topology; } set topology(value) { this._topology = value; } reset() { this.renderable = null; this.texture = null; this._batcher = null; this._batch = null; this.geometry = null; this._uvUpdateId = -1; this._textureMatrixUpdateId = -1; } /** * Sets the texture for the batchable mesh. * As it does so, it resets the texture matrix update ID. * this is to ensure that the texture matrix is recalculated when the uvs are referenced * @param value - The texture to set. */ setTexture(value) { if (this.texture === value) return; this.texture = value; this._textureMatrixUpdateId = -1; } get uvs() { const geometry = this.geometry; const uvBuffer = geometry.getBuffer("aUV"); const uvs = uvBuffer.data; let transformedUvs = uvs; const textureMatrix = this.texture.textureMatrix; if (!textureMatrix.isSimple) { transformedUvs = this._transformedUvs; if (this._textureMatrixUpdateId !== textureMatrix._updateID || this._uvUpdateId !== uvBuffer._updateID) { if (!transformedUvs || transformedUvs.length < uvs.length) { transformedUvs = this._transformedUvs = new Float32Array(uvs.length); } this._textureMatrixUpdateId = textureMatrix._updateID; this._uvUpdateId = uvBuffer._updateID; textureMatrix.multiplyUvs(uvs, transformedUvs); } } return transformedUvs; } get positions() { return this.geometry.positions; } get indices() { return this.geometry.indices; } get color() { return this.renderable.groupColorAlpha; } get groupTransform() { return this.renderable.groupTransform; } get attributeSize() { return this.geometry.positions.length / 2; } get indexSize() { return this.geometry.indices.length; } } exports.BatchableMesh = BatchableMesh; //# sourceMappingURL=BatchableMesh.js.map