# Animating a 3d shape in Pyprocessing

**URL:** <https://discourse.processing.org/t/animating-a-3d-shape-in-pyprocessing/11066>\
**Category:** Processing.py\
**Created:** [May 9, 2019, 12:14pm UTC](https://discourse.processing.org/t/animating-a-3d-shape-in-pyprocessing/11066 "2019-05-09T12:14:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Avatrin](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@Avatrin](https://discourse.processing.org/u/Avatrin)\
**Post date:** [May 9, 2019, 12:14pm UTC](https://discourse.processing.org/t/animating-a-3d-shape-in-pyprocessing/11066/1 "2019-05-09T12:14:01Z")

</div>

Hi  
I cannot find any animation tutorials on the Pyprocessing website. If I wanted to animate this pyramid from the 3d shape tutorial on that website, how can I go about doing that?

def drawShape():  
translate(width/2, height/2, 0)  
stroke(255)  
rotateX(PI/2)  
rotateZ(-PI/6)  
noFill()

```
beginShape()
vertex(-100, -100, -100)
vertex( 100, -100, -100)
vertex( 0, 0, 100)

vertex( 100, -100, -100)
vertex( 100, 100, -100)
vertex( 0, 0, 100)

vertex( 100, 100, -100)
vertex(-100, 100, -100)
vertex( 0, 0, 100)

vertex(-100, 100, -100)
vertex(-100, -100, -100)
vertex( 0, 0, 100)
endShape()
```

---

<div class="post-metadata">

**Author:** ![tabreturn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tabreturn/32/3697_2.png) [@tabreturn](https://discourse.processing.org/u/tabreturn)\
**Post date:** [May 9, 2019, 8:39pm UTC](https://discourse.processing.org/t/animating-a-3d-shape-in-pyprocessing/11066/2 "2019-05-09T20:39:24Z")

</div>

You’ll need a `setup()` and `draw()` function:

```auto
def setup():
    size(600,600, P3D)

r = 0

def draw():
    global r
    background('#FFFFFF')
    translate(width/2, height/2, 0)
    rotateX(r)
    rotateZ(r)

    beginShape()
    vertex(-100, -100, -100)
    ...
    endShape()

    r += 0.01

```

---

<div class="post-metadata">

**Author:** ![Avatrin](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@Avatrin](https://discourse.processing.org/u/Avatrin)\
**Post date:** [May 9, 2019, 8:45pm UTC](https://discourse.processing.org/t/animating-a-3d-shape-in-pyprocessing/11066/3 "2019-05-09T20:45:23Z")

</div>

Thank you so much!! I’ve been looking for this for such a long while!!
