Revert "reset beatOffsetTime on clearBeats"

This reverts commit dc59bc9b3b.
This commit is contained in:
Diego Marcos
2018-10-30 16:00:36 -07:00
parent 1164b8b96a
commit 092d872be5
2 changed files with 3 additions and 8 deletions

View File

@@ -139,8 +139,7 @@ AFRAME.registerComponent('beat-loader', {
// Re-sync song with beats playback.
const songComponent = this.el.components.song;
const currentTime = songComponent.getCurrentTime();
if (currentTime !== undefined && this.beatsTimeOffset !== undefined &&
if (songComponent.songStartTime && this.beatsTimeOffset !== undefined &&
this.songCurrentTime !== currentTime) {
this.songCurrentTime = currentTime;
this.beatsTime = (this.songCurrentTime + this.data.beatAnticipationTime) * 1000;
@@ -176,7 +175,6 @@ AFRAME.registerComponent('beat-loader', {
}
}
// Update preload beat offset.
if (this.beatsTimeOffset !== undefined) {
if (this.beatsTimeOffset <= 0) {
this.el.sceneEl.emit('beatloaderpreloadfinish', null, false);
@@ -187,7 +185,7 @@ AFRAME.registerComponent('beat-loader', {
}
}
this.beatsTime += delta;
this.beatsTime = beatsTime + delta;
},
generateBeat: (function () {
@@ -304,7 +302,7 @@ AFRAME.registerComponent('beat-loader', {
*/
clearBeats: function () {
this.beatsTime = 0;
this.beatsTimeOffset = this.data.beatAnticipationTime * 1000;
this.beatsTimeOffset = undefined;
for (let i = 0; i < this.beatContainer.children.length; i++) {
let child = this.beatContainer.children[i];
if (child.components.beat) {

View File

@@ -131,7 +131,6 @@ AFRAME.registerComponent('song', {
this.source.stop();
this.source.disconnect();
this.source = null;
this.songStartTime = undefined;
},
victory: function () {
@@ -178,7 +177,6 @@ AFRAME.registerComponent('song', {
if (this.data.isBeatsPreloaded) { this.startAudio(); }
}, ONCE);
this.audioAnalyser.refreshSource();
this.songStartTime = undefined;
},
onWallHitStart: function () {
@@ -202,7 +200,6 @@ AFRAME.registerComponent('song', {
},
getCurrentTime: function () {
if (this.songStartTime === undefined) { return undefined; }
return this.context.currentTime - this.songStartTime;
}
});