PositionalAudio
创建一个位置相关的音频对象.
使用了Web Audio API.
示例
webaudio / orientation
webaudio / sandbox
webaudio / timing
// create an AudioListener and add it to the camera
var listener = new THREE.AudioListener();
camera.add( listener );
// create the PositionalAudio object (passing in the listener)
var sound = new THREE.PositionalAudio( listener );
// load a sound and set it as the PositionalAudio object's buffer
var audioLoader = new THREE.AudioLoader();
audioLoader.load( 'sounds/song.ogg', function( buffer ) {
sound.setBuffer( buffer );
sound.setRefDistance( 20 );
sound.play();
});
// create an object for the sound to play from
var sphere = new THREE.SphereGeometry( 20, 32, 16 );
var material = new THREE.MeshPhongMaterial( { color: 0xff2200 } );
var mesh = new THREE.Mesh( sphere, material );
scene.add( mesh );
// finally add the sound to the mesh
mesh.add( sound );
构造函数
PositionalAudio( listener : AudioListener )
listener — (必须) AudioListener 实例.
属性
Audio类的继承属性.
# .panner : PannerNode
位置相关音频的PannerNode.
方法
Audio类的继承方法.
# .getOutput () : PannerNode
返回panner.
# .getRefDistance () : Float
返回panner.refDistance的值.
# .setRefDistance ( value : Float ) : PositionalAudio
设置panner.refDistance的值.
# .getRolloffFactor () : Float
返回panner.rolloffFactor的值.
# .setRolloffFactor ( value : Float ) : PositionalAudio
设置panner.rolloffFactor的值.
# .getDistanceModel () : String
返回panner.distanceModel的值.
# .setDistanceModel ( value : String ) : PositionalAudio
设置panner.distanceModel的值.
# .getMaxDistance () : Float
返回panner.maxDistance的值.
# .setMaxDistance ( value : Float ) : PositionalAudio
设置panner.maxDistance的值.
# .setDirectionalCone ( coneInnerAngle : Float, coneOuterAngle : Float, coneOuterGain : Float ) : PositionalAudio
这个方法用来把环绕声音转换为定向声音directional sound.