I’m trying to make the texture image fit a plane in three.js while keeping the ratio of it in case of page resize.
My problem is that the image fit the Plane
What I want is to “reproduce” the object-fit: cover behavior of css in three.js
So the image fit the height of the plane and the width “exceeds” outside of it
Hi!
Have a look at this forum topic: Centered background texture
You need to know ratios of width and height of an image, and width and height of a plane.
drei’s useAspect which is a css cover implementation https://github.com/pmndrs/drei#useaspect it’s just a small function, you could copy the code and adapt it. It doesn’t touch the textures but scales the mesh so that it fills the screen.
I cant make it work, maybe because im using the texture as uniform in my vertexFragment ? I got some results but none of them are doing what I want…
Here my code :
Tile : tile :: Sharemycode
Scene : scene :: Sharemycode