diff --git a/manimlib/camera/camera.py b/manimlib/camera/camera.py index 921bcbe8..16a1e4f0 100644 --- a/manimlib/camera/camera.py +++ b/manimlib/camera/camera.py @@ -184,7 +184,7 @@ class Camera(object): self.frame.move_to(center) def pixel_coords_to_space_coords(self, px, py, relative=False): - pw, ph = self.get_pixel_shape() + pw, ph = self.fbo.size fw, fh = self.get_frame_shape() fc = self.get_frame_center() if relative: @@ -192,11 +192,7 @@ class Camera(object): else: # Only scale wrt one axis scale = fh / ph - return np.array([ - scale * (px - pw / 2) - fc[0], - scale * (py - py / 2) - fc[0], - -fc[2] / 2, - ]) + return fc + scale * np.array([(px - pw / 2), (py - ph / 2), 0]) # TODO, account for 3d # Also, move this to CameraFrame? @@ -293,7 +289,7 @@ class Camera(object): mapping = { 'scale': fh / 2, # Scale based on frame size 'aspect_ratio': (pw / ph), # AR based on pixel shape - 'anti_alias_width': ANTI_ALIAS_WIDTH, + 'anti_alias_width': ANTI_ALIAS_WIDTH_OVER_FRAME_HEIGHT * fh, 'frame_center': tuple(fc), } for key, value in mapping.items(): diff --git a/manimlib/shaders/set_gl_Position.glsl b/manimlib/shaders/set_gl_Position.glsl index e83900d6..12e8fa1a 100644 --- a/manimlib/shaders/set_gl_Position.glsl +++ b/manimlib/shaders/set_gl_Position.glsl @@ -5,8 +5,8 @@ void set_gl_Position(vec3 point){ // TODO, orient in 3d based on certain rotation matrices + point -= frame_center; point /= scale; point.x /= aspect_ratio; - point -= frame_center; gl_Position = vec4(point, 1.0); } \ No newline at end of file diff --git a/manimlib/window.py b/manimlib/window.py index 7e9ac290..d39d2d7f 100644 --- a/manimlib/window.py +++ b/manimlib/window.py @@ -43,7 +43,7 @@ class Window(PygletWindow): super().on_mouse_drag(x, y, dx, dy, buttons, modifiers) point = self.pixel_coords_to_space_coords(x, y) d_point = self.pixel_coords_to_space_coords(dx, dy, relative=True) - self.scene.on_mouse_drag(point, d_point, buttons, modifiers) # Do a conversion? + self.scene.on_mouse_drag(point, d_point, buttons, modifiers) def on_mouse_press(self, x: int, y: int, button, mods): super().on_mouse_press(x, y, button, mods)