var image = new Image();
image.crossOrigin = “anonymous”;
image.onload = function () {
console.log(‘loaded image’);
var texture = new pc.Texture(self.app.graphicsDevice);
texture.setSource(image);
if(self.isSprite){
var sp = new pc.Sprite(self.app.graphicsDevice);
sp.atlas = texture;
self.entity.sprite.spriteAsset = sp;
}
else {
var meshInstances = self.entity.model.meshInstances;
for (var i = 0; i < meshInstances.length; ++i) {
var mesh = meshInstances[i];
mesh.material.diffuseMap = texture;
mesh.material.update();
}
}
};
image.src = this.url;
above code is working for changing the texture on a material how to do the same for sprite?