ManimCommunity / manim

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

ZOrder not working properly for NumberPlane in 3D scenes #2447

Open JulioLP opened 2 years ago

JulioLP commented 2 years ago

Description of bug / unexpected behavior

When plotting a sphere and a grid (NumberPlane) in a 3D scene, the NumberPlane is always rendered on top of the sphere (even when the sphere is over it). This does not happen with a ThreeDAxes object and a sphere, for example. Also setting the z_index has no effect.

(edit) Same wrong behavior when using Axes instead of ThreeDAxes. I understand that may happen due to mixing 2D and 3D Mobjects in the same scene, but I believe there are many good reasons to do this in animations (i.e.: using NumberPlane leads to much prettier results than using Surface to plot a simple 2D grid in 3D).

Expected behavior

The last added object should be rendered on top.

How to reproduce the issue

Code for reproducing the problem ```py from manim import * config.media_width = "80%" ``` ```py %%manim -qm -v WARNING ExampleNumberPlaneError class ExampleNumberPlaneError(ThreeDScene): def construct(self): axes = NumberPlane() grid = Surface( lambda u, v: np.array([u,v,0]), u_range=[-4, 4], v_range=[-4, 4], resolution=8, fill_opacity=0.0 ) self.set_camera_orientation(phi=PI / 9, theta=PI / 6) sphere = Sphere(center=(0, 3, 3), radius=1.3) sphere.set_fill(ORANGE) self.add(axes,sphere) ```

Additional media files

Images/GIFs ![ExampleNumberPlaneError_ManimCE_v0 13 1](https://user-images.githubusercontent.com/5730527/148656048-27a80be1-e089-47d3-9211-decefe207dac.png)

Logs

Terminal output ``` [01/08/22 19:45:23] INFO scene_file_writer.py:729 File ready at '/home/user/workspaces/m anim_ws/tests/media/images/tests/Exampl eNumberPlaneError_ManimCE_v0.13.1.png' INFO Rendered ExampleNumberPlaneError scene.py:237 Played 0 animations ```

System specifications

System Details - OS: Ubuntu 20.04.3 - RAM: 16GB - Python version: 3.8.10 - Installed modules (provide output from `pip list`): ``` actionlib 1.13.2 angles 1.9.13 apturl 0.5.2 argon2-cffi 21.3.0 argon2-cffi-bindings 21.2.0 attrs 19.3.0 autobahn 17.10.1 Automat 0.8.0 backcall 0.2.0 bcrypt 3.1.7 bleach 4.1.0 blinker 1.4 bondpy 1.8.6 Brlapi 0.7.0 camera-calibration 1.16.0 camera-calibration-parsers 1.12.0 catkin 0.8.10 catkin-pkg 0.4.24 catkin-pkg-modules 0.4.24 catkin-tools 0.8.2 cbor 1.0.0 certifi 2019.11.28 cffi 1.15.0 chardet 3.0.4 click 8.0.3 click-default-group 1.2.2 cloup 0.7.1 colorama 0.4.3 colour 0.1.5 command-not-found 0.3 commonmark 0.9.1 configobj 5.0.6 constantly 15.1.0 controller-manager 0.19.5 controller-manager-msgs 0.19.5 cryptography 2.8 cupshelpers 1.0 cv-bridge 1.16.0 cycler 0.10.0 Cython 0.29.14 data 0.4 dbus-python 1.2.16 debugpy 1.5.1 decorator 5.1.0 defer 1.0.6 defusedxml 0.6.0 diagnostic-analysis 1.10.4 diagnostic-common-diagnostics 1.10.4 diagnostic-updater 1.10.4 distro 1.4.0 distro-info 0.23ubuntu1 docutils 0.16 duplicity 0.8.12.0 dynamic-reconfigure 1.7.1 empy 3.3.2 entrypoints 0.3 fasteners 0.14.1 funcsigs 1.0.2 future 0.18.2 gazebo_plugins 2.9.2 gazebo_ros 2.9.2 gencpp 0.6.5 geneus 3.0.0 genlisp 0.4.18 genmsg 0.5.16 gennodejs 2.0.2 genpy 0.6.15 glcontext 2.3.4 httplib2 0.14.0 hyperlink 19.0.0 idna 2.8 image-geometry 1.16.0 importlib-resources 5.4.0 incremental 16.10.1 interactive-markers 1.12.0 ipykernel 6.6.0 ipython 7.30.1 ipython-genutils 0.2.0 ipywidgets 7.6.5 isosurfaces 0.1.0 jedi 0.18.1 Jinja2 3.0.3 joint_state_publisher 1.15.0 joint_state_publisher_gui 1.15.0 jsonschema 4.3.2 jupyter 1.0.0 jupyter-client 7.1.0 jupyter-console 6.4.0 jupyter-core 4.9.1 jupyterlab-pygments 0.1.2 jupyterlab-widgets 1.0.2 keyring 18.0.1 kiwisolver 1.0.1 language-selector 0.1 laser_geometry 1.6.7 latex 0.7.0 launchpadlib 1.10.13 lazr.restfulclient 0.14.2 lazr.uri 1.0.3 lockfile 0.12.2 louis 3.12.0 lz4 3.0.2+dfsg macaroonbakery 1.3.1 Mako 1.1.0 manim 0.13.1 ManimPango 0.3.1 mapbox-earcut 0.12.11 MarkupSafe 2.0.1 matplotlib 3.1.2 matplotlib-inline 0.1.3 message-filters 1.15.13 mistune 0.8.4 moderngl 5.6.4 moderngl-window 2.4.1 monotonic 1.5 mpi4py 3.0.3 multipledispatch 0.6.0 nbclient 0.5.9 nbconvert 6.3.0 nbformat 5.1.3 nest-asyncio 1.5.4 netifaces 0.10.4 networkx 2.6.3 nose 1.3.7 notebook 6.4.6 numpy 1.17.4 oauthlib 3.1.0 olefile 0.46 osrf-pycommon 1.0.0 packaging 21.3 pandocfilters 1.5.0 paramiko 2.6.0 parso 0.8.3 pbr 5.8.0 pexpect 4.6.0 pickleshare 0.7.5 Pillow 7.0.0 pip 21.3.1 prometheus-client 0.12.0 prompt-toolkit 3.0.24 protobuf 3.6.1 psutil 5.5.1 ptyprocess 0.7.0 py-ubjson 0.14.0 pyasn1 0.4.2 pyasn1-modules 0.2.1 pycairo 1.20.1 pycparser 2.21 pycryptodomex 3.6.1 pycups 1.9.73 pydot 1.4.1 pydub 0.25.1 pyglet 1.5.21 Pygments 2.10.0 PyGObject 3.36.0 PyHamcrest 1.9.0 PyJWT 1.7.1 pymacaroons 0.13.0 PyNaCl 1.3.0 PyOpenGL 3.1.0 pyOpenSSL 19.0.0 pyparsing 2.4.6 pypng 0.0.20 PyQRCode 1.2.1 PyQt5 5.14.1 pyRFC3339 1.1 pyrr 0.10.3 pyrsistent 0.18.0 python-apt 2.0.0+ubuntu0.20.4.6 python-dateutil 2.7.3 python-debian 0.1.36ubuntu1 python-gnupg 0.4.5 python-qt-binding 0.4.4 python-snappy 0.5.3 PyTrie 0.2 pytz 2019.3 pyxdg 0.26 PyYAML 5.3.1 pyzmq 22.3.0 qt-dotgraph 0.4.2 qt-gui 0.4.2 qt-gui-cpp 0.4.2 qt-gui-py-common 0.4.2 qtconsole 5.2.2 QtPy 2.0.0 ranger-fm 1.9.3 reportlab 3.5.34 requests 2.22.0 requests-unixsocket 0.2.0 resource_retriever 1.12.6 rich 10.16.1 roman 2.0.0 rosbag 1.15.13 rosboost-cfg 1.15.8 rosclean 1.15.8 roscreate 1.15.8 rosdep 0.21.0 rosdep-modules 0.21.0 rosdistro 0.8.3 rosdistro-modules 0.8.3 rosgraph 1.15.13 roslaunch 1.15.13 roslib 1.15.8 roslint 0.12.0 roslz4 1.15.13 rosmake 1.15.8 rosmaster 1.15.13 rosmsg 1.15.13 rosnode 1.15.13 rosparam 1.15.13 rospkg 1.3.0 rospkg-modules 1.3.0 rospy 1.15.13 rosservice 1.15.13 rostest 1.15.13 rostopic 1.15.13 rosunit 1.15.8 roswtf 1.15.13 rqt_action 0.4.9 rqt_bag 0.5.1 rqt_bag_plugins 0.5.1 rqt_console 0.4.11 rqt_dep 0.4.12 rqt_graph 0.4.14 rqt_gui 0.5.2 rqt_gui_py 0.5.2 rqt_image_view 0.4.16 rqt_launch 0.4.9 rqt_logger_level 0.4.11 rqt-moveit 0.5.10 rqt_msg 0.4.10 rqt_nav_view 0.5.7 rqt_plot 0.4.13 rqt_pose_view 0.5.11 rqt_publisher 0.4.10 rqt_py_common 0.5.2 rqt_py_console 0.4.10 rqt-reconfigure 0.5.4 rqt-robot-dashboard 0.5.8 rqt-robot-monitor 0.5.13 rqt_robot_steering 0.5.12 rqt_runtime_monitor 0.5.9 rqt-rviz 0.7.0 rqt_service_caller 0.4.10 rqt_shell 0.4.11 rqt_srv 0.4.9 rqt_tf_tree 0.6.2 rqt_top 0.4.10 rqt_topic 0.4.13 rqt_web 0.4.10 rviz 1.14.11 scipy 1.7.3 screen-resolution-extra 0.0.0 screeninfo 0.6.7 SecretStorage 2.3.1 Send2Trash 1.8.0 sensor-msgs 1.13.1 service-identity 18.1.0 setuptools 45.2.0 shutilwhich 1.1.0 simplejson 3.16.0 sip 4.19.21 six 1.14.0 skia-pathops 0.7.2 smach 2.5.0 smach-ros 2.5.0 smclib 1.8.6 srt 3.5.0 systemd-python 234 tempdir 0.7.1 terminado 0.12.1 testpath 0.5.0 testresources 2.0.1 tf 1.13.2 tf-conversions 1.13.2 tf2-geometry-msgs 0.7.5 tf2-kdl 0.7.5 tf2-py 0.7.5 tf2-ros 0.7.5 topic-tools 1.15.13 tornado 6.1 tqdm 4.62.3 traitlets 5.1.1 Twisted 18.9.0 txaio 2.10.0 u-msgpack-python 2.1 ubuntu-advantage-tools 27.4 ubuntu-drivers-common 0.0.0 ufw 0.36 unattended-upgrades 0.1 urllib3 1.25.8 usb-creator 0.3.7 wadllib 1.3.3 watchdog 2.1.6 wcwidth 0.2.5 webencodings 0.5.1 wheel 0.34.2 widgetsnbextension 3.5.2 wsaccel 0.6.2 xacro 1.14.10 xkit 0.0.0 zipp 3.6.0 zope.interface 4.7.1 ```
LaTeX details + Not used
FFMPEG Output of `ffmpeg -version`: ``` ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers built with gcc 9 (Ubuntu 9.3.0-10ubuntu2) configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --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-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 31.100 / 56. 31.100 libavcodec 58. 54.100 / 58. 54.100 libavformat 58. 29.100 / 58. 29.100 libavdevice 58. 8.100 / 58. 8.100 libavfilter 7. 57.100 / 7. 57.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 5.100 / 5. 5.100 libswresample 3. 5.100 / 3. 5.100 libpostproc 55. 5.100 / 55. 5.100 ```
alembcke commented 2 years ago

This does appear to be an issue, as I tried the argument shade_in_3d=True which usually works to convert 2D MObjects to 3D MObjects - still getting the same issue. I know not adding a whole lot here, but wanted to let you know that someone has looked at this and ended up with the same result.