# Cube explosion when clicking inside the cube

**URL:** <https://discourse.processing.org/t/cube-explosion-when-clicking-inside-the-cube/36573>\
**Category:** Coding Questions\
**Created:** [April 24, 2022, 3:12pm UTC](https://discourse.processing.org/t/cube-explosion-when-clicking-inside-the-cube/36573 "2022-04-24T15:12:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Timo](https://avatars.discourse-cdn.com/v4/letter/t/c4cdca/32.png) [@Timo](https://discourse.processing.org/u/Timo)\
**Post date:** [April 24, 2022, 3:12pm UTC](https://discourse.processing.org/t/cube-explosion-when-clicking-inside-the-cube/36573/1 "2022-04-24T15:12:06Z")

</div>

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](https://editor.p5js.org/timtensor/sketches/sIAbQJAPj)

Best T

---

<div class="post-metadata">

**Author:** ![Timo](https://avatars.discourse-cdn.com/v4/letter/t/c4cdca/32.png) [@Timo](https://discourse.processing.org/u/Timo)\
**Post date:** [April 26, 2022, 2:13pm UTC](https://discourse.processing.org/t/cube-explosion-when-clicking-inside-the-cube/36573/2 "2022-04-26T14:13:15Z")

</div>

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 ?
