Closed jhmitchel closed 5 years ago
Are you using the play widget? Can you just create an int slider and link that also to your time variable?
I tried using jslink to link an int slider to the time numpy array I pass into NumberKeyframeTrack. But jslink requires linking between Widget objects. Is there a way to represent time in a Widget object (as opposed to a numpy array)? Or am I misunderstanding another opportunity?
I haven't had time to play around with this myself, but from looking at the code, here are some observations:
time
attribute on AnimationAction
that might do what you want.time
attribute is not synced from JS to kernel while the animation is playing (but syncing the other way should probably work). The time is synced back to the kernel whenever the animation is stopped or paused.I tried setting the animation time input to the slider value (animation = AnimationAction(..., timeScale=playback_speed, time=slider.value)
) but then the slider had no effect on on the time of the animation. Is that what you were suggesting or am I misunderstanding?
This example actually shows very clearly what I want: https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20List.html#Play-(Animation)-widget
The problem is I don't know how to access the Play Widget of the animation (which is the mechanism used there that I would like to replicate). Any thoughts there?
You would have to link the time values using jslink, as you see in your linked example:
animation = AnimationAction(...)
ipywidgets.jslink((animation, 'time'), (slider, 'value'))
One improvement on the pythreejs side would be to have AnimationAction
sync its time back to the kernel in a conflatable way.
Agreed a two way link would be an improvement. But what you suggested worked one way. Thank you!
Nice, thanks for reporting back :)
Closing as answered then, but let me know if there is anything outstanding here, and I'll reopen.
Relatively new to pythreejs. I created an animation that has gotten quite long. The only time controls for the widget are play, pause, stop, and reset. I can't seem to find any support or guidance on how to add time controls where one could select a time (either via a scrubber or directly entering a value) in the animation to jump to.
Is this supported (either directly or indirectly)? If so, what is the best method or tool for this.