We’ve got some Billboards that we’re using to show coordinates by drawing to a canvas and assigning that as the Billboard’s image. Previously, we were creating a new canvas every time. I changed our code to create a canvas once, and clear it and redraw as necessary. That didn’t seem to work by itself. After digging through the Billboard source, I concluded that you actually have to re-assign to Billboard.image to trigger an update. That fixed the immediate issue.
However, I’m a bit concerned about what I think I’m seeing with the Billboard and TextureAtlas implementation. As best as I can tell, TextureAtlas has no provision for removing or updating existing images. If that’s the case, it seems that continually modifying Billboard images is going to result in the TextureAtlas repeatedly growing its internal texture, and ultimately it’s almost going to be a sort of memory leak. Is that the case, or is there something about the implementation that I’m missing?
It seems like it would be useful to have a couple new abilities for TextureAtlas and Billboard. Right now, Billboard.setImage() ignores an attempt to use the same image ID. It would be nice to allow updates to a given image ID. If the new image was the same dimensions, simply overwrite the existing region in the TextureAtlas. Then, give TextureAtlas the ability to remove or mark regions as unused, and either reuse them later, or skip them when doing a texture resize. I do realize that the latter would involve some pretty involved changes to the texture node algorithm, but there’s obviously plenty of 2D bin packing algorithms out there that could be useful.