Changing diffuse map of an object

Hi! I have a problem with changing material’s diffuse map texture via JS.

At start material have no texture, only diffuse color. After an event i wan’t to change diffuse map with texture.

I am using this code

 var meshes = this.entity.model.meshInstances;       
 for(var i = 0; i < meshes.length; i++){
      meshes[i].material.diffuseMap = this.Texture;

When running this code, diffuse map changes, but it seems like it only use alpha channel of texture.
I’ve tried manualy set diffuseMapChannel to ‘rgb’ in code, but when I’d checked runtime with browser’s developer tools, it was set ‘rgb’ already.

What is the problem? What I do wrong?

Sorry for bad english.

You have to include link to sample project with isolated issue in order to let others to replicate and debug it.

I’ve created a sample project. Space bar - change diffuse map.

Have you console.log actual attribute? :slight_smile: It is pointing to Asset not Texture, to fix that, just do: this.Texture.resource - resource is pointer to actual asset resource based on type of asset.

Ohhh, I didn’t know about that.:sweat: Thank you very much!!!:slight_smile: