diff --git a/packages/core/src/geometry/GeometrySystem.js b/packages/core/src/geometry/GeometrySystem.js index b2a3ad0..3b83a89 100644 --- a/packages/core/src/geometry/GeometrySystem.js +++ b/packages/core/src/geometry/GeometrySystem.js @@ -289,7 +289,9 @@ } /** - * Creates a Vao with the same structure as the geometry and stores it on the geometry. + * Creates or gets Vao with the same structure as the geometry and stores it on the geometry. + * If vao is created, it is bound automatically. + * * @protected * @param {PIXI.Geometry} geometry - Instance of geometry to to generate Vao for * @param {PIXI.Program} program - Instance of program @@ -390,7 +392,7 @@ this.activateVao(geometry, program); - gl.bindVertexArray(this._activeVao); + this._activeVao = vao; // add it to the cache! vaoObjectHash[program.id] = vao; @@ -474,7 +476,13 @@ // delete only signatures, everything else are copies if (vaoId[0] === 'g') { - gl.deleteVertexArray(vaos[vaoId]); + const vao = vaos[vaoId]; + + if (this._activeVao === vao) + { + this.unbind(); + } + gl.deleteVertexArray(vao); } } }