Changing diffuseMapUv for an object with multiple UV Channels

Hi everyone. I have an Object with 17 uv channels and I want to set the diffuseMapUv differently for every time when in spawns but unfortunately it is not changing when I’m launching it here is my Code for it:

when I’m launching the scene it just sets the Material’s UV channel to 0

would you please help me

hi there Majid_Ahmady

Try calling tvMat.update(); after making any changes to the material


Hi Francisco. Thanks for the reply. I tried it. it didn’t work. :neutral_face:
here is the link to the sample project:

OK this was a tricky one for me. I forked your project to do some testing:

UV’s of the model were imported just fine. I think the issue here is StandardMaterials do not support more than 2 UV sets (UV0 and UV1). Am I right in this one @yaustar?

The trick here is to switch the UVs of the mesh itself.
I’ve set up an interval of 3sec and then the UV’s of channel 0 are replaced with the Uvs of the next channel.
Be careful to store the UVs o channel 0 somewhere because they’ll be lost after you replace them once. I did not cover for that in my sample

EDIT: Also if you look at the docs it seems UVs can go from range 0 to 7

So maybe you’ll have to import different models to get every 7 sets of Uvs

1 Like

Thank you Francisco. this was very helpful. Now I have another problem I needed 17 UVs and since it’s limited to 7 :sweat_smile:. I think I need 3 different models.

That’s right!

With 3 models you can get all 17 uv sets you need. Just add them to the project, reference them into an array and you can iterate their uvs.

MyScript.attributes.add("sourceModels", {type:"entity", array:true});

this.sourceUvs = []

let tmp = [];
for (i = 0; i<this.sourceModels.length; i++) {
   for (j=0; j<7; j++) {
      this.sourceUvs.push(this.sourceModels.model.meshInstances[0].mesh.getUvs(j, tmp);
      tmp = [];


@slimbuck Did we make a change recent that allowed more UV maps? If we did, was there an upper limit?

1 Like

Oh this is great. Thanks again :slightly_smiling_face:

1 Like

Yes we fixed a bug ab 2 months ago to export up to 8 texture coordinate sets to GLB. JSON models only support 2 UV sets.

1 Like

The reason this doesn’t just work correctly is because of some nasty code in the material options builder here.