ManimCommunity / ManimCommunity/manim

add_fixed_orientation_mobjects fails with MathTex

Open
#4,645 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## Description of bug / unexpected behavior

It seems like add_fixed_orientation_mobjects does not work with MathTex (or maybe I'm using it badly?) as the object is rotated.

## Expected behavior

The text should not be rotated.

## How to reproduce the issue

Code for reproducing the problem

```py
from manim import *

class Tests(ThreeDScene):
def construct(self):
sphere = Surface(
lambda u, v: R * np.array([
np.sin(v) * np.cos(u),
np.cos(v),
np.sin(v) * np.sin(u),
]),
u_range=[0, TAU], v_range=[0, PI],
resolution=(36, 18),
fill_color=BLUE_D, fill_opacity=0.0,
stroke_color=BLUE_E, stroke_width=0.4, stroke_opacity=0.6,
)
labels = MathTex(r"|0\rangle")
self.add_fixed_orientation_mobjects(labels)
self.play(Create(sphere, lag_ratio=0.01))
self.play(sphere.animate.set_fill(BLUE_D, opacity=0.30))
# Move "up" a bit:
self.move_camera(
phi=-20 * DEGREES,
added_anims = [
],
run_time=3.0, rate_func=smooth)
## Rotate around Y axis (move_camera is too hard to use if not around z axis)
self.play(
Rotate(
VGroup(m for m in self.mobjects if isinstance(m, (VMobject, Surface))),
PI/4,
[0,1,0],
about_point=ORIGIN,
),
run_time=3.0,
rate_func=smooth
)
self.wait(0.3)

```

## Additional media files

Images/GIFs

https://github.com/user-attachments/assets/810175e6-b996-446a-903f-82f19e1d8596

## Logs
Terminal output

```
PASTE HERE OR PROVIDE LINK TO https://pastebin.com/ OR SIMILAR
```

## System specifications

System Details

- OS (with version, e.g., Windows 10 v2004 or macOS 10.15 (Catalina)): Linux NixOs 25.11
- RAM:
- Python version (`python/py/python3 --version`): 3.13.19
- Installed modules (provide output from `pip list`):
```
PASTE HERE
```

LaTeX details

+ LaTeX distribution (e.g. TeX Live 2020):
+ Installed LaTeX packages:

## Additional comments

**EDIT** My guess is that there is a clash with the rotation that wants to be applied twice… So far my trick is not to use `add_fixed_orientation_mobject`, instead I use a dummy point to track the location and `always_redraw` to place the point at the coordinate of the dummy point with the rotation I want, like this:
```
class Tests(ThreeDScene):
def construct(self):
sphere = Surface(
lambda u, v: R * np.array([
np.sin(v) * np.cos(u),
np.cos(v),
np.sin(v) * np.sin(u),
]),
u_range=[0, TAU], v_range=[0, PI],
resolution=(36, 18),
fill_color=BLUE_D, fill_opacity=0.0,
stroke_color=BLUE_E, stroke_width=0.4, stroke_opacity=0.6,
)
labelp = Circle(0).move_to(label_pos(0, 2))
labels = always_redraw(lambda: MathTex(r"|0\rangle").move_to(labelp))
self.add(labels)
self.add(labelp)
self.play(Create(sphere, lag_ratio=0.01))
self.play(sphere.animate.set_fill(BLUE_D, opacity=0.30))
# Move "up" a bit:
self.move_camera(
phi=-20 * DEGREES,
added_anims = [
],
run_time=3.0, rate_func=smooth)
## Rotate around Y axis (move_camera is too hard to use if not around z axis)
self.play(
Rotate(
VGroup(m for m in self.mobjects if isinstance(m, (VMobject, Surface)) and m != labels),
PI/4,
[0,1,0],
about_point=ORIGIN,
),
run_time=3.0,
rate_func=smooth
)
self.wait(0.3)
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided ThreeDScene reproduction and trace add_fixed_orientation_mobjects with MathTex during move_camera and the later Rotate animation. Compare the orientation handling for MathTex with the other objects in the example; done means the MathTex label stays unrotated while the scene and camera move as shown.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.