We’ve got a Cesium application that started on b17. We upgraded to b29 a couple months ago, and I’m now looking at upgrading to 1.0. We have a couple of sprite sheet images that we were loading into a TextureAtlas, specifying subregions for the various icons, and then passing the TextureAtlas around so that it could be assigned to a couple different BillboardCollections. In this case, we have a bunch of 48x48 icons, arranged in a 9x6 grid. Our data models later calculate the correct icon index based on various attributes. The idea here is that we set up the texture once, and each billboard just needs to know which part it refers to.
In looking at the changes for 1.0, I see that TextureAtlas has been removed from the public API, and we are now supposed to only use the methods supplied in the Billboard class. However, I’m having trouble seeing how to update our code to handle this use case. There doesn’t seem to be any way to pre-specify all the subregions at once.
Any suggestions for how to handle migrating this part of the code?
Mark Erikson
Using a pre-existing texture atlas is still possible. The Billboard handles this case using either:
- Parameters to BillboardCollection.add, specifically the ‘image’ and ‘imageSubRegion’ parameters. If you create several billboards using the same ‘image’ URL, but use different ‘imageSubRegion’ BoundingRectangles, they will only load the image once and share the same texture atlas across all the billboards.
The “addMarkerBillboards” function in the Billboards Sandcastle example demonstrates this.
http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Billboards.html&label=Showcases
- If you need to change the subRegion after construction, for example to switch between textures in an atlas, Billboard.setImageSubRegion can do that.
The issue is that our existing code pre-generated all the subregions at the time the image was originally loaded, so we didn’t have to worry about dealing with specific region coordinates later. Looking things over, the only thing I can come up with is that I’ll have to rewrite the code that calculated the image indices to return a BoundingRectangle instead.