Skip to content

ThreeD bug fixes #674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/source/examples/3d.rst
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions manim/camera/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

__all__ = ["Camera", "BackgroundColoredVMobjectDisplayer"]


from functools import reduce
import itertools as it
import operator as op
import time
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion manim/camera/three_d_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion manim/scene/three_d_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Binary file modified tests/control_data/graphical_units_data/threed/CameraMoveTest.npz
Binary file not shown.
Binary file not shown.
13 changes: 12 additions & 1 deletion tests/test_graphical_units/test_threed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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"


Expand Down