Change box UVs on create

Hey,
I’m creating a box with texture on it. As expected, based on box dimensions the texture is stretching. Here come 2 solutions

  1. Update uScale or vScale on texture, which work good.
  2. Create the box directly with desired UVs. …With this method I have some issues on understanding it. - Apply Material to Individual Faces - Babylon.js Documentation

https://playground.babylonjs.com/#0H7PV7#4 - line 27
First box from top is one basic box, without any changes, in the midle is the 2nd above solution which looks like it is not working. And the 3rd is corect displayed, using first above method.
Thanks :wink:

not sure to get what you want to achieve with the faceUV parameter in this case …
This parameter allows you to set a different part from the same texture/image to each box face. It doesn’t scale the texture.

1 Like

Hi @jerome. Sorry if I was unclear and for this late reply.
I was able to solve it at the end. Here is: https://playground.babylonjs.com/#0H7PV7#9

I understood what faceUV doing, but I think, as you can see in the above example, it can be used to ‘simulate’ this texture scaling.
Like this I avoid to clone the material if the box has a different size. Much better than the previous option, where I had to do this.

1 Like

I misunderstood your goal, sorry.
Glad you could achieve it.