[page:Object3D] → [page:Audio] →

# [name]

创建一个位置相关的音频对象.
使用了[link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API Web Audio API].

## 示例

[example:webaudio_orientation webaudio / orientation ]
[example:webaudio_sandbox webaudio / sandbox ]
[example:webaudio_timing 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 );`

## 构造函数

### [name]( [param:AudioListener listener] )

listener — (必须) [page:AudioListener AudioListener] 实例.

## 属性

[page:Audio Audio]类的继承属性.

### [property:PannerNode panner]

位置相关音频的[link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode PannerNode].

## 方法

[page:Audio Audio]类的继承方法.

### [method:PannerNode getOutput]()

返回[page:PositionalAudio.panner panner].

### [method:Float getRefDistance]()

返回[link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/refDistance panner.refDistance]的值.

### [method:PositionalAudio setRefDistance]( [param:Float value] )

设置[link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/refDistance panner.refDistance]的值.

### [method:Float getRolloffFactor]()

返回[link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/rolloffFactor panner.rolloffFactor]的值.

### [method:PositionalAudio setRolloffFactor]( [param:Float value] )

设置[link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/rolloffFactor panner.rolloffFactor]的值.

### [method:String getDistanceModel]()

返回[link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/distanceModel panner.distanceModel]的值.

### [method:PositionalAudio setDistanceModel]( [param:String value] )

设置[link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/distanceModel panner.distanceModel]的值.

### [method:Float getMaxDistance]()

返回[link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/maxDistance panner.maxDistance]的值.

### [method:PositionalAudio setMaxDistance]( [param:Float value] )

设置[link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/maxDistance panner.maxDistance]的值.

### [method:PositionalAudio setDirectionalCone]( [param:Float coneInnerAngle], [param:Float coneOuterAngle], [param:Float coneOuterGain] )

这个方法用来把环绕声音转换为定向声音[link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode directional sound].

## Source

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]