improve beam resume out of pause menu

This commit is contained in:
Kevin Ngo
2018-10-08 17:30:13 -07:00
parent e6451b12e5
commit 8338f9e16f
6 changed files with 30 additions and 25 deletions

View File

@@ -2,6 +2,7 @@ const ANIME = AFRAME.ANIME || AFRAME.anime;
AFRAME.registerComponent('beams', {
schema: {
isPlaying: {default: false},
poolSize: {default: 3}
},
@@ -48,13 +49,15 @@ AFRAME.registerComponent('beams', {
}
}
this.el.sceneEl.addEventListener('cleargame', this.clearBeams.bind(this));
this.clearBeams = this.clearBeams.bind(this);
this.el.sceneEl.addEventListener('cleargame', this.clearBeams);
},
/**
* Use tick for manual ANIME animations, else it will create RAF.
*/
tick: function (t, dt) {
if (!this.data.isPlaying) { return; }
for (let i = 0; i < this.beams.length; i++) {
let beam = this.beams[i];
// Tie animation state to beam visibility.
@@ -85,6 +88,8 @@ AFRAME.registerComponent('beams', {
clearBeams: function () {
for (let i = 0; i < this.beams.length; i++) {
this.beams[i].visible = false;
this.beams[i].time = 0;
this.beams[i].scale.x = 1;
}
}
});