Skip to content

Commit b6d963f

Browse files
authored
Merge pull request #7750 from processing/fix/spline
Fix spline() with z values + initial beginShape colors not updating
2 parents b5a29d7 + 92e579d commit b6d963f

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

src/core/p5.Renderer.js

+19-7
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ class Renderer {
184184

185185
beginShape(...args) {
186186
this.currentShape.reset();
187+
this.updateShapeVertexProperties();
187188
this.currentShape.beginShape(...args);
188189
}
189190

@@ -224,13 +225,24 @@ class Renderer {
224225
return this;
225226
}
226227

227-
spline(x1, y1, x2, y2, x3, y3, x4, y4) {
228-
this._pInst.beginShape();
229-
this._pInst.splineVertex(x1, y1);
230-
this._pInst.splineVertex(x2, y2);
231-
this._pInst.splineVertex(x3, y3);
232-
this._pInst.splineVertex(x4, y4);
233-
this._pInst.endShape();
228+
spline(...args) {
229+
if (args.length === 2 * 4) {
230+
const [x1, y1, x2, y2, x3, y3, x4, y4] = args;
231+
this._pInst.beginShape();
232+
this._pInst.splineVertex(x1, y1);
233+
this._pInst.splineVertex(x2, y2);
234+
this._pInst.splineVertex(x3, y3);
235+
this._pInst.splineVertex(x4, y4);
236+
this._pInst.endShape();
237+
} else if (args.length === 3 * 4) {
238+
const [x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4] = args;
239+
this._pInst.beginShape();
240+
this._pInst.splineVertex(x1, y1, z1);
241+
this._pInst.splineVertex(x2, y2, z2);
242+
this._pInst.splineVertex(x3, y3, z3);
243+
this._pInst.splineVertex(x4, y4, z4);
244+
this._pInst.endShape();
245+
}
234246
return this;
235247
}
236248

src/webgl/material.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -3117,7 +3117,9 @@ function material(p5, fn){
31173117
this._renderer.states.setValue('curAmbientColor', color._array);
31183118
this._renderer.states.setValue('_useNormalMaterial', false);
31193119
this._renderer.states.setValue('enableLighting', true);
3120-
this._renderer.states.setValue('fillColor', true);
3120+
if (!this._renderer.states.fillColor) {
3121+
this._renderer.states.setValue('fillColor', new Color([1, 1, 1]));
3122+
}
31213123
return this;
31223124
};
31233125

src/webgl/p5.RendererGL.js

-1
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,6 @@ class RendererGL extends Renderer {
11741174
}
11751175

11761176
getCommonVertexProperties() {
1177-
if (!this.states) debugger;
11781177
return {
11791178
...super.getCommonVertexProperties(),
11801179
stroke: this.states.strokeColor,

0 commit comments

Comments
 (0)