Repository navigation
Animation
BelfrySCAD implements OpenSCAD's $t animation. Open the pane with F9, the toolbar's Animate button, or Window ▸ Show Animate.
$t is a special variable that runs from 0 toward 1 over one cycle. Your script reads it and positions things accordingly. Each frame is a full Preview with a different $t.
// A spinning part
rotate([0, 0, $t * 360]) my_part();
// A piston
translate([0, 0, 20 * sin($t * 360)]) piston();
// An exploded view that assembles and comes apart
d = 40 * (1 - abs(2*$t - 1));
translate([0,0, d]) lid();
body();
translate([0,0, -d]) base();$t = step / steps for step in 0 … steps−1, so the cycle reaches 1 − 1/steps and never 1. That's what keeps rotate([0,0,$t*360]) from hitching as it wraps — frame 0 and frame steps would otherwise be identical.
| Field | |
|---|---|
| Time | The current $t. Type a value to jump to the nearest step |
| FPS | Playback rate, 1–1000 |
| Steps | Frames in one cycle, 1–1,000,000 |
Tab and ⇧Tab move between the three fields; Enter confirms.
Transport: First · Previous · Play · Pause · Next · Last. Play and Pause stay pressed in to show which one is in effect. Any transport action other than Play pauses first.
The wait cursor isn't shown during playback, so the controls stay usable while frames render.
Tick Dump Pictures before pressing Play, and playback starts from the first frame. You'll be asked for a destination folder each time (starting in the last dump's folder, else the script's own), before the first frame is rendered; cancelling stops playback. Then each frame of one full cycle is written as frameNNNN.png.
You can also tick it while the animation is playing: playback holds while you pick the folder, then one full cycle is saved starting from the frame it was on (at $t = 0.4 with 10 steps, frame0004.png comes first) and ending back at that frame. Cancelling the folder unticks the box and lets playback carry on; unticking it part-way through stops the dump there. While dumping, each frame waits for its render, so playback runs at render speed rather than the FPS set.
After the last frame, as in OpenSCAD, Dump Pictures unticks itself and playback carries on at the set FPS without writing any more frames. Pause when you've seen enough; tick it again to dump another cycle.
Frames are the viewport exactly as shown, on the viewport's background colour — never a transparent background.
Turn them into a video with ffmpeg:
ffmpeg -framerate 30 -i frame%04d.png -c:v libx264 -pix_fmt yuv420p out.mp4
ffmpeg -framerate 30 -i frame%04d.png -vf "scale=640:-1" out.gifHeadless, without opening a window:
belfryscad -o frame.png --animate 60 model.scad
belfryscad -o out.stl --animate 24 --animate_dir ./frames model.scadFrames are named {stem}{00000…N-1}{ext}. See Command Line.
- The camera stays put during playback. Unlike a normal render, frames don't auto-fit to the model's bounding box — otherwise the camera would lurch every time the model's extents changed. Frame your shot first, then press Play.
- Animation re-renders whichever file tab is currently visible.
- A slow model means slow playback: each frame is a full CSG render. Drop
$fn, or reduce Steps, while you get the motion right. - At rest (not playing),
$tis0. - Frames that don't depend on
$tare cache hits, so the parts of your model that don't move cost nothing to re-render.
Start here
Using the app
- Code Editor
- Viewport and Navigation
- Rendering
- Render Performance
- Debugger
- Customizer
- Animation
- Demo Scripts
- Data Viewers
- AI Chat
- Libraries
- Fonts
- Colors
- Exporting
- Testing and Coverage
- Documentation Generation
- Preferences
- Command Line
- Troubleshooting
Language reference