-
Notifications
You must be signed in to change notification settings - Fork 1
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
addedAll event incorrectly emitted for *each* texture when loading 2nd pack #2
Comments
Use https://github.com/caolan/async#each? Calls back when all of the function calls (for each iterated element) complete. Instead of: for (var j = 0; j < textureNames.length; j += 1) {
} Something like: async.each(textureNames, function(name, done) { // include Y, X in item |
Changed to use async module on 'async' branch but curiously, loading a second pack fails with "Callback was already called.", at:
something broken with getTextureNdarray()? |
This reverts commit e48be215d1ca1b4f5c88ec62fa7a7fd9fbbf32ab.
Test with game-shell-voxel, press P to invoke voxel-artpacks UI, drag another pack (MC175.zip) into the list -> the pack reloads very slowly, because voxel-stitch is emitting the
addedAll
event for each and every texture loaded.It is supposed to only emit when all of the pending textures have loaded, so gl-tile-map can calculate all the mipmaps quickly all at once (instead of recalculating continuously). To do this it maintains this.countLoading and this.countLoaded, loading set to textureNames.length in stitch(), and loaded incremented in each addTexturePixels() (async callback from addTextureName, from artpacks getTextureNdarray). If loaded >= loading, then
addedAll
is emitted; loading isn't being reset for some reason so this condition is always true for all the textures loaded in the second pack.The text was updated successfully, but these errors were encountered: