I need to be able to deform an already existing simple geometry with a material in it.
I need to make it shorter depending on parameter.
So, if I make it shorter, the texture deforms.
In order to fix that, I’d need to move its UVs exactly the same relative amount as vertices, so the texture doesn’t stretch or compress.
See this GIF animation that shows how that is accomplish inside MAYA:
Edit: I showed how to do it in the node material because that’s what you’re asking about I think, but you could also do the same thing in JS using mesh.scaling.x and texture.uScale like in this version of the PG.
My coding guy @paleRider will be happy to give that a sight.
We are trying to make a procedural way of creating wood planks of different sizes based on users input.
This is the way I thought it could be done, but you know, I come from offline 3D DCCs, so I don’t know if there are better ways to do this kind of thing.
I’ve struggling about what we want to achieve and how to do it.
As I see it, we have two options, either scale the texture (that’s what I see you do in your PG with the attribute texture.uScale), OR by scaling the UVs of the object (I don’t know if that is even possible in BabylonJS).
In both scenarios we have the same issue: we need to scale “some” parts of the UVs.
Your scene is quite simple, just a plane.
But we need to create a kind of wood plank with both variable length and thickness.
So, if we want to change the length of the wood plank, we’d just move the vertices to enlarge it, and then scale the UVs of that part of the object accordingly, BUT NOT the others. And viceversa if we want to change its thickness.
So, how do we scale SOME UVs of the object?
Can we just scale a RANGE of UVs and leave the rest intact?
So for example, if we want to enlarge the plank, then we scale in U direction the UVs from 0.0 to 0.5 ONLY.