Skip to content

Commit

Permalink
Merge pull request 3b1b#3 from 3b1b/shaders
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
TonyCrane authored Jan 16, 2021
2 parents 7c04edc + 2daf62e commit 83a9217
Show file tree
Hide file tree
Showing 10 changed files with 273 additions and 231 deletions.
1 change: 1 addition & 0 deletions custom_defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ tex:
# intermediate_filetype: "xdv"
universal_import_line: "from manimlib.imports import *"
style:
font: "Consolas"
background_color: "#333333"
camera_qualities:
low:
Expand Down
26 changes: 24 additions & 2 deletions example_scenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,22 +310,33 @@ class SurfaceExample(Scene):
}

def construct(self):
surface_text = Text("For 3d scenes, try using surfaces")
surface_text.fix_in_frame()
surface_text.to_edge(UP)
self.add(surface_text)
self.wait(0.1)

torus1 = Torus(r1=1, r2=1)
torus2 = Torus(r1=3, r2=1)
sphere = Sphere(radius=3, resolution=torus1.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 iamge directory in
# in whatever you've set as the image directory in
# the custom_defaults.yml file

# day_texture = "EarthTextureMap"
# night_texture = "NightEarthTextureMap"
day_texture = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4d/Whole_world_-_land_and_oceans.jpg/1280px-Whole_world_-_land_and_oceans.jpg"
night_texture = "https://upload.wikimedia.org/wikipedia/commons/thumb/b/ba/The_earth_at_night.jpg/1280px-The_earth_at_night.jpg"

surfaces = [
TexturedSurface(surface, day_texture, night_texture)
for surface in [sphere, torus1, torus2]
]

for mob in surfaces:
mob.shift(IN)
mob.mesh = SurfaceMesh(mob)
mob.mesh.set_stroke(BLUE, 1, opacity=0.5)

Expand Down Expand Up @@ -365,12 +376,23 @@ def construct(self):
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.move_to, 3 * IN, run_time=5)
self.play(light.shift, 10 * OUT, run_time=5)
self.wait(4)

drag_text = Text("Try clicking and dragging while pressing d")
drag_text.move_to(light_text)
drag_text.fix_in_frame()

self.play(FadeTransform(light_text, drag_text))
self.wait()


# See https://github.com/3b1b/videos for many, many more
2 changes: 1 addition & 1 deletion manimlib/camera/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def set_phi(self, phi):
return self.set_rotation(phi=phi)

def set_gamma(self, gamma):
return self.set_rotation(phi=phi)
return self.set_rotation(gamma=gamma)

def increment_theta(self, dtheta):
return self.set_rotation(theta=self.euler_angles[0] + dtheta)
Expand Down
1 change: 1 addition & 0 deletions manimlib/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
from manimlib.utils.bezier import *
from manimlib.utils.color import *
from manimlib.utils.config_ops import *
from manimlib.utils.customization import *
from manimlib.utils.debug import *
from manimlib.utils.directories import *
from manimlib.utils.images import *
Expand Down
Loading

0 comments on commit 83a9217

Please sign in to comment.