nglview icon indicating copy to clipboard operation
nglview copied to clipboard

Smooth transitions

Open SylvainCorlay opened this issue 7 years ago • 4 comments

For animations, it could be really nice to have smooth interpolation between object positions.

If you check out the demo for ipyvolume here: http://jupyter.org/widgets, you see that even with a very large time step, it makes animations look pretty nice.

SylvainCorlay avatar Apr 22 '18 20:04 SylvainCorlay

yeah I agree. We implemented the smoothing a bit but I admitted I did not spend much effort in it.

https://github.com/arose/nglview/blob/f6b665d56fb1d07ccad4447e420c353341ff7ae5/nglview/widget.py#L691-L692

I will keep this issue in mind. Thanks.

hainm avatar Apr 22 '18 20:04 hainm

I think that this is something that you can do on the javascript side, and would remain when embedding.

SylvainCorlay avatar Apr 22 '18 20:04 SylvainCorlay

ah, I think either sides is ok. The python side will compute and save the smoothed trajectory coordinates. We can update this chunk of code https://github.com/arose/nglview/blob/f6b665d56fb1d07ccad4447e420c353341ff7ae5/nglview/widget.py#L200-L215

hainm avatar Apr 22 '18 20:04 hainm

uhm, I still don't know a proper way to smooth a trajectory on the fly in the context of nglview, so I made a "smooth" function so user can "smooth" his/her trajectory.

With the code, the animation seems nicer. Thanks @SylvainCorlay for your suggestion.

I think that this is something that you can do on the javascript side, and would remain when embedding.

I admit that I am much more efficient with python code. :( There's one possible technical issue: nglview does not send all data (3D coordinates) for frontend but sending a single snapshot at a time. So it's easier do to the smoothing in backend.

This animation is from my screen capture. membrane2

hainm avatar May 01 '19 03:05 hainm