From 092d872be57c8ddc009081e4a65855ea36f2ded6 Mon Sep 17 00:00:00 2001 From: Diego Marcos Date: Tue, 30 Oct 2018 16:00:36 -0700 Subject: [PATCH] Revert "reset beatOffsetTime on clearBeats" This reverts commit dc59bc9b3bd8c70a57b0485eb4845df652dff2b1. --- src/components/beat-loader.js | 8 +++----- src/components/song.js | 3 --- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/components/beat-loader.js b/src/components/beat-loader.js index ad0a59b..7de777b 100644 --- a/src/components/beat-loader.js +++ b/src/components/beat-loader.js @@ -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) { diff --git a/src/components/song.js b/src/components/song.js index a82dd70..3b97644 100644 --- a/src/components/song.js +++ b/src/components/song.js @@ -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; } });