hook up beat hit sound
This commit is contained in:
BIN
assets/sounds/beatHit.ogg
Normal file
BIN
assets/sounds/beatHit.ogg
Normal file
Binary file not shown.
Binary file not shown.
6
package-lock.json
generated
6
package-lock.json
generated
@@ -97,9 +97,9 @@
|
||||
"integrity": "sha512-2Zm07u163vwzT7VLE7y9h9oL1e3RH8CNQGIUvdE+wgl2Yo6iSZwGhIpcYRFODthEdb0vHrCyFMOATZfniq7yhw=="
|
||||
},
|
||||
"aframe-audioanalyser-component": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/aframe-audioanalyser-component/-/aframe-audioanalyser-component-4.0.1.tgz",
|
||||
"integrity": "sha512-jTkt9umD4SoRmW6vlJfm2zG9fV8pzecNzTdJYn12w8hpZ0lp3BtFSKqTDy0RE3dqAsDJo9AU72niZAu8w3NeeA=="
|
||||
"version": "5.0.0-beta1",
|
||||
"resolved": "https://registry.npmjs.org/aframe-audioanalyser-component/-/aframe-audioanalyser-component-5.0.0-beta1.tgz",
|
||||
"integrity": "sha512-VKDwHBXq3QjX+nBZuoOtGTg7qBytVVC7um7yZSpBCI3hHxhjKtldTeZHohP6R8P5jaDrwygQkXXFfHyJCKOubw=="
|
||||
},
|
||||
"aframe-event-decorators": {
|
||||
"version": "1.0.2",
|
||||
|
||||
28
src/components/beat-hit.js
Normal file
28
src/components/beat-hit.js
Normal file
@@ -0,0 +1,28 @@
|
||||
var audioContext = new window.AudioContext();
|
||||
|
||||
/**
|
||||
* 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', {
|
||||
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);
|
||||
});
|
||||
},
|
||||
|
||||
processSound: function (sound) {
|
||||
this.currentBeatEl.object3D.getWorldPosition(sound.position);
|
||||
console.log(sound.position);
|
||||
// this.currentBeatEl.setObject3D('sound', sound);
|
||||
}
|
||||
});
|
||||
@@ -421,14 +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.destroyBeat(saberEls[i]);
|
||||
this.el.sceneEl.emit('beathit', null, false);
|
||||
break;
|
||||
}
|
||||
if (saberBoundingBox.intersectsBox(beatBoundingBox)) {
|
||||
this.el.emit('beathit', this.el);
|
||||
this.destroyBeat(saberEls[i]);
|
||||
this.wrongCut(saberEls[i].getAttribute('saber-controls').hand);
|
||||
this.el.sceneEl.emit('beatwrong', null, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,8 +100,11 @@
|
||||
<a-entity id="cursorLaser" obj-model="obj: #laserObj" visible="false"></a-entity>
|
||||
|
||||
<a-entity id="container">
|
||||
<a-entity id="beatContainer" bind__pause="isPaused: !isPlaying"></a-entity>
|
||||
|
||||
<a-entity
|
||||
id="beatContainer"
|
||||
beat-hit
|
||||
bind__pause="isPaused: !isPlaying"
|
||||
sound__beathit="poolSize: 12; src: assets/sounds/beatHit.ogg"></a-entity>
|
||||
{% include './templates/stage.html' %}
|
||||
{% include './templates/score.html' %}
|
||||
{% include './templates/menu.html' %}
|
||||
|
||||
2
vendor/README.md
vendored
Normal file
2
vendor/README.md
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
A-Frame currently derived from `overlay` branch from either Kevin or Diego's
|
||||
A-Frame GitHub repositories.
|
||||
69004
vendor/aframe.effects.js
vendored
69004
vendor/aframe.effects.js
vendored
File diff suppressed because one or more lines are too long
828
vendor/aframe.effects.js.map
vendored
828
vendor/aframe.effects.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user