1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<base href="../../../" />
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
[page:Object3D] → [page:Audio] →
<h1>[name]</h1>
<p class="desc">
Create a positional audio object.<br /><br />
This uses the [link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API Web Audio API].
</p>
<h2>Example</h2>
<p>
[example:webaudio_orientation webaudio / orientation ]<br />
[example:webaudio_sandbox webaudio / sandbox ]<br />
[example:webaudio_timing webaudio / timing ]
</p>
<code>
// 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 );
</code>
<h2>Constructor</h2>
<h3>[name]( [param:AudioListener listener] )</h3>
<p>
listener — (required) [page:AudioListener AudioListener] instance.
</p>
<h2>Properties</h2>
<p>
See the [page:Audio Audio] class for inherited properties.
</p>
<h3>[property:PannerNode panner]</h3>
<p>The PositionalAudio's [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode PannerNode].</p>
<h2>Methods</h2>
<p>
See the [page:Audio Audio] class for inherited methods.
</p>
<h3>[method:PannerNode getOutput]()</h3>
<p>
Returns the [page:PositionalAudio.panner panner].
</p>
<h3>[method:Float getRefDistance]()</h3>
<p>
Returns the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/refDistance panner.refDistance].
</p>
<h3>[method:PositionalAudio setRefDistance]( [param:Float value] )</h3>
<p>
Sets the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/refDistance panner.refDistance].
</p>
<h3>[method:Float getRolloffFactor]()</h3>
<p>
Returns the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/rolloffFactor panner.rolloffFactor].
</p>
<h3>[method:PositionalAudio setRolloffFactor]( [param:Float value] )</h3>
<p>
Sets the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/rolloffFactor panner.rolloffFactor].
</p>
<h3>[method:String getDistanceModel]()</h3>
<p>
Returns the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/distanceModel panner.distanceModel].
</p>
<h3>[method:PositionalAudio setDistanceModel]( [param:String value] )</h3>
<p>
Sets the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/distanceModel panner.distanceModel].
</p>
<h3>[method:Float getMaxDistance]()</h3>
<p>
Returns the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/maxDistance panner.maxDistance].
</p>
<h3>[method:PositionalAudio setMaxDistance]( [param:Float value] )</h3>
<p>
Sets the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/maxDistance panner.maxDistance].
</p>
<h3>[method:PositionalAudio setDirectionalCone]( [param:Float coneInnerAngle], [param:Float coneOuterAngle], [param:Float coneOuterGain] )</h3>
<p>
This method can be used in order to transform an omnidirectional sound into a [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode directional sound].
</p>
<h2>Source</h2>
<p>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</p>
</body>
</html>
|