hi Francesco,

the problem is with the order of the transformations.

consider the following:
(with-state
    (translate (vector 3 0 0))
    (rotate (vector 0 180 0))
    (build-cube))

this code actually rotates the cube first, then translates it.
and you get a different result, if you swap the translation and the rotation.

in your code, the animated rotation happens before the scale actually, because this is how the transformations are applied: rotate +1, scale, rotate 270. and if you rotate then scale, you skew the cylinder.

there are a couple of solutions how you can solve this. for example, you don't use any transformations when creating the object, then use (identity) every frame, which initializes the transformations and you set it up again from there using (time) to calculate the rotation angle.

(define faccia
    (with-state
        (build-cylinder 100 12)))

(define (animate)
    (with-primitive faccia
        (identity)
        (rotate (vector 0 (* 30 (time)) 90))
        (scale (vector 1 0.1 1))))

best,
gabor

Reply via email to