save draw calls on menu-difficulty-select, make active-color aware of visibility optimizations

This commit is contained in:
Kevin Ngo
2018-10-01 16:26:43 -07:00
parent dce298d568
commit 865f0cb82f
3 changed files with 12 additions and 3 deletions

View File

@@ -11,13 +11,15 @@ AFRAME.registerComponent('active-color', {
init: function () {
this.defaultColor = this.el.getAttribute('material').color;
this.materialObj = {color: this.data.color, opacity: 1};
},
update: function () {
var el = this.el;
if (this.data.active) {
el.setAttribute('material', {'color': this.data.color, 'opacity': 1});
el.setAttribute('material', this.materialObj);
el.object3D.visible = true;
} else {
el.setAttribute('material', 'color', this.defaultColor);
if (el.components.animation__mouseleave) {

View File

@@ -6,9 +6,11 @@ var bindEvent = require('aframe-event-decorators').bindEvent;
AFRAME.registerComponent('menu-difficulty-select', {
init: function () {
this.el.sceneEl.addEventListener('menuchallengeselect', () => {
this.el.object3D.visible = false;
setTimeout(() => {
this.el.components.layout.update();
});
this.el.object3D.visible = true;
}, 150);
});
},