Skip to content

Commit

Permalink
bug fix: refresh material html shader once in order to allow slow loa…
Browse files Browse the repository at this point in the history
…ding google fonts to render
  • Loading branch information
weddingdj committed Jun 14, 2018
1 parent 034a9d9 commit 6aee3ef
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 39 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
82 changes: 44 additions & 38 deletions js/ideaspacevr/isvr-scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

@php
if (function_exists('embed_fonts')) {
embed_fonts();
embed_fonts();
}
@endphp

Expand Down

0 comments on commit 6aee3ef

Please sign in to comment.