-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix loading of label background #11040
Conversation
Thanks for the pull request @UniquePanda!
Reviewers, don't forget to make sure that:
|
Thanks for the fix @UniquePanda! Good catch! I think this was an oversight in #10275. When we resolve the promise in Given this is fixing that oversight, as well as that |
5972f18
to
21f89d0
Compare
Ah yes, makes sense. I was wondering, why the problem didn't occur before and had forgotten about that PR :) I removed the parameter and the index hash is now updated always, when a sub region is added. |
Another good catch @UniquePanda! That test was not properly calling the final expectations of that test. I re-wrote the problematic specs a bit so that the expectation are actually being executed. I also made a tweak to your new expectation so that we avoid calling private members of the class where possible because accessing private members makes tests more tightly coupled to the source code, and therefore more fragile. If you could add a note to |
Haha, I have to admit that confused me a bit. I actually started to change the test like you did, but then thought I might just don't understand what it was doing Thanks for fixing. 😄 I updated the |
fc13d09
to
c9b463e
Compare
There's some antiquated promise behavior in some tests, so it's good to get them cleaned up. 😄 Thanks again @UniquePanda, happy to get this fix in! |
Fixes #10461
This adds a new boolean parameter
updateImageIndex
toTextureAtlas.prototype.addSubRegion()
which isfalse
by default. If it is true, the_indexHash
value for the given image id is updated to point to the index of the new sub region. Otherwise the index will still point to the region of the whole image (same behavior as currently).This is needed because billboards create such a subregion, but wouldn't currently use this subregion in later calls to
_loadImage
which results in the problems described in the issue.I am not really sure if my solution is good, because I am no expert on this topic. There are some open questions:
updateImageIndex
parameter)?_indexHash
and a_subRegionIndexHash
?addSubRegion
isn't used anywhere else (only by_loadImage()
ofBillboard.js
). Should this be refactored in general somehow?I didn't add/update any tests yet, because of those questions.
Longer description of what I think is the problem of the current code that is fixed by this PR:
An
imageSubRegion
for the billboard backgrounds is added to the texture atlas on the first load of a billboard.Later calls will not add anything to the texture atlas, but will request the correct image by relying on the texture atlas'
_indexHash
.In these later calls the index is retrieved from the texture atlas and then directly passed to
completeImageLoad()
.This function then uses this index to get the correct texture coordinates from the texture atlas. The problem is, that the image sub region is not taken into account anymore at this point.
The initial call, that added the sub region, is getting the index by calling
TextureAtlas.addSubRegion()
which returns a promise that resolves to the index. This is the index of the created subregion.However, later calls will receive the index of the whole image, because the
_indexHash
will still point to the index of the image and not its sub region. That's why the background looks different then.