diff --git a/src/webgl/p5.RendererGL.Immediate.js b/src/webgl/p5.RendererGL.Immediate.js index 9c47730078..5a2beaf990 100644 --- a/src/webgl/p5.RendererGL.Immediate.js +++ b/src/webgl/p5.RendererGL.Immediate.js @@ -201,6 +201,15 @@ p5.RendererGL.prototype.endShape = function( ); return this; } + // When we are drawing a shape then the shape mode is TESS, + // but in case of triangle we can skip the breaking into small triangle + // this can optimize performance by skipping the step of breaking it into triangles + if (this.immediateMode.geometry.vertices.length === 3 && + this.immediateMode.shapeMode === constants.TESS + ) { + this.immediateMode.shapeMode === constants.TRIANGLES; + } + this.isProcessingVertices = true; this._processVertices(...arguments); this.isProcessingVertices = false;