Displaying Skeleton from Array on Each Key Press

Hi folks;

I am expanding on a previous project that was displaying a 2D shape overtop of live video, but as I learn Processing, I’ve expanded to trying 3D shapes. In particular, I’m using the ISO Skeleton. Now, the issue that I’m having is that I want it so that every time I press the spacebar a new random shape (based on the parameters) shows up; however, currently, every time I press the spacebar, the shape remains the same. I believe that the error might have to do with line 39 where I use the vertex line because if I enclose the shape I’m trying to make with beginShape(); and endShape(CLOSE); (lines 36 & 48), then it works though with very angular shapes (which I do not want). Any assistance would be much appreciated!

import ComputationalGeometry.*;
IsoSkeleton skeleton;

import processing.video.*;
Capture video;

IntList inventory = new IntList();
boolean makeShape = false;
PVector[] pts = new PVector [30];

void captureEvent(Capture video) {
  video.read();
}

void setup() {
  fullScreen(P3D);
  video = new Capture(this, width, height);
  video.start();
  for (int i = 0; i < pts.length; i++) {
    pts[i] = new PVector(random(100, 300), random(100, 300), random(80, 100));
    inventory.append(i);
  }
}

void draw() {
  image(video, 0, 0);
  noStroke();
  lights();
  if (makeShape) {
    makeSkeleton();
  }
}

void makeSkeleton() {
  skeleton = new IsoSkeleton(this);
  //beginShape();
  for (int i = 0; i < pts.length; i++) {
    int index = inventory.get(i);
    vertex(pts[index].x, pts[index].y, pts[index].z);
  }
  for (int i=0; i<pts.length; i++) {
    for (int j=i+1; j<pts.length; j++) {
      if (pts[i].dist( pts[j] ) < 50) {
        skeleton.addEdge(pts[i], pts[j]);
      }
    }
  }
  //endShape(CLOSE);
  skeleton.plot(10.f * 250 / (2.0f*width), 250 / (2.0*height));

  if (key == 's') {
    save(millis() + ".png");
  }
}

void keyPressed() {
  if (key == ' ') {
    makeShape = !makeShape;
    inventory.shuffle();
    fill(random(255), random(255), random(255));
  }
}