[SOLVED] Weird material exeption

I have a suspicion that the ‘UV channel’ is preventing me from changing a material:
The following should work:

var self = this; 
        var img = self.app.assets.find('Bottom_NegY.png');
    var image =   new Image();

        var texture = new pc.Texture(self.app.graphicsDevice);
        texture.setSource(image);

        var material = new pc.StandardMaterial();
        material.diffuseMap = texture; 
        material.update();         
        
        self.app.root.findByName("SphereNormText").model.meshInstances[0].material=material;

The script seem to be executing (no err msg in console), but the material doesn’t change?

can the fact that the model is using a material with; UV channel: UV1, be the cause?

Hi @Thomas_Due_Nielsen,

What exactly are you trying to do? Are you trying to change the diffuse map of a material?

I think it would be much simpler to do this:

var material = self.app.root.findByName("SphereNormText").model.meshInstances[0].material;
var textureAsset = self.app.assets.find('Bottom_NegY.png');

material.diffuseMap = textureAsset.resource;
material.update();

ok, thanks that works … got lost at other examples (at forum-topics)

1 Like