MCPcopy
hub / github.com/ManimCommunity/manim / construct

Method construct

example_scenes/opengl.py:448–526  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

446
447class SurfaceExample(Scene):
448 def construct(self):
449 # surface_text = Text("For 3d scenes, try using surfaces")
450 # surface_text.fix_in_frame()
451 # surface_text.to_edge(UP)
452 # self.add(surface_text)
453 # self.wait(0.1)
454
455 torus1 = Torus(major_radius=1, minor_radius=1)
456 torus2 = Torus(major_radius=3, minor_radius=1)
457 sphere = Sphere(radius=3, resolution=torus1.resolution)
458 # You can texture a surface with up to two images, which will
459 # be interpreted as the side towards the light, and away from
460 # the light. These can be either urls, or paths to a local file
461 # in whatever you've set as the image directory in
462 # the custom_config.yml file
463
464 script_location = Path(__file__).resolve().parent
465 day_texture = (
466 script_location / "assets" / "1280px-Whole_world_-_land_and_oceans.jpg"
467 )
468 night_texture = script_location / "assets" / "1280px-The_earth_at_night.jpg"
469
470 surfaces = [
471 OpenGLTexturedSurface(surface, day_texture, night_texture)
472 for surface in [sphere, torus1, torus2]
473 ]
474
475 for mob in surfaces:
476 mob.shift(IN)
477 mob.mesh = OpenGLSurfaceMesh(mob)
478 mob.mesh.set_stroke(BLUE, 1, opacity=0.5)
479
480 # Set perspective
481 frame = self.renderer.camera
482 frame.set_euler_angles(
483 theta=-30 * DEGREES,
484 phi=70 * DEGREES,
485 )
486
487 surface = surfaces[0]
488
489 self.play(
490 FadeIn(surface),
491 Create(surface.mesh, lag_ratio=0.01, run_time=3),
492 )
493 for mob in surfaces:
494 mob.add(mob.mesh)
495 surface.save_state()
496 self.play(Rotate(surface, PI / 2), run_time=2)
497 for mob in surfaces[1:]:
498 mob.rotate(PI / 2)
499
500 self.play(Transform(surface, surfaces[1]), run_time=3)
501
502 self.play(
503 Transform(surface, surfaces[2]),
504 # Move camera frame during the transition
505 frame.animate.increment_phi(-10 * DEGREES),

Callers

nothing calls this directly

Calls 15

TorusClass · 0.85
SphereClass · 0.85
OpenGLSurfaceMeshClass · 0.85
FadeInClass · 0.85
CreateClass · 0.85
RotateClass · 0.85
TransformClass · 0.85
set_euler_anglesMethod · 0.80
increment_phiMethod · 0.80
increment_thetaMethod · 0.80
resolveMethod · 0.45

Tested by

no test coverage detected