i have a mesh and want to give it a material that scales with it. Lets say the mesh is 80cm wide then there are 4 planks filling the texture (20cm each) of the mesh. If i scale it to 90cm there should be still 4 planks but now every plank is 22,5cm wide. If i scale the mesh to 1m (100cm ) the mesh’s material should contain 5 planks with 20cm each. And so on like in the image below.
My only working solution is to split the mesh in single “planks” but i need it to be only one single mesh for my project. Thanks for any advice on how you would solve this problem
The easiest is to use the
repeat property of the texture, setting its
y) to the number of planks.
Thanks for the answer, sorry that i wasnt specific enough, the plank Textures are individual Textures differntiating from each other. Any suggestions on that?
can you specify what you mean with this? To specify further, there should always be an integer value on planks. The example of @PavelBoytchev was already implemented exactly as intended, only thing changed, that my texture contains 10 planks.
If you study the demo and understand how the texture is scaled, there will be no problem to make it work for a texture with images of 10 planks.
I would strongly recommend to try to find the solution by yourself.
If you fail, here is a second demo with a texture of 10 planks and only integer number of them are shown. The difference is that the first demo has:
texture.repeat.set( count, 1 );
while the same line in the second demo is:
texture.repeat.set( count/10, 1 );
I wish you good luck with your project.
Thank you Pavel that looks very promising, i will study your example and try to implement it for my project.