# Get a 3d cube made of cubes to expand from the center

**URL:** https://discourse.processing.org/t/get-a-3d-cube-made-of-cubes-to-expand-from-the-center/31220
**Category:** Coding Questions
**Created:** [July 12, 2021, 11:56pm UTC](https://discourse.processing.org/t/get-a-3d-cube-made-of-cubes-to-expand-from-the-center/31220 "2021-07-12T23:56:44Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![LuluLuna](https://avatars.discourse-cdn.com/v4/letter/l/87869e/32.png) [@LuluLuna](https://discourse.processing.org/u/LuluLuna)
#### Post date: [July 12, 2021, 11:56pm UTC](https://discourse.processing.org/t/get-a-3d-cube-made-of-cubes-to-expand-from-the-center/31220/1 "2021-07-12T23:56:44Z")

</div>

Hello, I made this sketch  
[Link to sketch](https://editor.p5js.org/lunalcampbell/sketches/wkZCkSJ6_)  
as you can see its a cube made of smaller cubes that expand and retract using sin.  
My problem is that the smaller cubes expand and retract from the corner cube and not from the center cube.

---

<div class="post-metadata">

### Author: ![KumuPaul](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kumupaul/32/13072_2.png) [@KumuPaul](https://discourse.processing.org/u/KumuPaul)
#### Post date: [July 13, 2021, 1:25am UTC](https://discourse.processing.org/t/get-a-3d-cube-made-of-cubes-to-expand-from-the-center/31220/2 "2021-07-13T01:25:41Z")

</div>

Your initial translation needs to be relative to the currently calculated gap:

```auto
  translate(-(gap + 40) * 4.5, -(gap + 40) * 4.5, -(gap + 40) * 4.5);

```
