Cube explosion when clicking inside the cube

Hello everyone, in my sketch I am using WEBGL and ScreenPosition js to create a new cube whenever the mouse X , mouseY co-ordinates are inside the cube. I am currently trying to make the cube explode when the above condition is met. I went through the particles.js demo from coding train to understand it better. However I am not sure what is the way to solve this. Currently from the sketch , I can create a smaller cube from particle.js( just for my visualization) which follows the main bigger cube.

This is different to what I want to achieve that is to , make the cube explode and the particles should be created out of the reference cube . (Basically the bigger box distinegrating to smaller pieces / chunks) . Any hints /suggestions as how to tackle this would be highly appreciated .

Trial sketch is here : p5.js Web Editor

Best T

1 Like

Hi again
I was wondering if the source of explosion is the original cube does it make sense to have classes ? I am a bit lost on that . Maybe I am over complicating things here . Any suggestions ?