[SOLVED] Dynamically creating texture assets from canvas/base64 resource

Probably something like this would work:

var texture = ...; // your texture object
var asset = new pc.Asset("asset-name", "texture", {
    url: "", // not sure exactly what you want to put in here, empty string might be fine
});
asset.resource = texture;
asset.loaded = true;

this.app.assets.add(asset);
3 Likes