From f581e32bb418ff5b5f1133f0f83e9668b3ac286a Mon Sep 17 00:00:00 2001 From: Kevin Ngo Date: Tue, 16 Oct 2018 01:43:42 -0700 Subject: [PATCH] preload keyboard img --- src/components/gpu-preloader.js | 11 +++++++++++ 1 file changed, 11 insertions(+) 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); } });