preload keyboard img

This commit is contained in:
Kevin Ngo
2018-10-16 01:43:42 -07:00
parent 8b85da2bd7
commit f581e32bb4

View File

@@ -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);
}
});