Skip to content

Conversation

@Beilinson
Copy link
Contributor

@Beilinson Beilinson commented Oct 8, 2025

Description

As per #12585, image subregions currently do not work since 1.127. The cause was a conditionless addImageSubregion call on the BillboardVisualizer every frame prior to rendering, which resulted in a large promise queue but also made sure that image.state was LOADING for every render.

This PR adds a comparison against the previous loading subRegion, which skips adding a new subregion if not needed, letting the first call resolve properly and set the state to LOADED.

image

Issue number and link

#12585

Testing plan

Sandboxes from #12585

Author checklist

  • I have submitted a Contributor License Agreement
  • I have added my name to CONTRIBUTORS.md
  • I have updated CHANGES.md with a short summary of my change
  • I have added or updated unit tests to ensure consistent code coverage
  • I have updated the inline documentation, and included code examples where relevant
  • I have performed a self-review of my code

@github-actions
Copy link

github-actions bot commented Oct 8, 2025

Thank you for the pull request, @Beilinson!

✅ We can confirm we have a CLA on file for you.

!BoundingRectangle.equals(subRegion, item.subRegion)
) {
billboard.setImageSubRegion(billboard.image, subRegion);
item.subRegion = BoundingRectangle.clone(subRegion, item.subRegion);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this basically doubles all BoundingRectangle objects added to the scene. I tried making this test against the internal width/height, but those are only set after the subRegion promise resolves so that wont work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice that a billboard's imageSubRegion is created as a constant property (based on the lack of the createPropertyCallback arg passed in to createPropertyDescriptor).

Since the property never changes, maybe the right move here is to remove this code from update entirely and find another home for it? (Like a constructor or some setter - something that's only called once, not every frame).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I'll try to put something together tmrw

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createProperty creates a setter that uses the value directly if it is a Property, so users can for example do:

billboard.imageSubRegion = new CallbackProperty(...);

And then createProperty will set the internal value to actually be a CallbackProperty, so I dont think what you wrote can work here, correct me if I'm wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh I see what you're saying. So the the value of the property is constant, but the reference to a property can change, essentially.

I agree, that invalidates my idea. Follow up question, though: how does this "double all BoundingRectangle objects added to the scene`? Every time you clone, GC (eventually) deletes the old one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I'm using BoundingRectangle.clone all subRegions exist twice: once on the BillboardGraphics, and once as a deep clone on the item in the BillboardVisualizer, to be used for equality comparison. The one on the BillboardGraphics isn't GC'ed since the reference to the graphics is never lost (until the graphics is removed of course)

I don't think this is a significant issue, just wanted to point that out for review in case there was a better solution

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going back to the original idea for a second, I do think something like this could work. E.g. subscribe to the definition change in the constructor.

But... it also means there's now an event listener listening to every property change on a billboard and filtering down to just imageSubRegion based on name. That would be in exchange for checking BoundingRectangle equality on every Update though, which maybe is worth it.

Comment on lines -192 to -193
this._imageWidth = undefined;
this._imageHeight = undefined;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted because these are unused anywhere else in the code

@Beilinson Beilinson changed the title Add billboard subregion condition fix billboard subregion not displayed Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants