diff --git a/assets/sounds/beatHit.ogg b/assets/sounds/beatHit.ogg index cc523c6..ebaa314 100644 Binary files a/assets/sounds/beatHit.ogg and b/assets/sounds/beatHit.ogg differ diff --git a/src/components/beat-hit.js b/src/components/beat-hit-sound.js similarity index 78% rename from src/components/beat-hit.js rename to src/components/beat-hit-sound.js index e3478a6..032952a 100644 --- a/src/components/beat-hit.js +++ b/src/components/beat-hit-sound.js @@ -29,22 +29,18 @@ THREE.Audio.prototype.play = function () { /** * Beat hit sound using positional audio and audio buffer source. - * Pitch the sound up and down using the song audioanalyser FFT. */ -AFRAME.registerComponent('beat-hit', { +AFRAME.registerComponent('beat-hit-sound', { dependencies: ['sound__beathit'], init: function () { - const data = this.data; - const el = this.el; - this.processSound = this.processSound.bind(this); + }, - const soundPool = el.components.sound__beathit; - el.addEventListener('beathit', evt => { - this.currentBeatEl = evt.detail; - soundPool.playSound(this.processSound); - }); + playSound: function (beatEl) { + const soundPool = this.el.components.sound__beathit; + this.currentBeatEl = beatEl; + soundPool.playSound(this.processSound); }, processSound: function (audio) { diff --git a/src/components/beat.js b/src/components/beat.js index 0839f5e..e45b628 100644 --- a/src/components/beat.js +++ b/src/components/beat.js @@ -421,12 +421,14 @@ AFRAME.registerComponent('beat', { saberBoundingBox = saberEls[i].components['saber-controls'].boundingBox; if (!boundingBox || !saberBoundingBox) { break; } if (saberBoundingBox.intersectsBox(boundingBox)) { - this.el.emit('beathit', this.el); + this.el.emit('beathit', null, false); + this.el.parentNode.components['beat-hit-sound'].playSound(this.el); this.destroyBeat(saberEls[i]); break; } if (saberBoundingBox.intersectsBox(beatBoundingBox)) { - this.el.emit('beathit', this.el); + this.el.emit('beathit', null, false); + this.el.parentNode.components['beat-hit-sound'].playSound(this.el); this.destroyBeat(saberEls[i]); this.wrongCut(saberEls[i].getAttribute('saber-controls').hand); break; diff --git a/src/index.html b/src/index.html index 653e64f..8afba28 100644 --- a/src/index.html +++ b/src/index.html @@ -106,7 +106,7 @@ {% include './templates/stage.html' %}