Last active
January 23, 2025 19:41
-
-
Save uwezi/93ece269e16b195865a043d248e4eb87 to your computer and use it in GitHub Desktop.
[openglSphere] A sphere for the opengl renderer. #manim #3D #sphere #opengl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://discord.com/channels/581738731934056449/1332024484496150589/1332024484496150589 | |
from manim import * | |
from manim.opengl import * | |
config.renderer="opengl" | |
config.write_to_movie=True | |
class openglSphere(OpenGLSurface): | |
def __init__(self, radius=1, **kwargs): | |
def uvfunc(u,v): | |
return radius * np.array([np.cos(v)*np.cos(u),np.cos(v)*np.sin(u),np.sin(v)]) | |
super().__init__( | |
uv_func=uvfunc, | |
u_range=[0,2*PI], | |
v_range=[-PI/2,PI/2], | |
**kwargs | |
) | |
class testsphere(ThreeDScene): | |
def construct(self): | |
self.set_camera_orientation(phi=75 * DEGREES, theta=-60 * DEGREES) | |
ax = ThreeDAxes().add_coordinates() | |
self.add(ax) | |
self.add( | |
openglSphere(radius=4, color=WHITE) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment