ManimCommunity / manim

A community-maintained Python framework for creating mathematical animations.
https://www.manim.community
MIT License
25.85k stars 1.78k forks source link

`Variable` class does not get fixed in the in `ThreeDScene` with `add_fixed_in_frame_mobjects()` #2942

Open tapyu opened 2 years ago

tapyu commented 2 years ago

Description of bug / unexpected behavior

self.add_fixed_in_frame_mobjects(x) should fix the object x on the 2D screen while one works in a 3D Scene. In fact, it works when x is a Text class, as shown in the examples. But when x is a Variable class, its position changes when we perform the animation self.play(x.tracker.animate.set_value())

Expected behavior

x should remain on its place as we change the tracker value.

How to reproduce the issue

Code for reproducing the problem ```py from manim import * class FixedInFrameMObjectTest(ThreeDScene): def construct(self): axes = ThreeDAxes() self.set_camera_orientation(phi=75 * DEGREES, theta=-45 * DEGREES) self.play(Create(axes)) self.wait() text3d = Variable(0.3, MathTex("x")) text3d.to_corner(UL) self.add_fixed_in_frame_mobjects(text3d) self.play(Write(text3d)) self.wait() self.play(text3d.tracker.animate.set_value(1)) self.wait() ```

Additional media files

Images/GIFs ![FixedInFrameMObjectTest_ManimCE_v0 16 0 post0](https://user-images.githubusercontent.com/22801918/188655988-f41d45d4-2f21-4253-9b0b-66466b28ccf8.gif)

Logs

Terminal output ``` ❯ manim -ql -p test.py Manim Community v0.16.0.post0 [09/06/22 12:21:48] INFO Animation 0 : Using cached data (hash : cairo_renderer.py:75 166007114_155735041_223132457) [09/06/22 12:21:49] INFO Animation 1 : Using cached data (hash : cairo_renderer.py:75 723241031_3315967912_2417228262) [09/06/22 12:21:50] INFO Animation 2 : Using cached data (hash : cairo_renderer.py:75 723241031_1815128715_1682129457) [09/06/22 12:21:51] INFO Animation 3 : Using cached data (hash : cairo_renderer.py:75 723241031_3315967912_3582625705) [09/06/22 12:21:52] INFO Animation 4 : Using cached data (hash : cairo_renderer.py:75 723241031_3076078580_3009176059) [09/06/22 12:21:53] INFO Animation 5 : Using cached data (hash : cairo_renderer.py:75 723241031_3315967912_4108828480) INFO Combining to Movie file. scene_file_writer.py:607 [09/06/22 12:21:54] INFO scene_file_writer.py:728 File ready at '/home/tapyu/git/courses/phd_nonlinear_opt/ Exercises/media/videos/test/480p15/FixedInF rameMObjectTest_ManimCE_v0.16.0.post0.gif' INFO Rendered FixedInFrameMObjectTest scene.py:240 Played 6 animations INFO Previewed File at: file_ops.py:224 '/home/tapyu/git/courses/phd_nonlinear_opt/Exercises /media/videos/test/480p15/FixedInFrameMObjectTest_Ma nimCE_v0.16.0.post0.gif' ```

System specifications

System Details ``` OS: Ubuntu 22.04 jammy Kernel: x86_64 Linux 5.15.0-47-generic Uptime: 1d 1h 37m Packages: 2157 Shell: zsh 5.8.1 Resolution: 1366x768 DE: GNOME 41.7 WM: Mutter WM Theme: GTK Theme: Yaru-dark [GTK2/3] Icon Theme: Yaru Font: Ubuntu 11 Disk: 71G / 469G (16%) CPU: Intel Core i5-8250U @ 8x 3.4GHz [49.0°C] GPU: Intel Corporation UHD Graphics 620 (rev 07) RAM: 1682MiB / 2288MiB ```
LaTeX details ``` ❯ tex --version TeX 3.141592653 (TeX Live 2022/dev/Debian) ```
FFMPEG ``` ❯ ffmpeg -version ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers built with gcc 11 (Ubuntu 11.2.0-19ubuntu1) configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 70.100 / 56. 70.100 libavcodec 58.134.100 / 58.134.100 libavformat 58. 76.100 / 58. 76.100 libavdevice 58. 13.100 / 58. 13.100 libavfilter 7.110.100 / 7.110.100 libswscale 5. 9.100 / 5. 9.100 libswresample 3. 9.100 / 3. 9.100 libpostproc 55. 9.100 / 55. 9.100 ```

Additional comments

I haven't used Manim for a while (2 or 3 years), and the syntax change considerably. So my code may have some errors.

Viicos commented 2 years ago

@tapyu This is a problem I had in the past (haven't used manim for a while so I can't tell if it is still the case right now). What I usually do is add an updater to my object:

def my_updater(object):
    self.add_fixed_in_frame_mobjects(object)

obj.add_updater(my_updater)

self.play(obj.animate.set_value(1))

I can't test right now but you will probably be able to get something by playing with updaters.

tapyu commented 2 years ago

@Viicos I appreciate your help as I had no comments since I've written here, but I didn't worked out :( If the add_updater() fixed it in the past, it does not fix anymore...