MCPcopy
hub / github.com/3b1b/manim / construct

Method construct

example_scenes.py:567–645  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

565
566class SurfaceExample(ThreeDScene):
567 def construct(self):
568 surface_text = Text("For 3d scenes, try using surfaces")
569 surface_text.fix_in_frame()
570 surface_text.to_edge(UP)
571 self.add(surface_text)
572 self.wait(0.1)
573
574 torus1 = Torus(r1=1, r2=1)
575 torus2 = Torus(r1=3, r2=1)
576 sphere = Sphere(radius=3, resolution=torus1.resolution)
577 # You can texture a surface with up to two images, which will
578 # be interpreted as the side towards the light, and away from
579 # the light. These can be either urls, or paths to a local file
580 # in whatever you've set as the image directory in
581 # the custom_config.yml file
582
583 # day_texture = "EarthTextureMap"
584 # night_texture = "NightEarthTextureMap"
585 day_texture = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4d/Whole_world_-_land_and_oceans.jpg/1280px-Whole_world_-_land_and_oceans.jpg"
586 night_texture = "https://upload.wikimedia.org/wikipedia/commons/thumb/b/ba/The_earth_at_night.jpg/1280px-The_earth_at_night.jpg"
587
588 surfaces = [
589 TexturedSurface(surface, day_texture, night_texture)
590 for surface in [sphere, torus1, torus2]
591 ]
592
593 for mob in surfaces:
594 mob.shift(IN)
595 mob.mesh = SurfaceMesh(mob)
596 mob.mesh.set_stroke(BLUE, 1, opacity=0.5)
597
598 surface = surfaces[0]
599
600 self.play(
601 FadeIn(surface),
602 ShowCreation(surface.mesh, lag_ratio=0.01, run_time=3),
603 )
604 for mob in surfaces:
605 mob.add(mob.mesh)
606 surface.save_state()
607 self.play(Rotate(surface, PI / 2), run_time=2)
608 for mob in surfaces[1:]:
609 mob.rotate(PI / 2)
610
611 self.play(
612 Transform(surface, surfaces[1]),
613 run_time=3
614 )
615
616 self.play(
617 Transform(surface, surfaces[2]),
618 # Move camera frame during the transition
619 self.frame.animate.increment_phi(-10 * DEG),
620 self.frame.animate.increment_theta(-20 * DEG),
621 run_time=3
622 )
623 # Add ambient rotation
624 self.frame.add_updater(lambda m, dt: m.increment_theta(-0.1 * dt))

Callers

nothing calls this directly

Calls 15

TextClass · 0.85
TorusClass · 0.85
SphereClass · 0.85
TexturedSurfaceClass · 0.85
SurfaceMeshClass · 0.85
FadeInClass · 0.85
ShowCreationClass · 0.85
RotateClass · 0.85
TransformClass · 0.85
FadeTransformClass · 0.85
GlowDotClass · 0.85
fix_in_frameMethod · 0.80

Tested by

no test coverage detected