workaround to fix sound component / audioloader not loading initially
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
<a-asset-item id="tunnelObj" src="assets/models/tunnel.obj"></a-asset-item>
|
||||
<a-asset-item id="tunnelNeonObj" src="assets/models/tunnelneon.obj"></a-asset-item>
|
||||
|
||||
<audio id="beatHitSound" src="assets/sounds/beatHit.ogg"></audio>
|
||||
<audio id="confirmSound" src="assets/sounds/beatHit.ogg"></audio>
|
||||
<audio id="hoverSound" src="assets/sounds/hover.ogg"></audio>
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ AFRAME.registerComponent('beat-hit-sound', {
|
||||
this.currentCutDirection = '';
|
||||
this.el.setAttribute('sound__beathit', {
|
||||
poolSize: 12,
|
||||
src: 'assets/sounds/beatHit.ogg',
|
||||
src: '#beatHitSound',
|
||||
volume: 0.5
|
||||
});
|
||||
this.processSound = this.processSound.bind(this);
|
||||
@@ -50,6 +50,15 @@ AFRAME.registerComponent('beat-hit-sound', {
|
||||
sourceCreatedCallback = this.sourceCreatedCallback.bind(this);
|
||||
},
|
||||
|
||||
play: function () {
|
||||
// Kick three.js loader...Don't know why sometimes doesn't load.
|
||||
if (!this.el.components.sound__beathit.loaded) {
|
||||
console.log('[beat-hit-sound] Kicking three.js AudioLoader / sound component...');
|
||||
this.el.setAttribute('sound__beathit', 'src', '');
|
||||
this.el.setAttribute('sound__beathit', 'src', '#beatHitSound');
|
||||
}
|
||||
},
|
||||
|
||||
playSound: function (beatEl, cutDirection) {
|
||||
const soundPool = this.el.components.sound__beathit;
|
||||
this.currentBeatEl = beatEl;
|
||||
|
||||
Reference in New Issue
Block a user