cesium icon indicating copy to clipboard operation
cesium copied to clipboard

imageSubRegion not display

Open mivui opened this issue 10 months ago • 2 comments

https://sandcastle.cesium.com/?src=Billboards.html&label=All

Add maker billboards

mivui avatar Apr 27 '25 02:04 mivui

Thanks @mivui, I can also reproduce the issue.

ggetz avatar May 01 '25 13:05 ggetz

Hi, can this issue be fixed in the next version? It is impossible to use sprites on the map for now.

plainheart avatar Jun 07 '25 14:06 plainheart

[email protected] works properly.

mivui avatar Jul 27 '25 02:07 mivui

Unfortunately, this bug persists from Cesium 1.127 to 1.132.

plainheart avatar Aug 02 '25 05:08 plainheart

@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. 🙏

v.126 Sandcastle

>= v1.127 Sandcastle

This bug may be introduced in #12495.

plainheart avatar Oct 07 '25 15:10 plainheart

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;
    }

Beilinson avatar Oct 08 '25 14:10 Beilinson

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.

plainheart avatar Oct 09 '25 03:10 plainheart

Confirmed fixed in sandbox link, thanks @Beilinson!

donmccurdy avatar Dec 01 '25 20:12 donmccurdy