ManimCommunity / ManimCommunity/manim
3D sphere animation issue! Can't do with config.renderer='opengl!! ERROR!
- Dominant language
- Python
- Stars
- 40.9k
- Forks
- 3.1k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 25
Description
## Description of bug / unexpected behavior
I was trying to create a 3d sphere in manim with opengl renderer. But I got an error on line 274 of file opengl_mobject.py. I was trying to animate it. All mobject made from Surface class cannot be animated.
## Expected behavior
Creates a sphere with the animation.
## How to reproduce the issue
Try to animate a sphere with config.renderer=opengl in the script. Even the creation animation doesn't work.
Code for reproducing the problem
```py
from manim import *
from math import *
config.renderer = 'opengl'
class test(ThreeDScene):
def func(self, u, v):
return np.array([sin(u) * cos(v), sin(u) * sin(v), cos(u)])
def construct(self):
self.set_camera_orientation(phi=TAU / 6, theta=-TAU / 8)
ax = ThreeDAxes(x_range=[-15, 15, 1], y_range=[-15, 15, 1], z_range=[-15, 15, 1], x_length=16, y_length=16,
z_length=16, axis_config={"stroke_width"
: 4, "include_ticks": False}, tips=False, ).set_color(
color=BLUE_C).set_opacity(0.7)
self.play(SpinInFromNothing(ax))
dot = Dot3D(radius=0.5, color=BLUE, resolution=(20, 20))
surf = Surface(lambda u, v: ax.c2p(*self.func(u, v)), resolution=(25, 25), u_range=[-1, 1], v_range=[-1, 1],
checkerboard_colors=(BLUE_C, BLUE_C))
self.play(Create(surf))
```
## Additional media files

## Logs
[06/09/22 09:22:11] INFO Animation 0 : Partial movie file written in 'C:\Users\nbhattarai\ scene_file_writer.py:504
Desktop\pythonProject\media\videos\manimtest\1080p60\partial_movi
e_files\test\1206935955_1327336443_223132457.mp4'
INFO Combining to Movie file. scene_file_writer.py:597
INFO scene_file_writer.py:718
File ready at 'C:\Users\nbhattarai\Desktop\pythonProject\media\vi
deos\manimtest\1080p60\test.mp4'
INFO Rendered test scene.py:240
Played 1 animations
INFO Previewed File at: 'C:\Users\nbhattarai\Desktop\pythonProject\media\videos file_ops.py:213
\manimtest\1080p60\test.mp4'
C:\Users\nbhattarai\Desktop\pythonProject>manim manimtest.py -pqh test
Manim Community v0.15.2
[06/09/22 09:22:28] INFO Animation 0 : Partial movie file written in 'C:\Users\nbhattarai\ scene_file_writer.py:504
Desktop\pythonProject\media\videos\manimtest\1080p60\partial_movi
e_files\test\1206935955_2205785231_223132457.mp4'
INFO Combining to Movie file. scene_file_writer.py:597
INFO scene_file_writer.py:718
File ready at 'C:\Users\nbhattarai\Desktop\pythonProject\media\vi
deos\manimtest\1080p60\test.mp4'
INFO Rendered test scene.py:240
Played 1 animations
INFO Previewed File at: 'C:\Users\nbhattarai\Desktop\pythonProject\media\videos file_ops.py:213
\manimtest\1080p60\test.mp4'
C:\Users\nbhattarai\Desktop\pythonProject>manim animate_orbit.py -pqh
Manim Community v0.15.2
[06/09/22 09:23:24] INFO Animation 0 : Partial movie file written in 'C:\Users\nbhattarai\ scene_file_writer.py:504
Desktop\pythonProject\media\videos\animate_orbit\1080p60\partial_
movie_files\SV\3753344363_1728346802_729892282.mp4'
[06/09/22 09:25:10] INFO Animation 1 : Partial movie file written in 'C:\Users\nbhattarai\ scene_file_writer.py:504
Desktop\pythonProject\media\videos\animate_orbit\1080p60\partial_
movie_files\SV\2697088693_2030932270_3254511410.mp4'
C:\Users\nbhattarai\Desktop\pythonProject\animate_orbit.py:34: DeprecationWarning: This method is not guaranteed to stay around. Please prefer getting the attribute normally.
a = mob.get_width() / 2
C:\Users\nbhattarai\Desktop\pythonProject\animate_orbit.py:35: DeprecationWarning: This method is not guaranteed to stay around. Please prefer getting the attribute normally.
b = mob.get_height() / 2
[06/09/22 09:26:49] INFO Animation 2 : Partial movie file written in 'C:\Users\nbhattarai\ scene_file_writer.py:504
Desktop\pythonProject\media\videos\animate_orbit\1080p60\partial_
movie_files\SV\609824976_3770544083_296555209.mp4'
[06/09/22 09:27:14] INFO Animation 3 : Partial movie file written in 'C:\Users\nbhattarai\ scene_file_writer.py:504
Desktop\pythonProject\media\videos\animate_orbit\1080p60\partial_
movie_files\SV\1346319175_305220765_4008628747.mp4'
[06/09/22 09:27:38] INFO Animation 4 : Partial movie file written in 'C:\Users\nbhattarai\ scene_file_writer.py:504
Desktop\pythonProject\media\videos\animate_orbit\1080p60\partial_
movie_files\SV\1492643054_305220765_976411088.mp4'
[06/09/22 09:29:18] INFO Animation 5 : Partial movie file written in 'C:\Users\nbhattarai\ scene_file_writer.py:504
Desktop\pythonProject\media\videos\animate_orbit\1080p60\partial_
movie_files\SV\614947739_3963600668_2936865332.mp4'
[06/09/22 09:29:43] INFO Animation 6 : Partial movie file written in 'C:\Users\nbhattarai\ scene_file_writer.py:504
Desktop\pythonProject\media\videos\animate_orbit\1080p60\partial_
movie_files\SV\3291823867_305220765_4125379837.mp4'
[06/09/22 09:31:24] INFO Animation 7 : Partial movie file written in 'C:\Users\nbhattarai\ scene_file_writer.py:504
Desktop\pythonProject\media\videos\animate_orbit\1080p60\partial_
movie_files\SV\3541831321_4108942551_1912565639.mp4'
[06/09/22 09:31:48] INFO Animation 8 : Partial movie file written in 'C:\Users\nbhattarai\ scene_file_writer.py:504
Desktop\pythonProject\media\videos\animate_orbit\1080p60\partial_
movie_files\SV\3446631281_305220765_2991827951.mp4'
[06/09/22 09:33:28] INFO Animation 9 : Partial movie file written in 'C:\Users\nbhattarai\ scene_file_writer.py:504
Desktop\pythonProject\media\videos\animate_orbit\1080p60\partial_
movie_files\SV\2858636624_1549216819_2117978172.mp4'
[06/09/22 09:33:52] INFO Animation 10 : Partial movie file written in 'C:\Users\nbhattarai scene_file_writer.py:504
\Desktop\pythonProject\media\videos\animate_orbit\1080p60\partial
_movie_files\SV\1242975613_305220765_2522340015.mp4'
[06/09/22 09:35:33] INFO Animation 11 : Partial movie file written in 'C:\Users\nbhattarai scene_file_writer.py:504
\Desktop\pythonProject\media\videos\animate_orbit\1080p60\partial
_movie_files\SV\2937933979_2322800566_1389832535.mp4'
[06/09/22 09:35:58] INFO Animation 12 : Partial movie file written in 'C:\Users\nbhattarai scene_file_writer.py:504
\Desktop\pythonProject\media\videos\animate_orbit\1080p60\partial
_movie_files\SV\4226533346_305220765_3563162186.mp4'
[06/09/22 09:37:40] INFO Animation 13 : Partial movie file written in 'C:\Users\nbhattarai scene_file_writer.py:504
\Desktop\pythonProject\media\videos\animate_orbit\1080p60\partial
_movie_files\SV\2814946966_136206461_3430518496.mp4'
[06/09/22 09:38:31] INFO Animation 14 : Partial movie file written in 'C:\Users\nbhattarai scene_file_writer.py:504
\Desktop\pythonProject\media\videos\animate_orbit\1080p60\partial
_movie_files\SV\2602327004_3044737987_2124548186.mp4'
0.8209641928385677
[06/09/22 09:51:56] INFO Animation 15 : Partial movie file written in 'C:\Users\nbhattarai scene_file_writer.py:504
\Desktop\pythonProject\media\videos\animate_orbit\1080p60\partial
_movie_files\SV\1738820499_1616291757_1183217292.mp4'
Aborted!
C:\Users\nbhattarai\Desktop\pythonProject>manim manimtest.py -pqh test
Manim Community v0.15.2
[06/09/22 09:55:42] INFO Animation 0 : Partial movie file written in 'C:\Users\nbhattarai\ scene_file_writer.py:504
Desktop\pythonProject\media\videos\manimtest\1080p60\partial_movi
e_files\test\1206935955_3536860325_223132457.mp4'
┌─────────────────────────────── Traceback (most recent call last) ────────────────────────────────┐
│ C:\Users\nbhattarai\AppData\Local\Programs\Python\Python310\lib\site-packages\manim\cli\render\c │
│ ommands.py:118 in render │
│ │
│ 115 │ │ for SceneClass in scene_classes_from_file(file): │
│ 116 │ │ │ try: │
│ 117 │ │ │ │ scene = SceneClass() │
│ > 118 │ │ │ │ scene.render() │
│ 119 │ │ │ except Exception: │
│ 120 │ │ │ │ error_console.print_exception() │
│ 121 │ │ │ │ sys.exit(1) │
│ │
│ C:\Users\nbhattarai\AppData\Local\Programs\Python\Python310\lib\site-packages\manim\scene\scene. │
│ py:222 in render │
│ │
│ 219 │ │ """ │
│ 220 │ │ self.setup() │
│ 221 │ │ try: │
│ > 222 │ │ │ self.construct() │
│ 223 │ │ except EndSceneEarlyException: │
│ 224 │ │ │ pass │
│ 225 │ │ except RerunSceneException as e: │
│ │
│ C:\Users\nbhattarai\Desktop\pythonProject\manimtest.py:26 in construct │
│ │
│ 23 │ │ surf = Surface(lambda u, v: ax.c2p(*self.func(u, v)), resolution=(25, 25), u_ran │
│ 24 │ │ │ │ │ checkerboard_colors=(BLUE_C, BLUE_C)) │
│ 25 │ │ │
│ > 26 │ │ self.play(Create(surf)) │
│ 27 │
│ │
│ C:\Users\nbhattarai\AppData\Local\Programs\Python\Python310\lib\site-packages\manim\scene\scene. │
│ py:1012 in play │
│ │
│ 1009 │ │ │
│ 1010 │ │ """ │
│ 1011 │ │ start_time = self.renderer.time │
│ > 1012 │ │ self.renderer.play(self, *args, **kwargs) │
│ 1013 │ │ run_time = self.renderer.time - start_time │
│ 1014 │ │ if subcaption: │
│ 1015 │ │ │ if subcaption_duration is None: │
│ │
│ C:\Users\nbhattarai\AppData\Local\Programs\Python\Python310\lib\site-packages\manim\utils\cachin │
│ g.py:63 in wrapper │
│ │
│ 60 │ │ │ "List of the first few animation hashes of the scene: %(h)s", │
│ 61 │ │ │ {"h": str(self.animations_hashes[:5])}, │
│ 62 │ │ ) │
│ > 63 │ │ func(self, scene, *args, **kwargs) │
│ 64 │ │
│ 65 │ return wrapper │
│ 66 │
│ │
│ C:\Users\nbhattarai\AppData\Local\Programs\Python\Python310\lib\site-packages\manim\renderer\ope │
│ ngl_renderer.py:445 in play │
│ │
│ 442 │ │ │ self.animation_elapsed_time = scene.duration │
│ 443 │ │ │
│ 444 │ │ else: │
│ > 445 │ │ │ scene.play_internal() │
│ 446 │ │ │
│ 447 │ │ self.file_writer.end_animation(not self.skip_animations) │
│ 448 │ │ self.time += scene.duration │
│ │
│ C:\Users\nbhattarai\AppData\Local\Programs\Python\Python310\lib\site-packages\manim\scene\scene. │
│ py:1177 in play_internal │
│ │
│ 1174 │ │ │ self.duration, │
│ 1175 │ │ ) │
│ 1176 │ │ for t in self.time_progression: │
│ > 1177 │ │ │ self.update_to_time(t) │
│ 1178 │ │ │ if not skip_rendering and not self.skip_animation_preview: │
│ 1179 │ │ │ │ self.renderer.render(self, t, self.moving_mobjects) │
│ 1180 │ │ │ if self.stop_condition is not None and self.stop_condition(): │
│ │
│ C:\Users\nbhattarai\AppData\Local\Programs\Python\Python310\lib\site-packages\manim\scene\scene. │
│ py:1410 in update_to_time │
│ │
│ 1407 │ │ for animation in self.animations: │
│ 1408 │ │ │ animation.update_mobjects(dt) │
│ 1409 │ │ │ alpha = t / animation.run_time │
│ > 1410 │ │ │ animation.interpolate(alpha) │
│ 1411 │ │ self.update_mobjects(dt) │
│ 1412 │ │ self.update_meshes(dt) │
│ 1413 │ │ self.update_self(dt) │
│ │
│ C:\Users\nbhattarai\AppData\Local\Programs\Python\Python310\lib\site-packages\manim\animation\an │
│ imation.py:322 in interpolate │
│ │
│ 319 │ │ │ The relative time to set the animation to, 0 meaning the start, 1 meaning │
│ 320 │ │ │ the end. │
│ 321 │ │ """ │
│ > 322 │ │ self.interpolate_mobject(alpha) │
│ 323 │ │
│ 324 │ def interpolate_mobject(self, alpha: float) -> None: │
│ 325 │ │ """Interpolates the mobject of the :class:`Animation` based on alpha value. │
│ │
│ C:\Users\nbhattarai\AppData\Local\Programs\Python\Python310\lib\site-packages\manim\animation\an │
│ imation.py:337 in interpolate_mobject │
│ │
│ 334 │ │ families = list(self.get_all_families_zipped()) │
│ 335 │ │ for i, mobs in enumerate(families): │
│ 336 │ │ │ sub_alpha = self.get_sub_alpha(alpha, i, len(families)) │
│ > 337 │ │ │ self.interpolate_submobject(*mobs, sub_alpha) │
│ 338 │ │
│ 339 │ def interpolate_submobject( │
│ 340 │ │ self, │
│ │
│ C:\Users\nbhattarai\AppData\Local\Programs\Python\Python310\lib\site-packages\manim\animation\cr │
│ eation.py:126 in interpolate_submobject │
│ │
│ 123 │ │ starting_submobject: Mobject, │
│ 124 │ │ alpha: float, │
│ 125 │ ) -> None: │
│ > 126 │ │ submobject.pointwise_become_partial( │
│ 127 │ │ │ starting_submobject, *self._get_bounds(alpha) │
│ 128 │ │ ) │
│ 129 │
│ │
│ C:\Users\nbhattarai\AppData\Local\Programs\Python\Python310\lib\site-packages\manim\mobject\open │
│ gl\opengl_vectorized_mobject.py:1313 in pointwise_become_partial │
│ │
│ 1310 │ │ """ │
│ 1311 │ │ assert isinstance(vmobject, OpenGLVMobject) │
│ 1312 │ │ if a <= 0 and b >= 1: │
│ > 1313 │ │ │ self.become(vmobject) │
│ 1314 │ │ │ return self │
│ 1315 │ │ num_curves = vmobject.get_num_curves() │
│ 1316 │ │ nppc = self.n_points_per_curve │
│ │
│ C:\Users\nbhattarai\AppData\Local\Programs\Python\Python310\lib\site-packages\manim\mobject\open │
│ gl\opengl_mobject.py:2443 in become │
│ │
│ 2440 │ │ │
│ 2441 │ │ self.align_family(mobject) │
│ 2442 │ │ for sm1, sm2 in zip(self.get_family(), mobject.get_family()): │
│ > 2443 │ │ │ sm1.set_data(sm2.data) │
│ 2444 │ │ │ sm1.set_uniforms(sm2.uniforms) │
│ 2445 │ │ self.refresh_bounding_box(recurse_down=True) │
│ 2446 │ │ return self │
│ │
│ C:\Users\nbhattarai\AppData\Local\Programs\Python\Python310\lib\site-packages\manim\mobject\open │
│ gl\opengl_vectorized_mobject.py:1458 in wrapper │
│ │
│ 1455 │ │ │ old_points = np.empty((0, 3)) │
│ 1456 │ │ │ for mob in self.family_members_with_points(): │
│ 1457 │ │ │ │ old_points = np.concatenate((old_points, mob.points), axis=0) │
│ > 1458 │ │ │ func(self, *args, **kwargs) │
│ 1459 │ │ │ new_points = np.empty((0, 3)) │
│ 1460 │ │ │ for mob in self.family_members_with_points(): │
│ 1461 │ │ │ │ new_points = np.concatenate((new_points, mob.points), axis=0) │
│ │
│ C:\Users\nbhattarai\AppData\Local\Programs\Python\Python310\lib\site-packages\manim\mobject\open │
│ gl\opengl_vectorized_mobject.py:1476 in set_data │
│ │
│ 1473 │ │
│ 1474 │ @triggers_refreshed_triangulation │
│ 1475 │ def set_data(self, data): │
│ > 1476 │ │ super().set_data(data) │
│ 1477 │ │ return self │
│ 1478 │ │
│ 1479 │ # TODO, how to be smart about tangents here? │
│ │
│ C:\Users\nbhattarai\AppData\Local\Programs\Python\Python310\lib\site-packages\manim\mobject\open │
│ gl\opengl_mobject.py:274 in set_data │
│ │
│ 271 │ │
│ 272 │ def set_data(self, data): │
│ 273 │ │ for key in data: │
│ > 274 │ │ │ self.data[key] = data[key].copy() │
│ 275 │ │ return self │
│ 276 │ │
│ 277 │ def set_uniforms(self, uniforms): │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
AttributeError: 'float' object has no attribute 'copy'
```
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)): WIndows 10
- RAM:16
- Python version (`python/py/python3 --version`): 3.10
- Installed modules (provide output from `pip list`):
- certifi 2022.5.18.1
charset-normalizer 2.0.12
click 8.1.3
click-default-group 1.2.2
cloup 0.13.1
colorama 0.4.4
colour 0.1.5
commonmark 0.9.1
data 0.4
decorator 5.1.1
funcsigs 1.0.2
future 0.18.2
georinex 1.16.1
glcontext 2.3.6
hatanaka 2.8.0
idna 3.3
importlib-resources 5.7.1
isosurfaces 0.1.0
latex 0.7.0
manim 0.15.2
ManimPango 0.4.1
mapbox-earcut 0.12.11
moderngl 5.6.4
moderngl-window 2.4.1
multipledispatch 0.6.0
ncompress 1.0.0
networkx 2.8.3
numpy 1.22.4
packaging 21.3
pandas 1.4.2
Pillow 9.1.1
pip 21.3.1
pycairo 1.21.0
pydub 0.25.1
pyglet 1.5.26
Pygments 2.12.0
pyparsing 3.0.9
pyrr 0.10.3
python-dateutil 2.8.2
pytz 2022.1
requests 2.27.1
rich 12.4.4
scipy 1.8.1
screeninfo 0.8
setuptools 60.2.0
shutilwhich 1.1.0
six 1.16.0
skia-pathops 0.7.2
srt 3.5.2
tempdir 0.7.1
tqdm 4.64.0
unlzw3 0.2.1
urllib3 1.26.9
watchdog 2.1.8
wheel 0.37.1
xarray 2022.3.0
```
PASTE HERE
```
LaTeX details
+ LaTeX distribution (e.g. TeX Live 2020):
+ Installed LaTeX packages:
FFMPEG
Output of `ffmpeg -version`:
```
PASTE HERE
```
## Additional comments
Contributor guide
Research direction
Start by reproducing the provided Surface and Create example with config.renderer set to opengl, then inspect opengl_mobject.py around line 274. Done means a sphere created from Surface can run its creation animation with the OpenGL renderer without the reported error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100