From 5f316067658faf500d1d5b107d5e7af488440983 Mon Sep 17 00:00:00 2001 From: Dave Pagurek Date: Thu, 17 Apr 2025 11:43:33 -0400 Subject: [PATCH 1/2] Fix spline() with z values + initial beginShape colors not updating --- src/core/p5.Renderer.js | 26 +++++++++++++++++++------- src/webgl/p5.RendererGL.js | 1 - 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/core/p5.Renderer.js b/src/core/p5.Renderer.js index 5b156f0155..4f3bcc70fb 100644 --- a/src/core/p5.Renderer.js +++ b/src/core/p5.Renderer.js @@ -184,6 +184,7 @@ class Renderer { beginShape(...args) { this.currentShape.reset(); + this.updateShapeVertexProperties(); this.currentShape.beginShape(...args); } @@ -224,13 +225,24 @@ class Renderer { return this; } - spline(x1, y1, x2, y2, x3, y3, x4, y4) { - this._pInst.beginShape(); - this._pInst.splineVertex(x1, y1); - this._pInst.splineVertex(x2, y2); - this._pInst.splineVertex(x3, y3); - this._pInst.splineVertex(x4, y4); - this._pInst.endShape(); + spline(...args) { + if (args.length === 2 * 4) { + const [x1, y1, x2, y2, x3, y3, x4, y4] = args; + this._pInst.beginShape(); + this._pInst.splineVertex(x1, y1); + this._pInst.splineVertex(x2, y2); + this._pInst.splineVertex(x3, y3); + this._pInst.splineVertex(x4, y4); + this._pInst.endShape(); + } else if (args.length === 3 * 4) { + const [x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4] = args; + this._pInst.beginShape(); + this._pInst.splineVertex(x1, y1, z1); + this._pInst.splineVertex(x2, y2, z2); + this._pInst.splineVertex(x3, y3, z3); + this._pInst.splineVertex(x4, y4, z4); + this._pInst.endShape(); + } return this; } diff --git a/src/webgl/p5.RendererGL.js b/src/webgl/p5.RendererGL.js index a5ea3b85a9..f7b1079213 100644 --- a/src/webgl/p5.RendererGL.js +++ b/src/webgl/p5.RendererGL.js @@ -1174,7 +1174,6 @@ class RendererGL extends Renderer { } getCommonVertexProperties() { - if (!this.states) debugger; return { ...super.getCommonVertexProperties(), stroke: this.states.strokeColor, From 92e579dcf60f72d21af62266e4249db657512419 Mon Sep 17 00:00:00 2001 From: Dave Pagurek Date: Thu, 17 Apr 2025 11:54:57 -0400 Subject: [PATCH 2/2] Fix fill color getting set to true --- src/webgl/material.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/webgl/material.js b/src/webgl/material.js index a2a93416fe..c7aeb1cb6e 100644 --- a/src/webgl/material.js +++ b/src/webgl/material.js @@ -3117,7 +3117,9 @@ function material(p5, fn){ this._renderer.states.setValue('curAmbientColor', color._array); this._renderer.states.setValue('_useNormalMaterial', false); this._renderer.states.setValue('enableLighting', true); - this._renderer.states.setValue('fillColor', true); + if (!this._renderer.states.fillColor) { + this._renderer.states.setValue('fillColor', new Color([1, 1, 1])); + } return this; };