mcpField
M
manimgl-best-practices

manimgl-best-practices

github.com/calesthioクリエイティブ・メディア73.0k1.1k 回インストール1 日前に更新
リポジトリ

manimgl-best-practices について

アニメーションシーン、数学ビジュアル、3D コンテンツの制作に役立つ、ManimGL のルール、例、テンプレートをまとめたスキルです。ManimGL ユーザー向けに、インタラクティブな開発やアニメーション、テキスト、カメラ操作、CLI を解説します。

主な機能

  1. 01シーンと Mobject のガイド
  2. 02アニメーションと変換のパターン
  3. 03テキスト・LaTeX・スタイルの資料
  4. 043D オブジェクトとカメラ操作
  5. 05対話型ワークフローと CLI の例

活用シーン

  1. 01数学の解説アニメーション制作
  2. 02グラフ描画と数式の可視化
  3. 03シーンの対話的な開発と確認
  4. 04再利用可能なテンプレートからの作成

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/calesthio/openmontage --skill manimgl-best-practices

インストール後、Claude Code で/manimgl-best-practicesを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

examples/
attention_arcs_animation.py
attention_pattern_dots.py
attention_scenes.py
attention_softmax_masking.py
autoregressive_flow.py
basic_multihead.py
bloch_sphere_3d.py
block_collision_basic.py
blocks_3d.py
collision_phase_space.py
complex_s_plane.py
cost_function.py
cube_projection_3d.py
damped_solutions_splane.py
dot_product_visualization.py
double_slit_interference.py
eigenvalue_equations.py
eigenvector_flow_field.py
eigenvector_matrix_transformation.py
elastic_collision_vectors.py
embedding_matrix.py
equation_transforms.py
exponential_derivative.py
fibonacci_eigenvalues.py
gradient_descent_basic.py
hexagon_cube_correspondence.py
integration_visualization.py
laplace_integral.py
light_polarization.py
linear_regression.py

詳細

使い方

詳しい説明とコード例については、各ルールファイルをお読みください。

コアコンセプト
作成と変形
テキストと数学
  • rules/tex.md - Tex クラス、raw strings R"..."、LaTeX レンダリング
  • rules/text.md - Text Mobject、フォント、スタイル設定
  • rules/t2c.md - 数式表現の色付けに使う tex_to_color_map (t2c)
スタイルと外観
  • rules/colors.md - 色定数、グラデーション、RGB、hex、GLSL による色付け
  • rules/styling.md - 塗りつぶし、線、透明度、背面の縁取り、光沢、影
3D とカメラ
  • rules/3d.md - 3D オブジェクト、曲面、Sphere、Torus、パラメトリック曲面、ライティング
  • rules/camera.md - frame.reorient()、オイラー角、fix_in_frame()、カメラアニメーション
インタラクティブ開発
設定と CLI
  • rules/cli.md - manimgl コマンド、フラグ(-w、-o、-se、-l、-h)、レンダリングオプション
  • rules/config.md - custom_config.yml、ディレクトリ、カメラ設定、品質プリセット

動作例

よく使われるパターンを紹介する、完全かつテスト済みのサンプルファイルです。

シーンテンプレート

新しいプロジェクトを始める際に、これらのテンプレートをコピーして変更してください。

クイックリファレンス

基本的なシーン構造
from manimlib import *

class MyScene(InteractiveScene):
    def construct(self):
        # Create mobjects
        circle = Circle()

        # Add to scene (static)
        self.add(circle)

        # Or animate
        self.play(ShowCreation(circle))  # Note: ShowCreation, not Create

        # Wait
        self.wait(1)
レンダリングコマンド
# Render and preview
manimgl scene.py MyScene

# Interactive mode - drop into shell at line 15
manimgl scene.py MyScene -se 15

# Write to file
manimgl scene.py MyScene -w

# Low quality for testing
manimgl scene.py MyScene -l
ManimCE との主な違い
機能ManimGL (3b1b)Manim Community
インポートfrom manimlib import *from manim import *
CLImanimglmanim
数式テキストTex(R"\pi")MathTex(r"\pi")
シーンInteractiveSceneScene
作成アニメーションShowCreationCreate
カメラself.frameself.camera.frame
フレームに固定mob.fix_in_frame()self.add_fixed_in_frame_mobjects(mob)
パッケージmanimgl (PyPI)manim (PyPI)
インタラクティブ開発ワークフロー

ManimGL の最大の特長は、インタラクティブに開発できることです。

# Start at line 20 with state preserved
manimgl scene.py MyScene -se 20

インタラクティブモードでは:

# Copy code to clipboard, then run:
checkpoint_paste()           # Run with animations
checkpoint_paste(skip=True)  # Run instantly (no animations)
checkpoint_paste(record=True) # Record while running
カメラ制御(self.frame)
# Get the camera frame
frame = self.frame

# Reorient in 3D (phi, theta, gamma, center, height)
frame.reorient(45, -30, 0, ORIGIN, 8)

# Animate camera movement
self.play(frame.animate.reorient(60, -45, 0))

# Fix mobjects to stay in screen space during 3D movement
title.fix_in_frame()
Tex クラスでの LaTeX
# Use raw strings with capital R
formula = Tex(R"\int_0^1 x^2 \, dx = \frac{1}{3}")

# Color mapping with t2c
equation = Tex(
    R"E = mc^2",
    t2c={"E": BLUE, "m": GREEN, "c": YELLOW}
)

# Isolate substrings for animation
formula = Tex(R"\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}")
formula.set_color_by_tex("n", BLUE)
よく使われるパターン
デバッグ用の埋め込み
def construct(self):
    circle = Circle()
    self.play(ShowCreation(circle))
    self.embed()  # Drops into IPython shell here
3D 用の床面を設定する
self.set_floor_plane("xz")  # Makes xy the viewing plane
テキストを読みやすくする背面の縁取り
text = Text("Label")
text.set_backstroke(BLACK, 5)  # Black outline behind text
インストール
# Install ManimGL
pip install manimgl

# Check installation
manimgl --version
避けるべきよくある落とし穴
  1. バージョンの混同 - manim(コミュニティ版)ではなく、manimglを使用していることを確認してください
  2. ShowCreation と Create - ManimGL ではCreateではなく、ShowCreationを使用します
  3. Tex と MathTex - ManimGL では、大文字の R を使った raw 文字列でTexを使用します
  4. self.frame と self.camera.frame - ManimGL では、self.frameを直接使用します
  5. fix_in_frame() - シーンではなく、mobject に対して呼び出してください
  6. インタラクティブモード - インタラクティブな開発には-seフラグを使用してください

ライセンスとクレジット

このスキルには、Grant Sanderson による3Blue1Brown の動画リポジトリをもとに改変したサンプルコードが含まれています。

ライセンス: CC BY-NC-SA 4.0

  • クレジット表記が必要 - 3Blue1Brown と改変者の両方を明記してください
  • 非営利 - 商用利用はできません
  • 継承 - 派生物には同じライセンスを適用する必要があります

詳細はLICENSE.txtを参照してください。

コメント