Comments (4)
More info: I'm running manim -qm --renderer=opengl -p manim.py SurfaceExample
, where manim.py
contains just the code from that example (trimmed down a little to just make the sphere). I'm using these textures: https://github.com/ManimCommunity/manim/tree/04bfa221075166a00eaa11fc9e9f0757f56625d2/example_scenes/assets. Here's my code:
from pathlib import Path
import manim.utils.opengl as opengl
from manim import *
from manim.opengl import * # type: ignore
class SurfaceExample(Scene):
def construct(self):
sphere = Sphere(radius=3, resolution=Torus(major_radius=1, minor_radius=1).resolution)
# You can texture a surface with up to two images, which will
# be interpreted as the side towards the light, and away from
# the light. These can be either urls, or paths to a local file
# in whatever you've set as the image directory in
# the custom_config.yml file
script_location = Path(__file__).resolve().parent
day_texture = (
script_location / "assets" / "1280px-Whole_world_-_land_and_oceans.jpg"
)
night_texture = script_location / "assets" / "1280px-The_earth_at_night.jpg"
# <-- fails here
textured_earth = OpenGLTexturedSurface(sphere, day_texture, night_texture)
textured_earth.shift(IN)
textured_earth.mesh = OpenGLSurfaceMesh(textured_earth)
textured_earth.mesh.set_stroke(BLUE, 1, opacity=0.5)
# Set perspective
frame = self.renderer.camera
frame.set_euler_angles(
theta=-30 * DEGREES,
phi=70 * DEGREES,
)
self.play(
FadeIn(textured_earth),
Create(textured_earth.mesh, lag_ratio=0.01, run_time=3),
)
textured_earth.add(textured_earth.mesh)
textured_earth.save_state()
self.play(Rotate(textured_earth, PI / 2), run_time=2)
# self.play(Transform(surface, surfaces[1]), run_time=3)
# self.play(
# Transform(surface, surfaces[2]),
# # Move camera frame during the transition
# frame.animate.increment_phi(-10 * DEGREES),
# frame.animate.increment_theta(-20 * DEGREES),
# run_time=3,
# )
# Add ambient rotation
frame.add_updater(lambda m, dt: m.increment_theta(-0.1 * dt))
# Play around with where the light is
# light_text = Text("You can move around the light source")
# light_text.move_to(surface_text)
# light_text.fix_in_frame()
# self.play(FadeTransform(surface_text, light_text))
light = self.camera.light_source
self.add(light)
light.save_state()
self.play(light.animate.move_to(3 * IN), run_time=5)
self.play(light.animate.shift(10 * OUT), run_time=5)
from manim.
try to rename your file to something else than "manim.py" and make sure to remove any file called "manim.py"
from manim.
try to rename your file to something else than "manim.py" and make sure to remove any file called "manim.py"
Right, that was an accidental top-level library name pollution, but it didn't impact running this particular example, which I can replicate regardless of filename in a blank directory, and also in a Jupyter notebook.
from manim.
as a help to debug the cause of the new problem in 0.18.0.post0: the following code works, i.e. explicitly defining an OpenGLSurface
while the internal overloading of a Surface
or Sphere
does not work and gives an error because uv_func
is not defined....
from manim import *
from manim.opengl import * # type: ignore
class SurfaceExample(Scene):
def construct(self):
sphere = OpenGLSurface(
lambda u,v: [3*np.sin(u)*np.cos(v), 3*np.sin(u)*np.sin(v), 3*np.cos(u)],
u_range=[0,PI],
v_range=[-PI,PI]
)
# You can texture a surface with up to two images, which will
# be interpreted as the side towards the light, and away from
# the light. These can be either urls, or paths to a local file
# in whatever you've set as the image directory in
# the custom_config.yml file
day_texture = "bilder/1280px-Whole_world_-_land_and_oceans.jpg"
night_texture = "bilder/1280px-The_earth_at_night.jpg"
# <-- fails here
textured_earth = OpenGLTexturedSurface(sphere, day_texture, night_texture)
textured_earth.shift(IN)
textured_earth.mesh = OpenGLSurfaceMesh(textured_earth)
textured_earth.mesh.set_stroke(BLUE, 1, opacity=0.5)
# Set perspective
frame = self.renderer.camera
frame.set_euler_angles(
theta=-30 * DEGREES,
phi=70 * DEGREES,
)
self.play(
FadeIn(textured_earth),
Create(textured_earth.mesh, lag_ratio=0.01, run_time=3),
)
textured_earth.add(textured_earth.mesh)
textured_earth.save_state()
self.play(Rotate(textured_earth, PI / 2), run_time=2)
# self.play(Transform(surface, surfaces[1]), run_time=3)
# self.play(
# Transform(surface, surfaces[2]),
# # Move camera frame during the transition
# frame.animate.increment_phi(-10 * DEGREES),
# frame.animate.increment_theta(-20 * DEGREES),
# run_time=3,
# )
# Add ambient rotation
frame.add_updater(lambda m, dt: m.increment_theta(-0.1 * dt))
# Play around with where the light is
# light_text = Text("You can move around the light source")
# light_text.move_to(surface_text)
# light_text.fix_in_frame()
# self.play(FadeTransform(surface_text, light_text))
light = self.camera.light_source
self.add(light)
light.save_state()
self.play(light.animate.move_to(3 * IN), run_time=5)
self.play(light.animate.shift(10 * OUT), run_time=5)
from manim.
Related Issues (20)
- add_subcaption does not work as expected HOT 1
- Error when using `next_to` to a ImageMobject with the OpenGL renderer
- Fix setup-ffmpeg - unable to fetch HOT 2
- Manim installation not working with conda and python 3.12.3
- Issue with installing manim on google colab; fixed issue and just wanted to inform
- pwntools compatibility issue due to gdb related problems HOT 1
- V0.18.1 NumberLine's number_to_point() is broken when using `add_tip` HOT 2
- Google Colab: Video data is no longer automatically embedded in the notebook HOT 1
- Manim stuck in python 3.12.3 on arch linux, and keeps allocating memory until no memory available. HOT 3
- Underline markup tag for MarkupText should be documented as <u></u> not <ul></ul>. HOT 1
- Latex error HOT 6
- FadeOut on DiGraph does not work smoothly HOT 1
- Autoaliasattr: `TypeVar`
- Error with Graph Tree Layout example in the graph.py HOT 3
- `VGroup` cannot have a `Mobject` as a child, but `VMobject` can
- I want to know there is a threeD table in Mainm? HOT 2
- always_redraw works in 0.18.0 but not in 0.18.1 (single ValueTracker) HOT 5
- cmanimpango fatal error: Python.h HOT 3
- Support Python 3.12 `TypeAlias` syntax
- Can not use \textcolor , always render as white color HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from manim.