Skip to content

Experimental: keyboard interaction - #4827

Open
colinrubow wants to merge 6 commits into
ManimCommunity:experimentalfrom
colinrubow:rubowfeat/keyboard_interaction
Open

Experimental: keyboard interaction#4827
colinrubow wants to merge 6 commits into
ManimCommunity:experimentalfrom
colinrubow:rubowfeat/keyboard_interaction

Conversation

@colinrubow

Copy link
Copy Markdown

Overview: What does this pull request change?

Enables interaction between the keyboard and mouse with the window.

Motivation and Explanation: Why and how do your changes improve the library?

Currently there's no such interaction. I accomplished this by giving the Scene to the pyglet opengl window and overriding pyglets interaction methods so that they call the Scenes interaction methods. I'd say there are three parts to this PR:

  1. tying the Scene's interaction methods to the opengl window's interaction methods
  2. linearly transforming pyglet window pixel coordinates to the camera coordinates
  3. changing the scaling and sensitivity of mouse motions to be reasonable (the current methods make me lose the mobjects in the scene quite easily).

Links to added or changed documentation pages

NA

Further Information and Comments

NA

Reviewer Checklist

  • The PR title is descriptive enough for the changelog, and the PR is labeled correctly
  • If applicable: newly added non-private functions and classes have a docstring including a short summary and a PARAMETERS section
  • If applicable: newly added functions and classes are tested

@colinrubow colinrubow changed the title Rubowfeat/keyboard interaction Experimental: keyboard interaction Jun 21, 2026
@henrikmidtiby

Copy link
Copy Markdown
Contributor

@colinrubow Can you explain how we can test your changes? Is there a specific scene you would suggest us to try?

@colinrubow

Copy link
Copy Markdown
Author

@henrikmidtiby There's no specfic scene to try. Just throw an object on the scene and interact with the window.
Specifically:

  1. run the scene with manim -p scene.py
  2. interaction methods:
    a) press d and move the mouse to do rotation
    b) press f and move the mouse to do panning
    c) press z and scroll to zoom
    d) scroll to pan vertically
    e) press o to print the current orientation of the camera (which can be copy and pasted directly into self.camera.set_orientation)

When the scene is done playing and is released for interaction, some instructions are printed to the terminal but the instructions aren't clear or descriptive, so this PR could probably be enhanced by making that info print better. I'll do that this evening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants