add back beat hit sound pool hack

This commit is contained in:
Kevin Ngo
2018-11-12 17:49:12 +08:00
parent 26df7dadea
commit a92fd1db3d

View File

@@ -53,9 +53,8 @@ AFRAME.registerComponent('beat-hit-sound', {
this.currentCutDirection = '';
this.processSound = this.processSound.bind(this);
sourceCreatedCallback = this.sourceCreatedCallback.bind(this);
},
play: function () {
// Sound pools.
for (let i = 1; i <= 10; i++) {
this.el.setAttribute(`sound__beathit${i}`, {
poolSize: 4,
@@ -72,6 +71,24 @@ AFRAME.registerComponent('beat-hit-sound', {
}
},
play: function () {
// Kick three.js loader...Don't know why sometimes doesn't load.
for (let i = 1; i <= 10; i++) {
if (!this.el.components[`sound__beathit${i}`].loaded) {
this.el.setAttribute(`sound__beathit${i}`, 'src', '');
this.el.setAttribute(`sound__beathit${i}`, 'src', `#hitSound${i}`);
}
if (!this.el.components[`sound__beathit${i}left`].loaded) {
this.el.setAttribute(`sound__beathit${i}left`, 'src', '');
this.el.setAttribute(`sound__beathit${i}left`, 'src', `#hitSound${i}left`);
}
if (!this.el.components[`sound__beathit${i}right`].loaded) {
this.el.setAttribute(`sound__beathit${i}right`, 'src', '');
this.el.setAttribute(`sound__beathit${i}right`, 'src', `#hitSound${i}right`);
}
}
},
playSound: function (beatEl, cutDirection) {
const rand = 1 + Math.floor(Math.random() * 10);
const dir = this.directionsToSounds[cutDirection || 'up'];