@@ -111,7 +111,8 @@ var WebAudioSoundManager = new Class({
111111 var context = this . context ;
112112
113113 // setTimeout to avoid weird audio artifacts (thanks Apple)
114- window . setTimeout ( function ( ) {
114+ window . setTimeout ( function ( )
115+ {
115116
116117 if ( context )
117118 {
@@ -429,11 +430,12 @@ var WebAudioSoundManager = new Class({
429430 {
430431 var listener = this . context . listener ;
431432
433+ var x = GetFastValue ( this . listenerPosition , 'x' , null ) ;
434+ var y = GetFastValue ( this . listenerPosition , 'y' , null ) ;
435+
436+
432437 if ( listener && listener . positionX !== undefined )
433438 {
434- var x = GetFastValue ( this . listenerPosition , 'x' , null ) ;
435- var y = GetFastValue ( this . listenerPosition , 'y' , null ) ;
436-
437439 if ( x && x !== this . _spatialx )
438440 {
439441 this . _spatialx = listener . positionX . value = x ;
@@ -444,6 +446,24 @@ var WebAudioSoundManager = new Class({
444446 }
445447 }
446448
449+ // Firefox doesn't currently implement positionX, positionY and positionZ properties on AudioListener,
450+ // falling back on AudioListener.prototype.setPosition() method. @see https://developer.mozilla.org/en-US/docs/Web/API/AudioListener/setPosition
451+ else if ( listener )
452+ {
453+ if ( x && x !== this . _spatialx )
454+ {
455+ this . _spatialx = x ;
456+ }
457+ if ( y && y !== this . _spatialy )
458+ {
459+ this . _spatialy = y ;
460+ }
461+
462+ var z = GetFastValue ( listener , 'z' , 0 ) ;
463+
464+ listener . setPosition ( this . _spatialx || 0 , this . _spatialy || 0 , z ) ;
465+ }
466+
447467 BaseSoundManager . prototype . update . call ( this , time , delta ) ;
448468
449469 // Resume interrupted audio on iOS only if the game has focus
0 commit comments