mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Simpler move_lighthouse_to
This commit is contained in:
parent
59d81feb26
commit
d7b84b0507
1 changed files with 6 additions and 14 deletions
|
@ -187,11 +187,12 @@ class LightSource(VMobject):
|
||||||
self.update_shadow()
|
self.update_shadow()
|
||||||
|
|
||||||
def update_lighthouse(self):
|
def update_lighthouse(self):
|
||||||
new_lh = Lighthouse()
|
self.lighthouse.move_to(self.get_source_point())
|
||||||
new_lh.move_to(ORIGIN)
|
# new_lh = Lighthouse()
|
||||||
new_lh.apply_matrix(self.rotation_matrix())
|
# new_lh.move_to(ORIGIN)
|
||||||
new_lh.shift(self.get_source_point())
|
# new_lh.apply_matrix(self.rotation_matrix())
|
||||||
self.lighthouse.submobjects = new_lh.submobjects
|
# new_lh.shift(self.get_source_point())
|
||||||
|
# self.lighthouse.submobjects = new_lh.submobjects
|
||||||
|
|
||||||
def update_ambient(self):
|
def update_ambient(self):
|
||||||
new_ambient_light = AmbientLight(
|
new_ambient_light = AmbientLight(
|
||||||
|
@ -416,7 +417,6 @@ class AmbientLight(VMobject):
|
||||||
|
|
||||||
|
|
||||||
class Spotlight(VMobject):
|
class Spotlight(VMobject):
|
||||||
|
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
"source_point": VectorizedPoint(location = ORIGIN, stroke_width = 0, fill_opacity = 0),
|
"source_point": VectorizedPoint(location = ORIGIN, stroke_width = 0, fill_opacity = 0),
|
||||||
"opacity_function" : lambda r : 1.0/(r/2+1.0)**2,
|
"opacity_function" : lambda r : 1.0/(r/2+1.0)**2,
|
||||||
|
@ -445,13 +445,10 @@ class Spotlight(VMobject):
|
||||||
w = project_along_vector(point,v)
|
w = project_along_vector(point,v)
|
||||||
return w
|
return w
|
||||||
|
|
||||||
|
|
||||||
def get_source_point(self):
|
def get_source_point(self):
|
||||||
return self.source_point.get_location()
|
return self.source_point.get_location()
|
||||||
|
|
||||||
|
|
||||||
def generate_points(self):
|
def generate_points(self):
|
||||||
|
|
||||||
self.submobjects = []
|
self.submobjects = []
|
||||||
|
|
||||||
self.add(self.source_point)
|
self.add(self.source_point)
|
||||||
|
@ -467,7 +464,6 @@ class Spotlight(VMobject):
|
||||||
new_sector = self.new_sector(r,dr,lower_angle,upper_angle)
|
new_sector = self.new_sector(r,dr,lower_angle,upper_angle)
|
||||||
self.add(new_sector)
|
self.add(new_sector)
|
||||||
|
|
||||||
|
|
||||||
def new_sector(self,r,dr,lower_angle,upper_angle):
|
def new_sector(self,r,dr,lower_angle,upper_angle):
|
||||||
alpha = self.max_opacity * self.opacity_function(r)
|
alpha = self.max_opacity * self.opacity_function(r)
|
||||||
annular_sector = AnnularSector(
|
annular_sector = AnnularSector(
|
||||||
|
@ -504,7 +500,6 @@ class Spotlight(VMobject):
|
||||||
else:
|
else:
|
||||||
return -absolute_angle
|
return -absolute_angle
|
||||||
|
|
||||||
|
|
||||||
def viewing_angles(self,screen):
|
def viewing_angles(self,screen):
|
||||||
|
|
||||||
screen_points = screen.get_anchors()
|
screen_points = screen.get_anchors()
|
||||||
|
@ -531,7 +526,6 @@ class Spotlight(VMobject):
|
||||||
|
|
||||||
return lower_ray, upper_ray
|
return lower_ray, upper_ray
|
||||||
|
|
||||||
|
|
||||||
def opening_angle(self):
|
def opening_angle(self):
|
||||||
l,u = self.viewing_angles(self.screen)
|
l,u = self.viewing_angles(self.screen)
|
||||||
return u - l
|
return u - l
|
||||||
|
@ -551,7 +545,6 @@ class Spotlight(VMobject):
|
||||||
self.update_sectors()
|
self.update_sectors()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
def update_sectors(self):
|
def update_sectors(self):
|
||||||
if self.screen == None:
|
if self.screen == None:
|
||||||
return
|
return
|
||||||
|
@ -567,7 +560,6 @@ class Spotlight(VMobject):
|
||||||
# submob.set_fill(opacity = 10 * self.opacity_function(submob.outer_radius))
|
# submob.set_fill(opacity = 10 * self.opacity_function(submob.outer_radius))
|
||||||
Transform(submob, new_submob).update(1)
|
Transform(submob, new_submob).update(1)
|
||||||
|
|
||||||
|
|
||||||
def dimming(self,new_alpha):
|
def dimming(self,new_alpha):
|
||||||
old_alpha = self.max_opacity
|
old_alpha = self.max_opacity
|
||||||
self.max_opacity = new_alpha
|
self.max_opacity = new_alpha
|
||||||
|
|
Loading…
Add table
Reference in a new issue