I am creating textures (heightmaps/colormaps) dynamically on app load time using an offscreen canvas. Everything works great and the created image element produces a pc.Texture.
But if I would like this texture to be registered as an asset in the registry, what should I do? I want this mainly for memory management and using the asset unload method.
I tried using a base64 string from the image on the url property of the pc.Asset constructor, with no success (non expected).
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);