diff --git a/docs/source/examples/3d.rst b/docs/source/examples/3d.rst index 9c25ab6642..90d7ef4cba 100644 --- a/docs/source/examples/3d.rst +++ b/docs/source/examples/3d.rst @@ -1,5 +1,18 @@ + 3D Scenes ================================= +.. manim:: FixedInFrameMObjectTest + :save_last_frame: + class FixedInFrameMObjectTest(ThreeDScene): + def construct(self): + axes = ThreeDAxes() + self.set_camera_orientation(phi=75 * DEGREES, theta=-45 * DEGREES) + text3d = Text("This is a 3D text") + self.add_fixed_in_frame_mobjects(text3d) + text3d.to_corner(UL) + self.add(axes) + self.wait() + .. manim:: ThreeDSphere :save_last_frame: diff --git a/manim/camera/camera.py b/manim/camera/camera.py index 84bbdc50e3..9835f4a411 100644 --- a/manim/camera/camera.py +++ b/manim/camera/camera.py @@ -3,7 +3,7 @@ __all__ = ["Camera", "BackgroundColoredVMobjectDisplayer"] - +from functools import reduce import itertools as it import operator as op import time @@ -1039,7 +1039,7 @@ def adjusted_thickness(self, thickness): """ # TODO: This seems...unsystematic - big_sum = op.add(config["default_pixel_height"], config["default_pixel_width"]) + big_sum = op.add(config["pixel_height"], config["pixel_width"]) this_sum = op.add(self.pixel_height, self.pixel_width) factor = fdiv(big_sum, this_sum) return 1 + (thickness - 1) / factor diff --git a/manim/camera/three_d_camera.py b/manim/camera/three_d_camera.py index 55271aeeb3..0385369881 100644 --- a/manim/camera/three_d_camera.py +++ b/manim/camera/three_d_camera.py @@ -18,6 +18,7 @@ from ..utils.simple_functions import clip_in_place from ..utils.space_ops import rotation_about_z from ..utils.space_ops import rotation_matrix +from ..utils.family import extract_mobject_family_members class ThreeDCamera(Camera): @@ -367,7 +368,7 @@ def add_fixed_in_frame_mobjects(self, *mobjects): **mobjects : Mobject The mobject to fix in frame. """ - for mobject in self.extract_mobject_family_members(mobjects): + for mobject in extract_mobject_family_members(mobjects): self.fixed_in_frame_mobjects.add(mobject) def remove_fixed_orientation_mobjects(self, *mobjects): diff --git a/manim/scene/three_d_scene.py b/manim/scene/three_d_scene.py index 5065899f5d..f35ee0a477 100644 --- a/manim/scene/three_d_scene.py +++ b/manim/scene/three_d_scene.py @@ -165,7 +165,7 @@ def move_camera( anims.append(ApplyMethod(tracker.set_value, value, **kwargs)) if frame_center is not None: anims.append( - ApplyMethod(self.renderer.camera.frame_center.move_to, frame_center) + ApplyMethod(self.renderer.camera._frame_center.move_to, frame_center) ) self.play(*anims + added_anims) diff --git a/tests/control_data/graphical_units_data/threed/CameraMoveTest.npz b/tests/control_data/graphical_units_data/threed/CameraMoveTest.npz index 7c4dcd1979..4d7054c930 100644 Binary files a/tests/control_data/graphical_units_data/threed/CameraMoveTest.npz and b/tests/control_data/graphical_units_data/threed/CameraMoveTest.npz differ diff --git a/tests/control_data/graphical_units_data/threed/FixedInFrameMObjectTest.npz b/tests/control_data/graphical_units_data/threed/FixedInFrameMObjectTest.npz new file mode 100644 index 0000000000..c14f3c6101 Binary files /dev/null and b/tests/control_data/graphical_units_data/threed/FixedInFrameMObjectTest.npz differ diff --git a/tests/test_graphical_units/test_threed.py b/tests/test_graphical_units/test_threed.py index ce7cc8ae3f..8068a7323a 100644 --- a/tests/test_graphical_units/test_threed.py +++ b/tests/test_graphical_units/test_threed.py @@ -24,7 +24,7 @@ class CameraMoveTest(ThreeDScene): def construct(self): cube = Cube() self.play(Animation(cube)) - self.move_camera(phi=PI / 4, theta=PI / 4) + self.move_camera(phi=PI / 4, theta=PI / 4, frame_center=[0, 0, -1]) class AmbientCameraMoveTest(ThreeDScene): @@ -34,6 +34,17 @@ def construct(self): self.play(Animation(cube)) +class FixedInFrameMObjectTest(ThreeDScene): + def construct(self): + axes = ThreeDAxes() + self.set_camera_orientation(phi=75 * DEGREES, theta=-45 * DEGREES) + circ = Circle() + self.add_fixed_in_frame_mobjects(circ) + circ.to_corner(UL) + self.add(axes) + self.wait() + + MODULE_NAME = "threed"