menu-controls allow unselecting / going back, remove unnoticable animations for perf

This commit is contained in:
Kevin Ngo
2018-10-04 01:54:25 -07:00
parent 6ee60c8b0c
commit 5bd7ca3246
6 changed files with 49 additions and 26 deletions

View File

@@ -1,9 +1,33 @@
AFRAME.registerComponent('intro-song', {
multiple: true,
schema: {
isPlaying: {default: true}
},
init: function () {
this.analyserEl = document.getElementById('audioAnalyser');
this.audio = document.getElementById('introSong');
},
update: function (oldData) {
const audio = this.audio;
if (!this.el.sceneEl.isPlaying) { return; }
if (!oldData.isPlaying && this.data.isPlaying) {
setTimeout(() => {
// TODO: Fade in volume.
this.analyserEl.setAttribute('audioanalyser', 'src', audio);
audio.play();
}, 1000);
}
if (oldData.isPlaying && !this.data.isPlaying) {
audio.pause();
}
},
play: function () {
const audio = document.getElementById('introSong');
audio.volume = 0.5;
audio.play();
this.audio.volume = 0.5;
this.audio.play();
}
});

View File

@@ -111,7 +111,9 @@ AFRAME.registerComponent('menu-controls', {
unselect: function () {
if (!this.data.enabled) { return; }
this.el.sceneEl.emit('menuunselect', null, false);
if (this.data.selectedChallengeId) {
this.el.sceneEl.emit('menuchallengeunselect', null, false);
}
},
hoverResult: function (i) {

View File

@@ -9,6 +9,7 @@ AFRAME.registerComponent('song-preview-system', {
},
init: function () {
this.analyserEl = document.getElementById('audioAnalyser');
this.audio = null;
this.audioStore = {};
this.preloadedAudioIds = [];
@@ -162,8 +163,7 @@ AFRAME.registerComponent('song-preview-system', {
},
updateAnalyser: function () {
document.getElementById('audioAnalyser').setAttribute('audioanalyser', 'src', this.audio);
document.getElementById('introSong').pause();
this.analyserEl.setAttribute('audioanalyser', 'src', this.audio);
},
/**