Rotate image texture

Good evening, everyone. I hope you’re all well,
I have a small question, I put on my 3D shirt.
a textured image with stripes, I would like to rotate the image so that the stripes are horizontal on my model.
is there a way to rotate the image before i diffuse it on the material ?

Hello!

I’m not 100% sure, but you might look at this example to see how the wheel textures are applied.
https://www.babylonjs-playground.com/#102TBD#33

These lines in particular:

//set texture for flat face of wheel
var faceUV =[];
faceUV[0] = new BABYLON.Vector4(0,0,1,1);
faceUV[2] = new BABYLON.Vector4(0,0,1,1);

If you’re working with a custom mesh, you can also adjust the UV maps with the modeling program (i.e. Blender).

https://www.babylonjs-playground.com/#T32V41

Does something like this work for you?

You can rotate the texture using some of these params vAng, uAng, wAng.

2 Likes

thnax for your reply ,
i forgot to say that im usinf pbr and wAng dosent exist with pbr
this 's my code

pbr.albedoTexture = new BABYLON.Texture(this.texture, this.scene);
pbr.metallic = 0.0;
pbr.roughness = 1;
pbr.sheen.isEnabled = true;
this.col.material = pbr;

Why wAng would not exist for pbr? It’s a property of the texture, so not related to pbr.

2 Likes

The property is a BaseTexture which does not have the param as it would for instance not fit on a CubeTexture.

You should:

const texture = new BABYLON.Texture .... ;
texture.vAngle = ...

pbr.albedoTexture = texture;

It seems VSC shows only the properties of the base type of the property declared in the declaration file for albedoTexture, which is a BaseTexture (which does not have wAng, nor uAng / vAng). But as you created a Texture, it does definitely have a wAng, uAng and vAng properties.

Try (pbr.albedoTexture as Texture).

Yes. It doesn’t show any of those props even in StandardMaterial. Just use it as shown and it will work. :slight_smile: