[SOLVED] How to add texture to an already loaded model

I am using PlayCanvas API for loading a model (app.assets.loadFromUrl(url, "model", function (err, asset) {
) inside my canvas, once the model is loaded I want to change the texture. I do it like this: loadedModel.getMaterials()[0].diffuseMap = asset.resource but the texture map stays the same and it is not changed.

How should I do this properly?

I solved it by calling