OpenSCAD User Manual/Animation

Animation Using the $t Special Variable

Simple harmonic motion, 20 FPS, 100 steps
Animated gears 17T and 31T

Animation is started by selecting the Window > Animate menu item and then entering values for "FPS" and "Steps" in the Animation Panel that opens. The "Time" field shows the current value of $t, the animation time variable, as a decimal fraction.

This variable, when active, is used in all rotate() and translate() modules, $t*360 giving complete cycles.

The value of $t will repeat from 0 through (1 - 1/Steps). It never reaches 1 because this would produce a "hitch" in the animation if using it for rotation -- two consecutive frames would be at the same angle.

There is no variable to distinguish between the cases of animation running at the first frame ($t=0) and animation not running, so make $t=0 your rest position for the model.

Examples of Animation Scripts