[page:Object3D] →
[name]
The [name] represents a virtual [link:https://developer.mozilla.org/de/docs/Web/API/AudioListener listener] of the all positional and non-positional audio effects in the scene.
A three.js application usually creates a single instance of [name]. It is a mandatory construtor parameter for audios entities like [page:Audio Audio] and [page:PositionalAudio PositionalAudio].
In most cases, the listener object is a child of the camera. So the 3D transformation of the camera represents the 3D transformation of the listener.
Example
[example:webaudio_sandbox webaudio / sandbox ]
[example:webaudio_timing webaudio / timing ]
[example:webaudio_visualizer webaudio / visualizer ]
// create an AudioListener and add it to the camera
var listener = new THREE.AudioListener();
camera.add( listener );
// create a global audio source
var sound = new THREE.Audio( listener );
// load a sound and set it as the Audio object's buffer
var audioLoader = new THREE.AudioLoader();
audioLoader.load( 'sounds/ambient.ogg', function( buffer ) {
sound.setBuffer( buffer );
sound.setLoop(true);
sound.setVolume(0.5);
sound.play();
});
Constructor
[name]( )
Create a new AudioListener.
Properties
[property:AudioContext context]
The [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext AudioContext] of the [page:AudioListener listener] given in the constructor.
[property:GainNode gain]
A [link:https://developer.mozilla.org/en-US/docs/Web/API/GainNode GainNode] created
using [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createGain AudioContext.createGain]().
[property:AudioNode filter]
Default is *null*.
Methods
[method:GainNode getInput]()
Return the [page:AudioListener.gain gainNode].
[method:null removeFilter]()
Set the [page:AudioListener.filter filter] property to *null*.
[method:AudioNode getFilter]()
Returns the value of the [page:AudioListener.filter filter] property.
[method:null setFilter]( [param:AudioNode value] )
Set the [page:AudioListener.filter filter] property to *value*.
[method:Number getMasterVolume]()
Return the volume.
[method:null setMasterVolume]( [param:Number value] )
Set the volume.
Source
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]