PShape translate xyz

I am desperately trying to find a workaround for a problem I’ve had for quite a while now with a PShape group (thisModel) that has 60000 BOX PShapes in it in retained mode. When I translate each BOX the program is very slow. (15 fps) here is a simplified version of the problem, the variables w, h, r, g, b are not included


for (int i = 0; i < 60000; i++) {
PShape cube = createShape(BOX, w,h,w);


shapes = thisModel.getChildren();

for (int i = 0; i < shapes.length; i++) {
shapes[i].setFill(r, g, b);
shapes[i].translate(x, y, z);

translate is slowing everything down. i’ve read that there are probably problems with various aspects of the matrix transformations.
does anyone know how to do the same thing another faster way ? in opengl directly ?
i wrote it in 151 with GLGraphics and it runs very smoothly at 60fps but i need to port it to P3 (Java 8) as soon as possible. any help would be great !

1 Like

hi COCO,
is this a BUMP of
P3D performance with 62500 boxes ?

again you post some sniplets ( from your very long code… )

  • a- could you format it using the
</> code formatter
  • b- could you make it a small but complete code what we can copy and run
    ( to verify it on other OS’s and hardware )
    ++like including variable settings, setup() / draw()
  • c- what is the difference to your last post?
    besides you lost 2500 boxes?

the performance might not only go by the number of boxes ?children?
also with the canvas setup ( size / fullScreen / smooth )

i understand that you are disappointed ( testing several recent processing versions )
but did you check on the open points from ?
or report it there?


@kil thanks for your response.

yes i did bump the post in my desperate pursuit to find a workaround because translate is still unfortunately very slow even in version 3.5.3.

here’s a very simplified version (in 151 + GLGraphics it runs at over 60fps)

PShape thisModel;
PShape[] shapes;

int savedTime;
int totalTime = 1000;

public void settings() {
void setup() {
  fill(255, 0, 0);
  savedTime = millis();

  thisModel = createShape(GROUP);
  for (int i = 0; i < 62500; i++) {
    PShape cube = createShape(BOX, 1, 1, 1);
   shapes = thisModel.getChildren();

void draw() {
  for (int i = 0; i < shapes.length; i++) {
    shapes[i].translate(random(width), random(height), -300);
  int passedTime = millis() - savedTime;
  if (passedTime > totalTime) {
    savedTime = millis();

And yes there is an issue reported

1 Like

I’m not sure. The only other approach that comes to mind (not performance tested) is to call shape on the children directly, and specific the random location coordinates for each child shape at draw time. This means the child shape matrix is never updated and never needs to be reset – which might be faster…?:

void draw() {
  for (int i = 0; i < shapes.length; i++) {
    shape(shapes[i], random(width), random(height));

in fact it is even slower… 6fps but thanks

Did you increase memory in the preferences

yes i did, but it didn’t change anything