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

[name]

Create a positional audio object.

This uses the [link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API Web Audio API].

Example

[example:misc_sound misc / sound ]
//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 ) { sound1.setBuffer( buffer ); sound1.setRefDistance( 20 ); sound1.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 );

Constructor

[name]( [page:AudioListener listener] )

listener — (required) [page:AudioListener AudioListener] instance.

Properties

See the [page:Audio Audio] class for inherited properties.

[property:PannerNode panner]

The PositionalAudio's [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode PannerNode].

Methods

See the [page:Audio Audio] class for inherited methods.

[method:PannerNode getOutput]()

Returns the [page:PositionalAudio.panner panner].

[method:Number getRefDistance]()

Returns the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/refDistance panner.refDistance].

[method:PannerNode setRefDistance]( [page:Number value] )

Sets the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/refDistance panner.refDistance].

[method:PannerNode getRolloffFactor]()

Returns the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/rolloffFactor panner.rolloffFactor].

[method:PannerNode setRolloffFactor]( [page:Number value] )

Sets the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/rolloffFactor panner.rolloffFactor].

[method:String getDistanceModel]()

Returns the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/distanceModel panner.distanceModel].

[method:String setDistanceModel]( [page:String value] )

Sets the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/distanceModel panner.distanceModel].

[method:PannerNode getMaxDistance]()

Returns the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/maxDistance panner.maxDistance].

[method:PannerNode setMaxDistance]( [page:Number value] )

Sets the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/maxDistance panner.maxDistance].

Source

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