Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow camera distance to be fixed during Animation

See original GitHub issue

The code below produces a nice video file moving from a sagittal view to a front view. However, the interpolation from the starting point to the ending point causes the camera to seemingly zoom in and zoom out. This is different from the zoom feature, but I’m lacking the vocabulary to describe the effect as anything else. My goal is to interpolate from camera_1 to camera_2 while maintaining a fixed camera distance from the focal point.

from brainrender import Scene, Animation
from rich import print
from myterial import orange
from pathlib import Path

print(f"[{orange}]Running example: {Path(__file__).name}")
    This example shows how to create an animated video by specifying
    the camera parameters at a number of key frames
# Set custom camera positions
camera_1 = {
    'pos': (7830, 4296, 36854),
    'viewup': (0, -1, 0),
    'clippingRange': (29305, 60266),
    'focalPoint': (7830, 4296, -5694),
camera_2 = {
     'pos': (-50378, 4296, -5694),
     'viewup': (0, -1, 0),
     'clippingRange': (29305, 60266),
     'focalPoint': (7830, 4296, -5694),

# Create a brainrender scene
scene = Scene(title="brain regions", inset=False)

# Add brain regions

anim = Animation(scene, "./examples", "vid4")

# Specify camera position and zoom at some key frames
anim.add_keyframe(0, camera=camera_1 , zoom=1)
anim.add_keyframe(2, camera=camera_2 , zoom=1)

# Make videos
anim.make_video(duration=3, fps=15)

In the above code the focal point, camera_1, and camera_2 all have the same value for the second axis (4296), so for this example axis 2 is constrained and I will ignore it from hereon out. Camera_1 and the focal point are aligned on axis 1, and camera_2 and the focal point are aligned on axis 3. Thus, the distance between the focal point and camera_1 should be exactly the same as the distance between the focal point and camera_2 (see figure below).

In the example code above the distance between the camera and the focal point is continuously changing during the interpolation between camera_1 and camera_2 and appears to be following the path in red. My guess is that this red path is being controlled by the ‘interpol’ parameter in the add_keyframe function which by default calls the sigma function and could be altered by defining a different interpolation function, such as one that locks the distance between the camera and focal point. Am I on the right track?

Is there a way to fix the distance between the camera and focal point during interpolation?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

FedeClaudicommented, Nov 25, 2021

Vedo is the best! It’s such a rich library, great job!

@blogeman perhaps one can use Spline and Arc to define fancy camera movements?

blogemancommented, Nov 28, 2021

Thanks, this is really useful info! I’m going to spend some time playing around and will let you know if I come up with anything that generally useful for other users.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using camera in Animate - Adobe Support
Use this article to learn how to work with camera in Animate. Camera in Animate allows animators to simulate a real-life camera.
Read more >
After Effects - Camera Focus Distance - YouTube
Work with 3D camera work with the camera tools, how to set the focus ... an animation and simulate a real camera used...
Read more >
Camera Animations - Keyshot Manual
With camera animations you can animate camera movement, rotation, focal length etc. as well as switch from one camera to another.
Read more >
Animating the Camera View Orientation - SolidWorks Web Help
Drag the key point from the Orientation and Camera Views line to the time bar, and select Place Key. Do one of the...
Read more >
Working with Cameras in After Effects - School of Motion
Let's -a-go! Camera Tutorial for After Effects. If you enjoy watching tutorials more than reading just check out the following video. The tutorial...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found