diff --git a/src/mesh/Mesh.js b/src/mesh/Mesh.js index 1ccbfda..f6490b4 100644 --- a/src/mesh/Mesh.js +++ b/src/mesh/Mesh.js @@ -59,6 +59,7 @@ * @member {boolean} */ this.dirty = true; + this.indexDirty = true; /** * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. @@ -172,12 +173,22 @@ .addAttribute(glData.uvBuffer, glData.shader.attributes.aTextureCoord, gl.FLOAT, false, 2 * 4, 0); this._glDatas[renderer.CONTEXT_UID] = glData; + + + this.indexDirty = false; } if(this.dirty) { this.dirty = false; glData.uvBuffer.upload(); + + } + + if(this.indexDirty) + { + this.indexDirty = false; + glData.indexBuffer.upload(); } glData.vertexBuffer.upload(); diff --git a/src/mesh/Mesh.js b/src/mesh/Mesh.js index 1ccbfda..f6490b4 100644 --- a/src/mesh/Mesh.js +++ b/src/mesh/Mesh.js @@ -59,6 +59,7 @@ * @member {boolean} */ this.dirty = true; + this.indexDirty = true; /** * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. @@ -172,12 +173,22 @@ .addAttribute(glData.uvBuffer, glData.shader.attributes.aTextureCoord, gl.FLOAT, false, 2 * 4, 0); this._glDatas[renderer.CONTEXT_UID] = glData; + + + this.indexDirty = false; } if(this.dirty) { this.dirty = false; glData.uvBuffer.upload(); + + } + + if(this.indexDirty) + { + this.indexDirty = false; + glData.indexBuffer.upload(); } glData.vertexBuffer.upload(); diff --git a/src/mesh/Plane.js b/src/mesh/Plane.js index 9fddbd8..79cfe33 100644 --- a/src/mesh/Plane.js +++ b/src/mesh/Plane.js @@ -58,9 +58,6 @@ var indices = []; var texture = this.texture; - // texture.width = 800 texture.width || 800; - // texture.height = 800//texture.height || 800; - var segmentsXSub = this.segmentsX - 1; var segmentsYSub = this.segmentsY - 1; var i = 0; @@ -106,6 +103,8 @@ this.uvs = new Float32Array(uvs); this.colors = new Float32Array(colors); this.indices = new Uint16Array(indices); + + this.indexDirty = true; }; /** diff --git a/src/mesh/Mesh.js b/src/mesh/Mesh.js index 1ccbfda..f6490b4 100644 --- a/src/mesh/Mesh.js +++ b/src/mesh/Mesh.js @@ -59,6 +59,7 @@ * @member {boolean} */ this.dirty = true; + this.indexDirty = true; /** * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. @@ -172,12 +173,22 @@ .addAttribute(glData.uvBuffer, glData.shader.attributes.aTextureCoord, gl.FLOAT, false, 2 * 4, 0); this._glDatas[renderer.CONTEXT_UID] = glData; + + + this.indexDirty = false; } if(this.dirty) { this.dirty = false; glData.uvBuffer.upload(); + + } + + if(this.indexDirty) + { + this.indexDirty = false; + glData.indexBuffer.upload(); } glData.vertexBuffer.upload(); diff --git a/src/mesh/Plane.js b/src/mesh/Plane.js index 9fddbd8..79cfe33 100644 --- a/src/mesh/Plane.js +++ b/src/mesh/Plane.js @@ -58,9 +58,6 @@ var indices = []; var texture = this.texture; - // texture.width = 800 texture.width || 800; - // texture.height = 800//texture.height || 800; - var segmentsXSub = this.segmentsX - 1; var segmentsYSub = this.segmentsY - 1; var i = 0; @@ -106,6 +103,8 @@ this.uvs = new Float32Array(uvs); this.colors = new Float32Array(colors); this.indices = new Uint16Array(indices); + + this.indexDirty = true; }; /** diff --git a/src/mesh/Rope.js b/src/mesh/Rope.js index c3fc687..0d7b95b 100644 --- a/src/mesh/Rope.js +++ b/src/mesh/Rope.js @@ -125,6 +125,7 @@ } this.dirty = true; + this.indexDirty = true; }; /** @@ -134,6 +135,7 @@ */ Rope.prototype._onTextureUpdate = function () { + Mesh.prototype._onTextureUpdate.call(this); // wait for the Rope ctor to finish before calling refresh