How to do the Tao Tajima menu gallery image snap into viewport animation

So I’m doing this project of mine where I’m testing some designs and I saw website and I was wondering how to do their gallery image snap into viewport animation. I made this image texture with some noise for wave effect and now I have some trouble snapping the image to the viewport. How can I do it. Here’s my sandbox link for what I have so far,

In your vertex shader, you transform the vertices with:

        gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.);

If you instead pass the untransformed vertices directly, it will map to the viewport itself. (Although stretched to the screen bounds).

So my guess is that you could tie this behavior to a transition uniform value 0 to 1 and do something like:

vec4 positionWorld = projectionMatrix * modelViewMatrix * vec4(pos, 1.);
vec4 positionScreen = vec4(pos, 1.); //You may need to adjust X by the aspect ratio
gl_Position = mix(positionScreen,positionWorld, uScreenTransition );

It was a little more complex than I thought since the aspect ratio of the image needed to be taken into account. I fixed it up to scale the image to whichever axis fit better into the aspect ratio…

Something like this:

1 Like

So I found this article on Codrops that does this effect I’m looking for, and the I cloned his project and did some editing, you can check it out. :hugs:, when you click on a grid it expands and when you click on menu it collapse back to it’s initial position.

1 Like