-
Notifications
You must be signed in to change notification settings - Fork 2.2k
3D Lines Bending and Changing Colour When Endpoints are Far Away #4243
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
Comments
The bending is most likely caused by perspective distortion. Try to use a longer "focal distance". Just for highlighting your problem, here is the rendered output of your code with the bug uncommented: class BendingLine(ThreeDScene):
def construct(self):
# Create a point, and move it far away in a particular direction. You get
# different bugs depending on the starting point and direction
point = np.array([1, 0, 0], dtype=np.float64)
# Uncomment one of these lines to see different bugs
# direction = np.array([1, 1, 0], dtype=np.float64) # works correctly
# direction = np.array([2, 0, -1], dtype=np.float64) # line spreads out
direction = np.array([2, 0.1, -1], dtype=np.float64) # line curves
# direction = np.array([-100000, 0, 0], dtype=np.float64) # line stays straight, but changes colour
far_point = point - direction * 100
# create line
line = Line3D(ORIGIN, far_point)
self.add(line) class BendingLine(ThreeDScene):
def construct(self):
# Create a point, and move it far away in a particular direction. You get
# different bugs depending on the starting point and direction
self.camera.set_focal_distance(10000)
point = np.array([1, 0, 0], dtype=np.float64)
direction = np.array([2, 0.1, -1], dtype=np.float64) # line curves
far_point = point - direction * 100
# create line
line = Line3D(ORIGIN, far_point)
self.add(line) |
Thanks. Does that mean the line is supposed to bend like that? |
it's distortion, just like with a true real-world camera lens. |
Okay, that's good. So the only bug is that the lines change colour. |
also this is - I assume - not a bug. It's a matter of reflection of the light source in the scene. class BendingLine(ThreeDScene):
def construct(self):
# Create a point, and move it far away in a particular direction. You get
# different bugs depending on the starting point and direction
self.camera.set_focal_distance(10000)
point = np.array([1, 0, 0], dtype=np.float64)
direction = np.array([2, 0.1, -1], dtype=np.float64) # line curves
far_point = point - direction * 100
# create line
line = Line3D(ORIGIN, far_point, color=PURE_BLUE)
self.add(line) I suggest you come over to Discord and explain what you want to achieve and how you are hindered by ManimCE. The volunteer helpers there will help you. Discussing whether something is a bug or not on very limited details here seems not to be leading anywhere. |
Changing the thickness (default value is 0.02) of the line or rendering at a higher resolution also gives your lines back more of the low-saturation default colors: class BendingLine(ThreeDScene):
def construct(self):
# Create a point, and move it far away in a particular direction. You get
# different bugs depending on the starting point and direction
self.camera.set_focal_distance(10000)
point = np.array([1, 0, 0], dtype=np.float64)
direction = np.array([2, 0.1, -1], dtype=np.float64) # line curves
far_point = point - direction * 100
# create line
line = Line3D(ORIGIN, far_point, thickness=0.1, color=BLUE)
self.add(line) |
Your first comment was exactly what I needed. I just left the issue open because I thought there was something in manim that needed to be fixed. If it's not a bug, then I'll close the issue. Thank you for your help. |
Description of bug / unexpected behavior
When the end points of a 3D line are too far outside the scene, the line changes colour, and sometimes curves. I could work around it by moving the end point closer, it was just inconvenient. I've tested it in 2D, and the bug only seems to be present in 3D.
Expected behavior
The line should stay the same colour, and stay straight.
How to reproduce the issue
Code for reproducing the problem
Additional media files
Images/GIFs
These are the different results you get when uncommenting each of the lines in the code above
Correct behaviour:

Incorrect behaviour:



Logs
Terminal output
System specifications
System Details
python/py/python3 --version
): 3.13.1pip list
):LaTeX details
Additional comments
The text was updated successfully, but these errors were encountered: