How do I update an existing texture with new Bitmap data, or delete an existing texture?

As the title suggests, I need to figure out how to update an existing texture. I can’t just add new textures, as that would be terrible for memory. Destroying the texture and loading a new one is a possibility as well.

Hello! I found that one way to destroy a texture is to access the texture manager (from within a scene, this means “this.load.textureManager” and call its remove(key) function.
See https://photonstorm.github.io/phaser3-docs/Phaser.Textures.TextureManager.html#remove__anchor
However, in attempting to do this, I’ve discovered that it appears you cannot later re-load a texture with the same key; when I later call this.load.image, say, with the same key and the same PNG file, the key is not added to the texture manager’s list of keys.
If you can figure out a way around this, please let me know! I’m struggling with this, too.

Hey Peter,
I found a solution to this by doing the following:

if(this.scene.textures.exists(textureName)) this.scene.textures.remove(textureName);

var img = document.createElement("img");
img.src = canvas.toDataURL("image/png");
img.addEventListener('load', ()=>{
    this.scene.textures.addImage(textureName, img);
});

Hope that helps!

Thank you so much for responding.
What does this code do exactly? How can I modify it so that it adds multiple textures to the Texture Manager? Right now it seems to only work for one image.
Also, I notice that there’s no place for a URL of the PNG file that I want to use to create textures. How can this work without that?