From 865f0cb82ffbabfa71c45f518860912789189827 Mon Sep 17 00:00:00 2001 From: Kevin Ngo Date: Mon, 1 Oct 2018 16:26:43 -0700 Subject: [PATCH] save draw calls on menu-difficulty-select, make active-color aware of visibility optimizations --- src/components/active-color.js | 4 +++- src/components/menu-difficulty-select.js | 4 +++- src/templates/menu.html | 7 ++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/active-color.js b/src/components/active-color.js index 13ad6ac..17aa98b 100644 --- a/src/components/active-color.js +++ b/src/components/active-color.js @@ -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) { diff --git a/src/components/menu-difficulty-select.js b/src/components/menu-difficulty-select.js index 38779a9..cfe8491 100644 --- a/src/components/menu-difficulty-select.js +++ b/src/components/menu-difficulty-select.js @@ -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); }); }, diff --git a/src/templates/menu.html b/src/templates/menu.html index c7dea96..cee357f 100644 --- a/src/templates/menu.html +++ b/src/templates/menu.html @@ -116,6 +116,7 @@ > + + animation__mouseentervisible="property: visible; from: false; to: true; startEvents: mouseenter; pauseEvents: mouseleave; dur: 1" + animation__mouseleave="property: components.material.material.opacity; to: 0.0; startEvents: mouseleave; pauseEvents: mouseenter; dur: 150" + animation__mouseleavevisible="property: visible; from: true; to: false; startEvents: mouseleave; pauseEvents: mouseenter; dur: 160">