Changing Uvs while scaling the model

Hi there,
I have a basic 3D model (a rectangular box from an FBX file format) imported in Threejs with an applied texture. I need to scale it horizontally and vertically without stretching the texture but repeating it as infinite pattern.

If I scale it horizontally that’s the result:

I also looked at this thread: https://discourse.threejs.org/t/updating-uv-coordinates-of-buffergeometry/9180
where I need to obtain the similar effect in and I tried to apply the solution that “Mugen87” proposed.

Nevertheless the texture seems to be stretched as the uvs don’t update correctly.
Here is the code that I use:


As you see I update the model coordinates but the uvs don’t change.
I also set the textures like this:

const texture = new THREE.TextureLoader().load( ‘models/mensola/texture/34056_SU_CENERE.jpg’ );
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set( 1, 1);
texture.needsUpdate = true;

but it doesn’t seem to work.

Can you please help me?

Thanks a lot,

Francesco.

Hey there! I was wondering if you were able to find a solution for this.

Iam currently running into exactly the same problem,

Kind regards,

Darryn

From looking at the documentation, this seems rather obvious to me:

.repeat : Vector2

How many times the texture is repeated across the surface, in each direction U and V. If repeat is set greater than 1 in either direction, the corresponding Wrap parameter should also be set to THREE.RepeatWrapping or THREE.MirroredRepeatWrapping to achieve the desired tiling effect. Setting different repeat values for textures is restricted in the same way like .offset.

The thread starter seems to be explicitely requesting a “repeat” of exactly 1, which would be no repeat at all:

texture.repeat.set( 1, 1);

I would expect a

texture.repeat.set( scalex, scaley);

to do the trick, assuming the box is scaled by scalex, scaley, respectively.

1 Like