From aa399a46c709fe55fcb7324d57385f3250e5fdde Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Sat, 6 Jul 2024 19:12:04 +0900 Subject: [PATCH] Fix race condition for tiles rendering --- example/src/plugins/overlays/TextureOverlayMaterial.js | 2 -- example/src/plugins/overlays/TextureOverlayPlugin.js | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/example/src/plugins/overlays/TextureOverlayMaterial.js b/example/src/plugins/overlays/TextureOverlayMaterial.js index a30dae81..23b95a57 100644 --- a/example/src/plugins/overlays/TextureOverlayMaterial.js +++ b/example/src/plugins/overlays/TextureOverlayMaterial.js @@ -25,8 +25,6 @@ export const TextureOverlayMaterialMixin = base => class extends base { DISPLAY_AS_OVERLAY: Number( this.displayAsOverlay ), }; - console.log('UPDATE') - // WebGL does not seem to like empty texture arrays if ( textures.length !== 0 ) { diff --git a/example/src/plugins/overlays/TextureOverlayPlugin.js b/example/src/plugins/overlays/TextureOverlayPlugin.js index 1ef11a8a..fb6291c3 100644 --- a/example/src/plugins/overlays/TextureOverlayPlugin.js +++ b/example/src/plugins/overlays/TextureOverlayPlugin.js @@ -15,7 +15,6 @@ function canUseImageBitmap() { } - return ! ( typeof createImageBitmap === 'undefined' || isSafari || ( isFirefox && firefoxVersion < 98 ) ); } @@ -218,7 +217,8 @@ export class TextureOverlayPlugin { this._assignTexturesCallback = ( { tile, scene } ) => { - this.assignCallback( scene, tile, this ); + // queue a microtask here so we can make sure this fires after all the other load events + queueMicrotask( () => this.assignCallback( scene, tile, this ) ); };