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

Conversation

BrendanMartin
Copy link
Contributor

This is a fix for #569.

Added import for new location of extract_mobject_family_members and removed self. from invocation in method add_fixed_in_frame_mobjects.

Acknowledgement

@kolibril13
Copy link
Member

Nice, thanks a lot for fixing this! :)
I just tested it with this script:

from manim import *

class Text3D3(ThreeDScene):
    def construct(self):
        axes = ThreeDAxes()
        self.set_camera_orientation(phi=75 * DEGREES,theta=-45*DEGREES)
        text3d=TextMobject("This is a 3D text")
        self.add_fixed_in_frame_mobjects(text3d)
        text3d.to_corner(UL)
        self.add(axes)

and it behaves like expected.
Great work!
Would you like to maybe add a test as well for this function?
That would be very beneficial for the further manimce dev!
Read the Manim CE wiki if you are not familiar with these tests.
In case you don't want to add the test, I would also give it an approve if you say that you don't have time for that and we add it to out todo list for a future pr.

@BrendanMartin BrendanMartin changed the title Fix for #569 ThreeD bug fixes Nov 3, 2020
@BrendanMartin
Copy link
Contributor Author

Some other bugs I found while rendering my ThreeDScene's:

  1. Error using move_camera with frame_center parameter:
class Example(ThreeDScene):
    def construct(self):
        cube = Cube()
        self.play(Animation(cube))
        self.move_camera(phi=PI / 4, theta=PI / 4, frame_center=[0, 0, -2])
Traceback (most recent call last):
  File "c:\users\brendan\appdata\local\programs\python\python38\lib\site-packages\manim\scene\three_d_scene.py", line 168, in move_camera
    ApplyMethod(self.renderer.camera.frame_center.move_to, frame_center)
AttributeError: 'numpy.ndarray' object has no attribute 'move_to'

Fixed by changing frame_center to _frame_center.

  1. After working on a fix for the above, I found that camera.py was missing import for reduce function
    Fixed by adding import for reduce.

  2. Running test_threed.CameraMoveTest showed that camera.py was referencing config["default_pixel_height"], config["default_pixel_width"] but there was no default_ for these values. Removed default_

Finally, made addition to CameraMoveTest by adding frame_center parameter.

The last commit fixes these new bugs.

@kolibril13
Copy link
Member

There seems to be a small differnce in the created test data and the reference data: First unmatched index is at [ 30 168]: [153 153 153 255] != [154 154 154 255].
Is the test passing locally at your machine?

@BrendanMartin
Copy link
Contributor Author

@kolibril13 yeah, the test passes locally.

@kolibril13
Copy link
Member

ok, I will test this also locally on my machine right now.

@kolibril13
Copy link
Member

kolibril13 commented Nov 4, 2020

Result, when running pytest it gives an error here:
image

E           AssertionError: The frames don't match. FixedInFrameMObject has been modified.
E           Please ignore if it was intended.
E           First unmatched index is at [29 54]: [ 15  15  15 255] != [ 20  20  20 255]

Same one as the one we got on github.
What operating system are you using?
I'm on Ubuntu 20.04.
As an idea to solve this, I could recreate the test data on my machine and commit it to your branch

@BrendanMartin
Copy link
Contributor Author

I'm on Windows 10 64. If you have time to make the test data and commit that would be great. I'm not sure why my side passes and yours doesn't

def construct(self):
axes = ThreeDAxes()
self.set_camera_orientation(phi=75 * DEGREES, theta=-45 * DEGREES)
text3d = TextMobject("This is a 3D text")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TextMobject has been deprecated; please use Text.

Without specifying the font to use, there is no chance this test will pass on all of our supported operating systems: different systems use different default fonts, this is my guess why the tests are failing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!
Thanks for this!
Therefore, I think it would be best if you could just update your test, @BrendanMartin.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this is wrong as has been pointed out on Discord: TextMobject was deprecated, but it is the old equivalent to what is Tex nowadays. I have no idea why the test outputs are different in that case, unfortunately.

@kolibril13
Copy link
Member

And one more idea:
It would be super nice to have this example in the example gallery:
https://docs.manim.community/en/latest/examples/3d.html

@BrendanMartin
Copy link
Contributor Author

@kolibril13 the circle is definitely a better idea. In the test you removed self.wait(), but the only way for the test to pass for me is to include that. Otherwise the result is empty pixels.

@kolibril13
Copy link
Member

@kolibril13 the circle is definitely a better idea. In the test you removed self.wait(), but the only way for the test to pass for me is to include that. Otherwise the result is empty pixels.

Thanks.
Oh, can you maybe push these changes with this new test data?
Recently I made a fix for this missing self.wait() but never tested it with 3d scenes: #653

@kolibril13
Copy link
Member

kolibril13 commented Nov 5, 2020

Wuhu, tests are not failing anymore!

@leotrs leotrs merged commit 1167338 into ManimCommunity:master Nov 6, 2020
@BrendanMartin BrendanMartin deleted the ThreeDScene-bug branch November 6, 2020 12:57
@BrendanMartin
Copy link
Contributor Author

Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants