[name] 用一个虚拟的[link:https://developer.mozilla.org/de/docs/Web/API/AudioListener listener]表示在场景中所有的位置和非位置相关的音效. 一个three.js程序通常创建一个[name]. 它是音频实体构造函数的必须参数,比如 [page:Audio Audio] and [page:PositionalAudio PositionalAudio]. 大多数情况下, listener对象是camera的子对象. Camera的3D变换表示了listener的3D变换.
[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();
});
创建一个新的AudioListener.
[page:AudioListener listener]构造函数中的[link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext AudioContext].
使用[link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createGain AudioContext.createGain]()创建 [link:https://developer.mozilla.org/en-US/docs/Web/API/GainNode GainNode].
默认为*null*.
Time delta value for audio entities. Use in context of [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioParam/linearRampToValueAtTime AudioParam.linearRampToValueAtTimeDefault](). Default is *0*.
返回[page:AudioListener.gain gainNode].
设置[page:AudioListener.filter filter]属性为*null*.
返回[page:AudioListener.filter filter]属性的值.
设置[page:AudioListener.filter filter] 属性的值.
返回音量.
设置音量.