Animating a 3d shape in Pyprocessing

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()
1 Like

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

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
3 Likes

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