yt-project / yt_idv

Interactive volume rendering for yt
Other
8 stars 6 forks source link

Keyframing support #80

Open matthewturk opened 1 year ago

matthewturk commented 1 year ago

yt has keyframe tracking functionality, which can be used. Here's a simple script (which requires a fix to the keyframe that I'm about to issue a PR for) that shows it.

class Track:
    def __init__(self):
        self.pos = []
        self.up = []
    def snapshot(self, cam):
        self.pos.append(cam.position)
        self.up.append(cam.up)

from yt.visualization.volume_rendering.camera_path import Keyframes
cam = rc.scene.camera
t.snapshot(cam)
t.snapshot(cam)
t.snapshot(cam)
t.snapshot(cam)
import numpy as np
x, y, z = np.array(t.pos).T
up = np.array(t.up)
K = Keyframes(x, y, z, up_vectors = up)
path = K.create_path(100)
for i in range(path['position'].shape[0]):
    cam.position = path['position'][i,:]
    cam.up = path['up_vectors'][i,:]
    rc.scene.render()
    rc.snap()

We should expose this functionality.