diff --git a/packages/core/src/batch/BatchRenderer.js b/packages/core/src/batch/BatchRenderer.js index 19e5cf0..b9a5e4f 100644 --- a/packages/core/src/batch/BatchRenderer.js +++ b/packages/core/src/batch/BatchRenderer.js @@ -247,6 +247,8 @@ const sprite = elements[i]; + elements[i] = null; + nextTexture = sprite._texture.baseTexture; const spriteBlendMode = premultiplyBlendMode[nextTexture.premultiplyAlpha ? 1 : 0][sprite.blendMode]; @@ -352,6 +354,7 @@ for (let j = 0; j < groupTextureCount; j++) { textureSystem.bind(group.textures[j], j); + group.textures[j] = null; } // this.state.blendMode = group.blend; diff --git a/packages/core/src/batch/BatchRenderer.js b/packages/core/src/batch/BatchRenderer.js index 19e5cf0..b9a5e4f 100644 --- a/packages/core/src/batch/BatchRenderer.js +++ b/packages/core/src/batch/BatchRenderer.js @@ -247,6 +247,8 @@ const sprite = elements[i]; + elements[i] = null; + nextTexture = sprite._texture.baseTexture; const spriteBlendMode = premultiplyBlendMode[nextTexture.premultiplyAlpha ? 1 : 0][sprite.blendMode]; @@ -352,6 +354,7 @@ for (let j = 0; j < groupTextureCount; j++) { textureSystem.bind(group.textures[j], j); + group.textures[j] = null; } // this.state.blendMode = group.blend; diff --git a/packages/graphics/src/GraphicsData.js b/packages/graphics/src/GraphicsData.js index 91598b3..f7b7628 100644 --- a/packages/graphics/src/GraphicsData.js +++ b/packages/graphics/src/GraphicsData.js @@ -67,8 +67,8 @@ { return new GraphicsData( this.shape, - this.lineStyle, this.fillStyle, + this.lineStyle, this.matrix ); } diff --git a/packages/core/src/batch/BatchRenderer.js b/packages/core/src/batch/BatchRenderer.js index 19e5cf0..b9a5e4f 100644 --- a/packages/core/src/batch/BatchRenderer.js +++ b/packages/core/src/batch/BatchRenderer.js @@ -247,6 +247,8 @@ const sprite = elements[i]; + elements[i] = null; + nextTexture = sprite._texture.baseTexture; const spriteBlendMode = premultiplyBlendMode[nextTexture.premultiplyAlpha ? 1 : 0][sprite.blendMode]; @@ -352,6 +354,7 @@ for (let j = 0; j < groupTextureCount; j++) { textureSystem.bind(group.textures[j], j); + group.textures[j] = null; } // this.state.blendMode = group.blend; diff --git a/packages/graphics/src/GraphicsData.js b/packages/graphics/src/GraphicsData.js index 91598b3..f7b7628 100644 --- a/packages/graphics/src/GraphicsData.js +++ b/packages/graphics/src/GraphicsData.js @@ -67,8 +67,8 @@ { return new GraphicsData( this.shape, - this.lineStyle, this.fillStyle, + this.lineStyle, this.matrix ); } diff --git a/packages/graphics/src/GraphicsGeometry.js b/packages/graphics/src/GraphicsGeometry.js index d8d3ce9..912a39c 100644 --- a/packages/graphics/src/GraphicsGeometry.js +++ b/packages/graphics/src/GraphicsGeometry.js @@ -1,5 +1,6 @@ import { BatchGeometry } from '@pixi/core'; -import { Rectangle, SHAPES } from '@pixi/math'; +import { SHAPES } from '@pixi/math'; +import { Bounds } from '@pixi/display'; import GraphicsData from './GraphicsData'; import buildCircle from './utils/buildCircle'; @@ -157,10 +158,10 @@ /** * Cached bounds. * - * @member {PIXI.Rectangle} + * @member {PIXI.Bounds} * @private */ - this._bounds = new Rectangle(); + this._bounds = new Bounds(); /** * The bounds dirty flag. @@ -177,12 +178,18 @@ * @default 0 */ this.boundsPadding = 0; + + this.batchable = false; + + this.indicesUint16 = null; + + this.uvsFloat32 = null; } /** * Get the current bounds of the graphic geometry. * - * @member {PIXI.Rectangle} + * @member {PIXI.Bounds} * @readonly */ get bounds() @@ -215,9 +222,11 @@ this.colors.length = 0; this.uvs.length = 0; this.indices.length = 0; + this.textureIds.length = 0; - for (let i = 0; i < DRAW_CALL_POOL.length; i++) + for (let i = 0; i < this.drawCalls.length; i++) { + this.drawCalls[i].textures.length = 0; DRAW_CALL_POOL.push(this.drawCalls[i]); } @@ -533,6 +542,7 @@ for (let i = 0; i < this.drawCalls.length; i++) { + this.drawCalls[i].textures.length = 0; DRAW_CALL_POOL.push(this.drawCalls[i]); } @@ -682,7 +692,7 @@ if (this.graphicsData.length) { - let shape = 0; + let shape = null; let x = 0; let y = 0; let w = 0; diff --git a/packages/core/src/batch/BatchRenderer.js b/packages/core/src/batch/BatchRenderer.js index 19e5cf0..b9a5e4f 100644 --- a/packages/core/src/batch/BatchRenderer.js +++ b/packages/core/src/batch/BatchRenderer.js @@ -247,6 +247,8 @@ const sprite = elements[i]; + elements[i] = null; + nextTexture = sprite._texture.baseTexture; const spriteBlendMode = premultiplyBlendMode[nextTexture.premultiplyAlpha ? 1 : 0][sprite.blendMode]; @@ -352,6 +354,7 @@ for (let j = 0; j < groupTextureCount; j++) { textureSystem.bind(group.textures[j], j); + group.textures[j] = null; } // this.state.blendMode = group.blend; diff --git a/packages/graphics/src/GraphicsData.js b/packages/graphics/src/GraphicsData.js index 91598b3..f7b7628 100644 --- a/packages/graphics/src/GraphicsData.js +++ b/packages/graphics/src/GraphicsData.js @@ -67,8 +67,8 @@ { return new GraphicsData( this.shape, - this.lineStyle, this.fillStyle, + this.lineStyle, this.matrix ); } diff --git a/packages/graphics/src/GraphicsGeometry.js b/packages/graphics/src/GraphicsGeometry.js index d8d3ce9..912a39c 100644 --- a/packages/graphics/src/GraphicsGeometry.js +++ b/packages/graphics/src/GraphicsGeometry.js @@ -1,5 +1,6 @@ import { BatchGeometry } from '@pixi/core'; -import { Rectangle, SHAPES } from '@pixi/math'; +import { SHAPES } from '@pixi/math'; +import { Bounds } from '@pixi/display'; import GraphicsData from './GraphicsData'; import buildCircle from './utils/buildCircle'; @@ -157,10 +158,10 @@ /** * Cached bounds. * - * @member {PIXI.Rectangle} + * @member {PIXI.Bounds} * @private */ - this._bounds = new Rectangle(); + this._bounds = new Bounds(); /** * The bounds dirty flag. @@ -177,12 +178,18 @@ * @default 0 */ this.boundsPadding = 0; + + this.batchable = false; + + this.indicesUint16 = null; + + this.uvsFloat32 = null; } /** * Get the current bounds of the graphic geometry. * - * @member {PIXI.Rectangle} + * @member {PIXI.Bounds} * @readonly */ get bounds() @@ -215,9 +222,11 @@ this.colors.length = 0; this.uvs.length = 0; this.indices.length = 0; + this.textureIds.length = 0; - for (let i = 0; i < DRAW_CALL_POOL.length; i++) + for (let i = 0; i < this.drawCalls.length; i++) { + this.drawCalls[i].textures.length = 0; DRAW_CALL_POOL.push(this.drawCalls[i]); } @@ -533,6 +542,7 @@ for (let i = 0; i < this.drawCalls.length; i++) { + this.drawCalls[i].textures.length = 0; DRAW_CALL_POOL.push(this.drawCalls[i]); } @@ -682,7 +692,7 @@ if (this.graphicsData.length) { - let shape = 0; + let shape = null; let x = 0; let y = 0; let w = 0; diff --git a/packages/mesh-extras/src/SimplePlane.js b/packages/mesh-extras/src/SimplePlane.js index 7b572ce..be35b50 100644 --- a/packages/mesh-extras/src/SimplePlane.js +++ b/packages/mesh-extras/src/SimplePlane.js @@ -31,7 +31,7 @@ super(planeGeometry, meshMaterial); // wait for the texture to load - if (!texture.baseTexture.hasLoaded) + if (!texture.baseTexture.valid) { texture.once('update', this.textureUpdated, this); } diff --git a/packages/core/src/batch/BatchRenderer.js b/packages/core/src/batch/BatchRenderer.js index 19e5cf0..b9a5e4f 100644 --- a/packages/core/src/batch/BatchRenderer.js +++ b/packages/core/src/batch/BatchRenderer.js @@ -247,6 +247,8 @@ const sprite = elements[i]; + elements[i] = null; + nextTexture = sprite._texture.baseTexture; const spriteBlendMode = premultiplyBlendMode[nextTexture.premultiplyAlpha ? 1 : 0][sprite.blendMode]; @@ -352,6 +354,7 @@ for (let j = 0; j < groupTextureCount; j++) { textureSystem.bind(group.textures[j], j); + group.textures[j] = null; } // this.state.blendMode = group.blend; diff --git a/packages/graphics/src/GraphicsData.js b/packages/graphics/src/GraphicsData.js index 91598b3..f7b7628 100644 --- a/packages/graphics/src/GraphicsData.js +++ b/packages/graphics/src/GraphicsData.js @@ -67,8 +67,8 @@ { return new GraphicsData( this.shape, - this.lineStyle, this.fillStyle, + this.lineStyle, this.matrix ); } diff --git a/packages/graphics/src/GraphicsGeometry.js b/packages/graphics/src/GraphicsGeometry.js index d8d3ce9..912a39c 100644 --- a/packages/graphics/src/GraphicsGeometry.js +++ b/packages/graphics/src/GraphicsGeometry.js @@ -1,5 +1,6 @@ import { BatchGeometry } from '@pixi/core'; -import { Rectangle, SHAPES } from '@pixi/math'; +import { SHAPES } from '@pixi/math'; +import { Bounds } from '@pixi/display'; import GraphicsData from './GraphicsData'; import buildCircle from './utils/buildCircle'; @@ -157,10 +158,10 @@ /** * Cached bounds. * - * @member {PIXI.Rectangle} + * @member {PIXI.Bounds} * @private */ - this._bounds = new Rectangle(); + this._bounds = new Bounds(); /** * The bounds dirty flag. @@ -177,12 +178,18 @@ * @default 0 */ this.boundsPadding = 0; + + this.batchable = false; + + this.indicesUint16 = null; + + this.uvsFloat32 = null; } /** * Get the current bounds of the graphic geometry. * - * @member {PIXI.Rectangle} + * @member {PIXI.Bounds} * @readonly */ get bounds() @@ -215,9 +222,11 @@ this.colors.length = 0; this.uvs.length = 0; this.indices.length = 0; + this.textureIds.length = 0; - for (let i = 0; i < DRAW_CALL_POOL.length; i++) + for (let i = 0; i < this.drawCalls.length; i++) { + this.drawCalls[i].textures.length = 0; DRAW_CALL_POOL.push(this.drawCalls[i]); } @@ -533,6 +542,7 @@ for (let i = 0; i < this.drawCalls.length; i++) { + this.drawCalls[i].textures.length = 0; DRAW_CALL_POOL.push(this.drawCalls[i]); } @@ -682,7 +692,7 @@ if (this.graphicsData.length) { - let shape = 0; + let shape = null; let x = 0; let y = 0; let w = 0; diff --git a/packages/mesh-extras/src/SimplePlane.js b/packages/mesh-extras/src/SimplePlane.js index 7b572ce..be35b50 100644 --- a/packages/mesh-extras/src/SimplePlane.js +++ b/packages/mesh-extras/src/SimplePlane.js @@ -31,7 +31,7 @@ super(planeGeometry, meshMaterial); // wait for the texture to load - if (!texture.baseTexture.hasLoaded) + if (!texture.baseTexture.valid) { texture.once('update', this.textureUpdated, this); } diff --git a/packages/mesh-extras/src/SimpleRope.js b/packages/mesh-extras/src/SimpleRope.js index ba8a4cf..bab5ed2 100644 --- a/packages/mesh-extras/src/SimpleRope.js +++ b/packages/mesh-extras/src/SimpleRope.js @@ -28,11 +28,18 @@ const meshMaterial = new MeshMaterial(texture); super(ropeGeometry, meshMaterial); + + this.autoUpdate = true; } _render(renderer) { - this.geometry.width = this.shader.texture.height; + if (this.autoUpdate + || this.geometry.width !== this.shader.texture.height) + { + this.geometry.width = this.shader.texture.height; + this.geometry.update(); + } super._render(renderer); } diff --git a/packages/core/src/batch/BatchRenderer.js b/packages/core/src/batch/BatchRenderer.js index 19e5cf0..b9a5e4f 100644 --- a/packages/core/src/batch/BatchRenderer.js +++ b/packages/core/src/batch/BatchRenderer.js @@ -247,6 +247,8 @@ const sprite = elements[i]; + elements[i] = null; + nextTexture = sprite._texture.baseTexture; const spriteBlendMode = premultiplyBlendMode[nextTexture.premultiplyAlpha ? 1 : 0][sprite.blendMode]; @@ -352,6 +354,7 @@ for (let j = 0; j < groupTextureCount; j++) { textureSystem.bind(group.textures[j], j); + group.textures[j] = null; } // this.state.blendMode = group.blend; diff --git a/packages/graphics/src/GraphicsData.js b/packages/graphics/src/GraphicsData.js index 91598b3..f7b7628 100644 --- a/packages/graphics/src/GraphicsData.js +++ b/packages/graphics/src/GraphicsData.js @@ -67,8 +67,8 @@ { return new GraphicsData( this.shape, - this.lineStyle, this.fillStyle, + this.lineStyle, this.matrix ); } diff --git a/packages/graphics/src/GraphicsGeometry.js b/packages/graphics/src/GraphicsGeometry.js index d8d3ce9..912a39c 100644 --- a/packages/graphics/src/GraphicsGeometry.js +++ b/packages/graphics/src/GraphicsGeometry.js @@ -1,5 +1,6 @@ import { BatchGeometry } from '@pixi/core'; -import { Rectangle, SHAPES } from '@pixi/math'; +import { SHAPES } from '@pixi/math'; +import { Bounds } from '@pixi/display'; import GraphicsData from './GraphicsData'; import buildCircle from './utils/buildCircle'; @@ -157,10 +158,10 @@ /** * Cached bounds. * - * @member {PIXI.Rectangle} + * @member {PIXI.Bounds} * @private */ - this._bounds = new Rectangle(); + this._bounds = new Bounds(); /** * The bounds dirty flag. @@ -177,12 +178,18 @@ * @default 0 */ this.boundsPadding = 0; + + this.batchable = false; + + this.indicesUint16 = null; + + this.uvsFloat32 = null; } /** * Get the current bounds of the graphic geometry. * - * @member {PIXI.Rectangle} + * @member {PIXI.Bounds} * @readonly */ get bounds() @@ -215,9 +222,11 @@ this.colors.length = 0; this.uvs.length = 0; this.indices.length = 0; + this.textureIds.length = 0; - for (let i = 0; i < DRAW_CALL_POOL.length; i++) + for (let i = 0; i < this.drawCalls.length; i++) { + this.drawCalls[i].textures.length = 0; DRAW_CALL_POOL.push(this.drawCalls[i]); } @@ -533,6 +542,7 @@ for (let i = 0; i < this.drawCalls.length; i++) { + this.drawCalls[i].textures.length = 0; DRAW_CALL_POOL.push(this.drawCalls[i]); } @@ -682,7 +692,7 @@ if (this.graphicsData.length) { - let shape = 0; + let shape = null; let x = 0; let y = 0; let w = 0; diff --git a/packages/mesh-extras/src/SimplePlane.js b/packages/mesh-extras/src/SimplePlane.js index 7b572ce..be35b50 100644 --- a/packages/mesh-extras/src/SimplePlane.js +++ b/packages/mesh-extras/src/SimplePlane.js @@ -31,7 +31,7 @@ super(planeGeometry, meshMaterial); // wait for the texture to load - if (!texture.baseTexture.hasLoaded) + if (!texture.baseTexture.valid) { texture.once('update', this.textureUpdated, this); } diff --git a/packages/mesh-extras/src/SimpleRope.js b/packages/mesh-extras/src/SimpleRope.js index ba8a4cf..bab5ed2 100644 --- a/packages/mesh-extras/src/SimpleRope.js +++ b/packages/mesh-extras/src/SimpleRope.js @@ -28,11 +28,18 @@ const meshMaterial = new MeshMaterial(texture); super(ropeGeometry, meshMaterial); + + this.autoUpdate = true; } _render(renderer) { - this.geometry.width = this.shader.texture.height; + if (this.autoUpdate + || this.geometry.width !== this.shader.texture.height) + { + this.geometry.width = this.shader.texture.height; + this.geometry.update(); + } super._render(renderer); } diff --git a/packages/mesh/src/Mesh.js b/packages/mesh/src/Mesh.js index 870e3c4..1750771 100644 --- a/packages/mesh/src/Mesh.js +++ b/packages/mesh/src/Mesh.js @@ -107,6 +107,8 @@ */ this.vertexDirty = 0; + this._transformID = -1; + // Inherited from DisplayMode, set defaults this.tint = 0xFFFFFF; this.blendMode = BLEND_MODES.NORMAL; diff --git a/packages/core/src/batch/BatchRenderer.js b/packages/core/src/batch/BatchRenderer.js index 19e5cf0..b9a5e4f 100644 --- a/packages/core/src/batch/BatchRenderer.js +++ b/packages/core/src/batch/BatchRenderer.js @@ -247,6 +247,8 @@ const sprite = elements[i]; + elements[i] = null; + nextTexture = sprite._texture.baseTexture; const spriteBlendMode = premultiplyBlendMode[nextTexture.premultiplyAlpha ? 1 : 0][sprite.blendMode]; @@ -352,6 +354,7 @@ for (let j = 0; j < groupTextureCount; j++) { textureSystem.bind(group.textures[j], j); + group.textures[j] = null; } // this.state.blendMode = group.blend; diff --git a/packages/graphics/src/GraphicsData.js b/packages/graphics/src/GraphicsData.js index 91598b3..f7b7628 100644 --- a/packages/graphics/src/GraphicsData.js +++ b/packages/graphics/src/GraphicsData.js @@ -67,8 +67,8 @@ { return new GraphicsData( this.shape, - this.lineStyle, this.fillStyle, + this.lineStyle, this.matrix ); } diff --git a/packages/graphics/src/GraphicsGeometry.js b/packages/graphics/src/GraphicsGeometry.js index d8d3ce9..912a39c 100644 --- a/packages/graphics/src/GraphicsGeometry.js +++ b/packages/graphics/src/GraphicsGeometry.js @@ -1,5 +1,6 @@ import { BatchGeometry } from '@pixi/core'; -import { Rectangle, SHAPES } from '@pixi/math'; +import { SHAPES } from '@pixi/math'; +import { Bounds } from '@pixi/display'; import GraphicsData from './GraphicsData'; import buildCircle from './utils/buildCircle'; @@ -157,10 +158,10 @@ /** * Cached bounds. * - * @member {PIXI.Rectangle} + * @member {PIXI.Bounds} * @private */ - this._bounds = new Rectangle(); + this._bounds = new Bounds(); /** * The bounds dirty flag. @@ -177,12 +178,18 @@ * @default 0 */ this.boundsPadding = 0; + + this.batchable = false; + + this.indicesUint16 = null; + + this.uvsFloat32 = null; } /** * Get the current bounds of the graphic geometry. * - * @member {PIXI.Rectangle} + * @member {PIXI.Bounds} * @readonly */ get bounds() @@ -215,9 +222,11 @@ this.colors.length = 0; this.uvs.length = 0; this.indices.length = 0; + this.textureIds.length = 0; - for (let i = 0; i < DRAW_CALL_POOL.length; i++) + for (let i = 0; i < this.drawCalls.length; i++) { + this.drawCalls[i].textures.length = 0; DRAW_CALL_POOL.push(this.drawCalls[i]); } @@ -533,6 +542,7 @@ for (let i = 0; i < this.drawCalls.length; i++) { + this.drawCalls[i].textures.length = 0; DRAW_CALL_POOL.push(this.drawCalls[i]); } @@ -682,7 +692,7 @@ if (this.graphicsData.length) { - let shape = 0; + let shape = null; let x = 0; let y = 0; let w = 0; diff --git a/packages/mesh-extras/src/SimplePlane.js b/packages/mesh-extras/src/SimplePlane.js index 7b572ce..be35b50 100644 --- a/packages/mesh-extras/src/SimplePlane.js +++ b/packages/mesh-extras/src/SimplePlane.js @@ -31,7 +31,7 @@ super(planeGeometry, meshMaterial); // wait for the texture to load - if (!texture.baseTexture.hasLoaded) + if (!texture.baseTexture.valid) { texture.once('update', this.textureUpdated, this); } diff --git a/packages/mesh-extras/src/SimpleRope.js b/packages/mesh-extras/src/SimpleRope.js index ba8a4cf..bab5ed2 100644 --- a/packages/mesh-extras/src/SimpleRope.js +++ b/packages/mesh-extras/src/SimpleRope.js @@ -28,11 +28,18 @@ const meshMaterial = new MeshMaterial(texture); super(ropeGeometry, meshMaterial); + + this.autoUpdate = true; } _render(renderer) { - this.geometry.width = this.shader.texture.height; + if (this.autoUpdate + || this.geometry.width !== this.shader.texture.height) + { + this.geometry.width = this.shader.texture.height; + this.geometry.update(); + } super._render(renderer); } diff --git a/packages/mesh/src/Mesh.js b/packages/mesh/src/Mesh.js index 870e3c4..1750771 100644 --- a/packages/mesh/src/Mesh.js +++ b/packages/mesh/src/Mesh.js @@ -107,6 +107,8 @@ */ this.vertexDirty = 0; + this._transformID = -1; + // Inherited from DisplayMode, set defaults this.tint = 0xFFFFFF; this.blendMode = BLEND_MODES.NORMAL; diff --git a/packages/sprite-animated/src/AnimatedSprite.js b/packages/sprite-animated/src/AnimatedSprite.js index 330c683..b4a738b 100644 --- a/packages/sprite-animated/src/AnimatedSprite.js +++ b/packages/sprite-animated/src/AnimatedSprite.js @@ -286,7 +286,9 @@ { this._texture = this._textures[this.currentFrame]; this._textureID = -1; + this._textureTrimmedID = -1; this.cachedTint = 0xFFFFFF; + this.uvs = this._texture._uvs.uvsFloat32; if (this.onFrameChange) {