imageSubRegion not display
https://sandcastle.cesium.com/?src=Billboards.html&label=All
Add maker billboards
Thanks @mivui, I can also reproduce the issue.
Hi, can this issue be fixed in the next version? It is impossible to use sprites on the map for now.
[email protected] works properly.
Unfortunately, this bug persists from Cesium 1.127 to 1.132.
@ggetz @mzschwartz5 @javagl Hello, could you please take a look at this bug that has been persisting from version 1.127 through to the latest version 1.134? It's been blocking our progress for months, forcing us to remain on v1.126. We'd really appreciate your help resolving this. 🙏
This bug may be introduced in #12495.
BillboardTexture.prototype.addImageSubRegion = async function (id, subRegion) {
this._id = id;
this._loadState = BillboardLoadState.LOADING;
this._loadError = undefined;
this._hasSubregion = true;
let index;
const atlas = this._billboardCollection.textureAtlas;
try {
index = await atlas.addImageSubRegion(id, subRegion);
} catch (error) {
// There was an error loading the referenced image
this._loadState = BillboardLoadState.ERROR;
this._loadError = error;
return;
}
if (!defined(index) || index === -1) {
this._loadState = BillboardLoadState.FAILED;
this._index = -1;
this._width = undefined;
this._height = undefined;
return;
}
this._width = subRegion.width;
this._height = subRegion.height;
this._index = index;
this._loadState = BillboardLoadState.LOADED;
this.dirty = true;
};
I've found the source of the bug, this method gets called every frame in the update cycle (which happens before the render): https://github.com/CesiumGS/cesium/blob/2ffac63c04b626536151f96122cc5c19e5426bb0/packages/engine/Source/DataSources/BillboardVisualizer.js#L235-L238
It sets the texture state to LOADING, and can only resolve after the frame. This means at the beginning of every frame render the texture is considered LOADING (in fact, it is, this queues up a growing number of promises needlessly).
BillboardVisualizer has the following check for updating the image itself, something similar should be added to the subregion:
if (item.textureValue !== textureValue) {
billboard.image = textureValue;
item.textureValue = textureValue;
}
Thank you @Beilinson for investigating this bug. I really appreciate your recent work on improving the label, billboard, and picking performance! - These are all I look forward to.
Confirmed fixed in sandbox link, thanks @Beilinson!