diff --git a/src/components/gpu-preloader.js b/src/components/gpu-preloader.js index de3d6ee..a2c6b39 100644 --- a/src/components/gpu-preloader.js +++ b/src/components/gpu-preloader.js @@ -12,6 +12,7 @@ AFRAME.registerComponent('gpu-preloader', { this.preloadBeamMap(); this.preloadBeatEnvMap(); this.preloadCutParticles(); + this.preloadKeyboard(); this.preloadMissMap(); this.preloadWallMap(); this.preloadWrongMap(); @@ -41,6 +42,12 @@ AFRAME.registerComponent('gpu-preloader', { this.preloadTexture(particles.components.particleplayer.material.map); }, + preloadKeyboard: function () { + const keyboard = document.getElementById('keyboard') + const kbImg = keyboard.components['super-keyboard'].kbImg; + this.preloadTexture(kbImg.getObject3D('mesh').material.map); + }, + preloadMineEnvMaps: function () { const stageColors = this.el.sceneEl.components['stage-colors']; this.el.sceneEl.addEventListener('mineredenvmaploaded', () => { @@ -71,6 +78,10 @@ AFRAME.registerComponent('gpu-preloader', { console.warn('[gpu-preloader] Error preloading texture', texture); return; } + if (!texture.image.complete) { + console.warn('[gpu-preloader] Error preloading, image not loaded', texture); + return; + } this.el.renderer.setTexture2D(texture, i++ % 8); } });