Recording Camera Movements
Before showing you how to control the camera movement programmatically from Python, let's first learn how to record camera movements interactively.
This tutorial will teach you how to:
- Set up a logger to save camera movement data
- Create an event handler to capture camera movements
- Configure a scene with a movable camera view
By the end, you'll have a camera movement file saved to assets/camera_movement.pkl, which you can use to replay camera movements programmatically in the next tutorial.
Step 1: Create the Camera Movement Handler
When you drag the camera in the browser, Vuer emits CAMERA_MOVE events. We define an async handler function to capture these events and log them to a pickle file.
The handler receives two arguments:
event: Contains the camera data (position, rotation, matrix)sess: The current Vuer session (not used here, but available for sending responses)
Then we create the Vuer app and register our handler for CAMERA_MOVE events. The handler must be registered before starting the app.
Step 2: Set Up the Scene with a CameraView
We create a scene with a CameraView component. This renders a virtual camera that you can move around interactively.
Step 3: Running the Tutorial
Paste the code into record_camera_movement.py and run:
Then open the URL printed in the terminal (usually https://vuer.ai).
Move the camera around by dragging in the browser. Each movement will be logged to assets/camera_movement.pkl. You can then load this file in the next tutorial to replay the camera trajectory programmatically.