3D Viewer: Animate addition of new mesh

3d-viewer
imagej
#1

@SebT @bene.schmid @ctrueden @albertcardona

Has one of you tried to smoothly animate this:

universe.adjustView( content );

Right now it changes the point of view immediately from the current view to a new view in which the content is centered. Thus, the user does not have a feel for where this content is relative to the previous view point. It would be really nice to be able to animate this. I guess I could figure this out somehow, e.g. reusing some of the bdv code (https://javadoc.scijava.org/Fiji/bdv/viewer/animate/SimilarityTransformAnimator.html)

But if someone has already some relevant code for the 3d-viewer that would help a lot to get started!

0 Likes

#2

It’s basically an interpolation between affine transforms, with as many steps in between as desired. I don’t have a script for this, but it shouldn’t be hard.

1 Like

#3

Thanks! In terms of API, do you happen to know whether this can be achieved by sequentially calling this function universe.setGlobalTransform( )?

0 Likes

#4

That sounds right. Why not just try it?

2 Likes

#5

This works. I coded an animation feature in VisBio like that many years ago. But depending on the start and end transforms, you can get weird effects—the scene “bending” from one position to another, rather than e.g. rotating as intended. My thinking at the time was that something slightly more sophisticated would be needed to make the transitions nicer, by treating the scale and rotation values differently somehow.

1 Like

#6

In SciView you just animate the camera’s position…

1 Like

#7

Looking forward to the day when SciView “just works”, like the 3D Viewer does. Took a long time and dedication for the 3D Viewer to reach that state of grace!

0 Likes

#8

Indeed, the bending will be an issue. An alternative is to separate the scaling and rotating components, to make sure the transform is always rigid.

0 Likes

#9

When you get back maybe @tferr and I will have finished the SNT + SciView integration :smiley: It is essentially done for loading basic SWCs.

0 Likes

#10

Looking forward to trying it out!

0 Likes

#11

Thanks all for the helpful comments!
I started to look into it but got a bit stuck, because I am, in fact, having the aim to link my view of the data in Bdv with the one in the 3DViewer. And I did not yet manage to figure out how the GlobalTransform in 3DViewer and the ViewerTransform (AffineTransform3D) in Bdv are mathematically related to each other. If anyone has already code or tips for that, that would be amazing :slight_smile:

0 Likes

#12

@albertcardona
As mentioned above, my plan was to reuse the code from here: https://javadoc.scijava.org/Fiji/bdv/viewer/animate/SimilarityTransformAnimator.html
The name (Similarity) suggests that this is a rigid way of going from view A to view B. Maybe that could help with the bending? But, as mentioned above as well, I did not yet figure out how convert the 3DViewer transform and the BdvViewer transforms into each other…

0 Likes

#13

I managed to get something simple working by modifying the ij3d.ViewAdjuster class.

This looks much smoother in reality, the judder was introduced by conversion to an animated gif.

Code currently lives here:

Happy easter everyone :slight_smile:

0 Likes