ManimGL Scenes
Scene Types
ManimGL provides several scene types:
InteractiveScene (Recommended)
The default for most development. Supports interactive mode with -se flag.
from manimlib import *
class MyScene(InteractiveScene):
def construct(self):
circle = Circle()
self.play(ShowCreation(circle))
self.wait()Scene (Base Class)
Basic scene without interactive features:
class BasicScene(Scene):
def construct(self):
self.play(Write(Text("Hello")))ThreeDScene
For 3D animations with proper camera setup:
from manimlib import *
class My3DScene(ThreeDScene):
def construct(self):
axes = ThreeDAxes()
self.add(axes)
self.camera.frame.reorient(-45*DEGREES, 75*DEGREES)The construct Method
All scene logic goes in construct():
class MyScene(InteractiveScene):
def construct(self):
# 1. Create mobjects
circle = Circle(color=BLUE)
square = Square(color=RED)
# 2. Position them
circle.shift(LEFT * 2)
square.shift(RIGHT * 2)
# 3. Animate
self.play(ShowCreation(circle), ShowCreation(square))
# 4. Wait for viewer
self.wait(2)Adding vs Playing
# Static add (instant, no animation)
self.add(circle)
# Animated add
self.play(ShowCreation(circle))
self.play(FadeIn(square))Scene Methods
| Method | Description |
|---|---|
self.play(*anims) |
Play animations |
self.wait(t) |
Wait t seconds |
self.add(*mobs) |
Add mobjects instantly |
self.remove(*mobs) |
Remove mobjects |
self.clear() |
Clear all mobjects |
self.embed() |
Drop into IPython shell |
Interactive Mode
Run with -se flag to enter at a specific line:
manimgl scene.py MyScene -se 15In the shell:
checkpoint_paste() # Run clipboard code with animations
checkpoint_paste(skip=True) # Run instantly
checkpoint_paste(record=True) # Record while runningClass Attributes
Define scene configuration as class attributes:
class MyScene(InteractiveScene):
camera_class = ThreeDCamera # Use 3D camera
random_seed = 42 # For reproducibility
def construct(self):
...