From 6aee3efacd02ba3b113e4900e8d6b460e4a5509e Mon Sep 17 00:00:00 2001 From: Wedding DJ Date: Thu, 14 Jun 2018 12:34:16 -0400 Subject: [PATCH] bug fix: refresh material html shader once in order to allow slow loading google fonts to render --- CHANGELOG.md | 4 ++ js/ideaspacevr/isvr-scene.js | 82 +++++++++++++++++++----------------- views/index.blade.php | 2 +- 3 files changed, 49 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d903743..6926fc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ ## 1.0 - Initial version + +## 1.1 + +- Bug fix: if Google Fonts are used and they need longer to load, the material HTML shader must be updated diff --git a/js/ideaspacevr/isvr-scene.js b/js/ideaspacevr/isvr-scene.js index 777d25d..9813e07 100644 --- a/js/ideaspacevr/isvr-scene.js +++ b/js/ideaspacevr/isvr-scene.js @@ -58,44 +58,50 @@ AFRAME.registerComponent('isvr-scene', { /* workaround: it we don't wait, the first menu item mouseenter event is triggered and it causes wrong animation behaviour for that menu item */ setTimeout(function() { - /* trigger custom events */ - var soundClick = document.querySelector('#sound-click'); - var collidables = document.querySelectorAll('.collidable'); - for (var j = 0; j < collidables.length; j++) { - - collidables[j].addEventListener('mouseenter', function(e) { - - e.target.emit('isvr_mouseenter'); - - /*for (var i = 0; i < e.target.parentNode.childNodes.length; i++) { - if (e.target.parentNode.childNodes[i].className == "title") { - e.target.parentNode.childNodes[i].emit('isvr_titlein'); - //e.target.parentNode.childNodes[i].setAttribute('visible', true); - break; - } - }*/ - - if (e.target.classList.contains('wrapper')) { - soundClick.components.sound.stopSound(); - soundClick.components.sound.playSound(); - } - - }); - - collidables[j].addEventListener('mouseleave', function(e) { - - e.target.emit('isvr_mouseleave'); - - /*for (var i = 0; i < e.target.parentNode.childNodes.length; i++) { - if (e.target.parentNode.childNodes[i].className == "title") { - //e.target.parentNode.childNodes[i].emit('isvr_titleout'); - //e.target.parentNode.childNodes[i].setAttribute('visible', true); - break; - } - }*/ - }); - - } + /* trigger custom events */ + var soundClick = document.querySelector('#sound-click'); + var collidables = document.querySelectorAll('.collidable'); + for (var j = 0; j < collidables.length; j++) { + + collidables[j].addEventListener('mouseenter', function(e) { + + e.target.emit('isvr_mouseenter'); + + /*for (var i = 0; i < e.target.parentNode.childNodes.length; i++) { + if (e.target.parentNode.childNodes[i].className == "title") { + e.target.parentNode.childNodes[i].emit('isvr_titlein'); + //e.target.parentNode.childNodes[i].setAttribute('visible', true); + break; + } + }*/ + + if (e.target.classList.contains('wrapper')) { + soundClick.components.sound.stopSound(); + soundClick.components.sound.playSound(); + } + + }); + + collidables[j].addEventListener('mouseleave', function(e) { + + e.target.emit('isvr_mouseleave'); + + /*for (var i = 0; i < e.target.parentNode.childNodes.length; i++) { + if (e.target.parentNode.childNodes[i].className == "title") { + //e.target.parentNode.childNodes[i].emit('isvr_titleout'); + //e.target.parentNode.childNodes[i].setAttribute('visible', true); + break; + } + }*/ + }); + + } + + /* workaround: in case google fonts have not been loaded yet, update material html shader */ + var titles = document.querySelectorAll('.title'); + for (var k = 0; k < titles.length; k++) { + titles[k].components.material.shader.__render(); + } }, 2000); diff --git a/views/index.blade.php b/views/index.blade.php index 8c97646..2eb5aa5 100644 --- a/views/index.blade.php +++ b/views/index.blade.php @@ -26,7 +26,7 @@ @php if (function_exists('embed_fonts')) { - embed_fonts(); + embed_fonts(); } @endphp