menu-controls allow unselecting / going back, remove unnoticable animations for perf
This commit is contained in:
@@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user