Open Mixnik26 opened 3 years ago
@Mixnik26 I added the argument shade_in_3d=True
when calling Square
and it fixed it for me. It seems doing this for any 2D mobject turns it into a 3D mobject.
from manim import *
class Scene(ThreeDScene):
def construct(self):
tetra = Tetrahedron()
plane = Square(side_length=5, color=WHITE, fill_opacity=0.4, shade_in_3d=True)
_3D = ThreeDAxes()
self.add(_3D)
self.move_camera(phi=65*DEGREES, theta=-45*DEGREES)
self.play(FadeIn(plane))
self.play(FadeIn(tetra.shift([0,0,1])))
self.play(Rotate(plane, 90*DEGREES, about_point=ORIGIN))
self.wait()
Here is the output of the above code on my machine:
Is this solution suitable for you?
shade_in_3d
seems to be the way to go when dealing with 2D Mobjects in a 3D scene. However, it could be great if these Mobjects had the attribute effect applied when creating (or animating) them:
Result:
An example of this issue is with a tetrahedron (Tetrahedron()) and a 2D plane (Square()), where, if you rotate the plane, it would overlay above the tetrahedron even if the tetrahedron has a higher z-coordinate: `
` This will output:
https://user-images.githubusercontent.com/90397670/132694874-f888ebd8-7e18-4adf-8c8b-4372aff57f94.mp4
The Square Mobject overlays itself over the Tetrahedron when the rotation animation plays. z_index() does not affect this outcome, I've attempted to give the Square Mobject a lower z_index multiple times with the same result. The only way I've found to fix this is by defining the plane as a Polyhedron(): `
` This outputs what I was looking for:
https://user-images.githubusercontent.com/90397670/132695649-6bf88c5d-bb37-4828-9359-ba7d607c8525.mp4