3D Animation with OpenSCAD
Or… An easy way to get into 3D model generation and animation — programmatically.
TL;DR¹
OpenSCAD is an application that allows the programmatic generation of 3D models, and has a mode that allows the models to be animated easily.
Just keep an eye on the ‘special variable’
$t
which is the key to animation in OpenSCAD.In animation mode the special variable
$t
automatically increments from a 0 (zero) value to 1 (one) and is used to compute the steps within the animation. This variable can be used as an input to various things — camera rotation, translation, and distance, along with using it for input to the modelling.Additionally, for the purposes of this article — I also go through converting the output images to an animated gif — with an optional step for converting that to a movie file.
Table of Contents
Send In The Clowns
— The OpenSCAD interface
— The Code
— The $t special variable
— How the $t special variable changes
— Entering animation mode
A Slightly More Advanced Example
— Final Note
Generating Animated Gifs And Movies
— A Note On File Sizes
— 1. Resize the images
— 2. Convert the frames to an animated gif
— 3. (Optionally) Convert to a movie
— All Too Hard?
Colophon