diff --git a/core/src/processing/core/PShape.java b/core/src/processing/core/PShape.java index dcb1a7621..40ec381f5 100644 --- a/core/src/processing/core/PShape.java +++ b/core/src/processing/core/PShape.java @@ -166,6 +166,8 @@ public class PShape implements PConstants { protected int emissiveColor; protected float shininess; + protected int sphereDetailU, sphereDetailV; + /** Temporary toggle for whether styles should be honored. */ protected boolean style = true; diff --git a/core/src/processing/opengl/PGraphics3D.java b/core/src/processing/opengl/PGraphics3D.java index a2288ceb5..a60641dac 100644 --- a/core/src/processing/opengl/PGraphics3D.java +++ b/core/src/processing/opengl/PGraphics3D.java @@ -277,7 +277,7 @@ public class PGraphics3D extends PGraphicsOpenGL { shape = new PShapeOpenGL(parent, PShape.PRIMITIVE); shape.setKind(BOX); } else if (kind == SPHERE) { - if (len != 1) { + if (len < 1 || 3 < len) { showWarning("Wrong number of parameters"); return null; } diff --git a/core/src/processing/opengl/PShapeOpenGL.java b/core/src/processing/opengl/PShapeOpenGL.java index 2ad97a479..e0fde4a2c 100644 --- a/core/src/processing/opengl/PShapeOpenGL.java +++ b/core/src/processing/opengl/PShapeOpenGL.java @@ -330,6 +330,9 @@ public class PShapeOpenGL extends PShape { emissiveColor = pg.emissiveColor; shininess = pg.shininess; + sphereDetailU = pg.sphereDetailU; + sphereDetailV = pg.sphereDetailV; + normalX = normalY = 0; normalZ = 1; @@ -2787,12 +2790,17 @@ public class PShapeOpenGL extends PShape { protected void tessellateSphere() { - // Getting sphere detail from renderer. Is this correct? - int nu = pg.sphereDetailU; - int nv = pg.sphereDetailV; float r = 0; - if (params.length == 1) { + int nu = sphereDetailU; + int nv = sphereDetailV; + if (1 <= params.length) { r = params[0]; + if (params.length == 2) { + nu = nv = (int)params[1]; + } else if (params.length == 3) { + nu = (int)params[1]; + nv = (int)params[2]; + } } inGeo.setMaterial(fillColor, strokeColor, strokeWeight,