Issue adding multiple textures to a material using the sketchfab viewer api

I’m currently working on a product configurator to switch out materials. I have chosen to upload the textures on runtime when a button is pressed (because of the many textures I plan on using) and then updating the existing material with the new texture UID (currently 3 different textures per material switch). I’m using a similar method explained in the viewer api. Im currently adding each texture one by one and then updating the material once I get confirmation the texture UIDs have been created and stored to the proper channels.

The problem I’m running into is on first load (w/ cleared cache) the textures that are updated appear to be uploaded flipped. Once I select another material and then re-select the material with the textures cached in memory they appear correctly. This issue doesn’t happen when only updating just one texture.

Can someone help me with this, I’m not certain what can be causing this issue? Is there a better way to add a batch of textures with the method explained in the viewer api?

Edit:* I added a codepen example of the issue.

I found the issue, it was in my code. I was using a global variable and was being re-written during the async texture fetching. Causing textures to be placed in wrong slots of the model.

1 Like