mirror of
https://github.com/3b1b/manim.git
synced 2025-11-14 17:47:44 +00:00
Changed how PiCreatureScene gets creature to look at animated mobjects
This commit is contained in:
parent
b0e53b8f2a
commit
aa9d1822c7
1 changed files with 16 additions and 19 deletions
|
|
@ -293,28 +293,25 @@ class PiCreatureScene(Scene):
|
||||||
self.pi_creature.change_mode, target_mode
|
self.pi_creature.change_mode, target_mode
|
||||||
]
|
]
|
||||||
|
|
||||||
def play(self, *args, **kwargs):
|
def compile_play_args_to_animation_list(self, *args):
|
||||||
|
animations = Scene.compile_play_args_to_animation_list(self, *args)
|
||||||
if self.pi_creature not in self.get_mobjects():
|
if self.pi_creature not in self.get_mobjects():
|
||||||
Scene.play(self, *args, **kwargs)
|
return animations
|
||||||
return
|
if len(animations) == 0:
|
||||||
|
return animations
|
||||||
|
first_anim = animations[0]
|
||||||
|
if first_anim.mobject is self.pi_creature:
|
||||||
|
return animations
|
||||||
|
|
||||||
if inspect.ismethod(args[0]):
|
if isinstance(first_anim, Transform):
|
||||||
mobject_of_interest = args[0].im_self
|
mobject_of_interest = first_anim.ending_mobject
|
||||||
elif isinstance(args[0], Transform):
|
|
||||||
if args[0].mobject is self.pi_creature:
|
|
||||||
mobject_of_interest = self.pi_creature
|
|
||||||
else:
|
|
||||||
mobject_of_interest = args[0].ending_mobject
|
|
||||||
elif isinstance(args[0], Animation):
|
|
||||||
mobject_of_interest = args[0].mobject
|
|
||||||
else:
|
else:
|
||||||
raise Exception("Invalid play args")
|
mobject_of_interest = first_anim.mobject
|
||||||
|
new_anim = ApplyMethod(
|
||||||
if mobject_of_interest is self.pi_creature:
|
self.pi_creature.look_at,
|
||||||
new_anims = []
|
mobject_of_interest
|
||||||
else:
|
)
|
||||||
new_anims = [self.pi_creature.look_at, mobject_of_interest]
|
return list(animations) + [new_anim]
|
||||||
Scene.play(self, *list(args) + new_anims, **kwargs)
|
|
||||||
|
|
||||||
def blink(self):
|
def blink(self):
|
||||||
self.play(Blink(self.pi_creature))
|
self.play(Blink(self.pi_creature))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue