This browser has no WebGPU, so the sketch cannot run here. The program is below, and it runs in a current Chrome, Edge or Safari.

Particles Bounce

simple 3D particle system

Open in new tab ↗ · formationsparticlessimulation

////////////////////////////////////////////////
// particles-bounce
// simple 3D particle system
////////////////////////////////////////////////
&dim = (128, 128);
// per-channel boolean for crossing the bounds
&hit = lrg(abs(add(#positions, #velocities)), 1.0);

#colors{
   dim = (8);
   set = rand(1,2,3);
} 

#positions {
   dim = &dim;
   set = srand(4,5,6); // initial random position
   run = add(#, #velocities); // move each particle
}

#velocities {
   dim = &dim;
   set = mlt(srand(7,8,9), 0.003);  // random initial velocity
   run = mlt(#, sub(1, mlt(&hit, 2))); // flip on wall hit
}

~particles {
   dim = &dim; 
   shape = ICO;
   col = #colors;
   i_pos = #positions;
   i_scl = (0.75);
}