Redeclaration of createShape in draw()

I am creating a sphere shape in setup following noStroke() so there are no triangles visible on the sphere. I am then displaying images on the globe, together with a grid pattern. Under certain circumstances, I would like to display the triangles, but if I redeclare createShape(SPHERE, 500) in draw() it creates a very dark image on the globe and the image wrapped on the globe is not visible. I have background(0) before the redeclaration.
Is it possible to redeclare createShape without causing the black out of the globe?


A minimal example of your formatted code would help.

Example at end of this tutorial was used:

In draw() I selected one of these before displaying the shape:

  globe.setStroke(color(255, 255, 0));
  //globe.setStroke(0); //transparent stroke



I also had to add this to example:
size(300, 300, P3D);



Thank you glv. I’ll try that when I get back later today.

Peter Turner

I had tried this previously, but initially noStroke() before declaring createShape resulted in still no stroke for both options. Even adding globe.setStrokeWeight(2); didn’t make them appear. Only by removing the initial noStroke(); does the stroke appear when calling globe.setStroke(255,255,0);

I assume that the initial noStroke() is permanent, and is not altered by subsequent calls to globe setStroke.

Thank you for your information, glv.

Peter Turner

It seems so.
This one is in my notes. :)

And you are welcome!

An example without the texture for the topic:

PShape globe;
boolean toggle = true;
void setup() 
  size(300, 300, P3D);
  // noStroke(); //Once set you can't use setStroke();
  globe = createShape(SPHERE, 100);
  println("Press a key to toggle setStroke()");
void draw()
  translate(width/2, height/2);
    globe.setStroke(color(255, 255, 0)); //yellow
    globe.setStroke(0); // 0 is  the same as color(0, 0, 0, 0) and transparent
  shape(globe,0, 0);
void keyPressed()
  toggle = !toggle;

PShape \ See last section for 3D and textures.