You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
4.1 KiB

2 years ago
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="utf-8" />
<base href="../../../" />
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
[page:Object3D] &rarr; [page:Audio] &rarr;
<h1>[name]</h1>
<p class="desc">
Crea un oggetto audio posizionale.<br /><br />
Utilizza le [link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API API Web Audio].
</p>
<h2>Codice di Esempio</h2>
<code>
// crea un AudioListener e lo aggiunge alla camera
const listener = new THREE.AudioListener();
camera.add( listener );
// crea l'oggetto PositionalAudio (passandogli il listener)
const sound = new THREE.PositionalAudio( listener );
// carica un suono e lo imposta come buffer dell'oggetto PositionalAudio
const audioLoader = new THREE.AudioLoader();
audioLoader.load( 'sounds/song.ogg', function( buffer ) {
sound.setBuffer( buffer );
sound.setRefDistance( 20 );
sound.play();
});
// crea un oggetto da cui riprodurre il suono
const sphere = new THREE.SphereGeometry( 20, 32, 16 );
const material = new THREE.MeshPhongMaterial( { color: 0xff2200 } );
const mesh = new THREE.Mesh( sphere, material );
scene.add( mesh );
// infine aggiunge il suono alla mesh
mesh.add( sound );
</code>
<h2>Esempi</h2>
<p>
[example:webaudio_orientation webaudio / orientation ]<br />
[example:webaudio_sandbox webaudio / sandbox ]<br />
[example:webaudio_timing webaudio / timing ]
</p>
<h2>Costruttore</h2>
<h3>[name]( [param:AudioListener listener] )</h3>
<p>
listener — (obbligatorio) istanza di [page:AudioListener AudioListener].
</p>
<h2>Proprietà</h2>
<p>
Vedi la classe [page:Audio Audio] per le proprietà ereditate.
</p>
<h3>[property:PannerNode panner]</h3>
<p>
Il [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode PannerNode] di PositionalAudio.
</p>
<h2>Metodi</h2>
<p>
Vedi la classe [page:Audio Audio] per i metodi ereditati.
</p>
<h3>[method:PannerNode getOutput]()</h3>
<p>
Restituisce il [page:PositionalAudio.panner panner].
</p>
<h3>[method:Float getRefDistance]()</h3>
<p>
Restisuice il valore di [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/refDistance panner.refDistance].
</p>
<h3>[method:this setRefDistance]( [param:Float value] )</h3>
<p>
Imposta il valore di [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/refDistance panner.refDistance].
</p>
<h3>[method:Float getRolloffFactor]()</h3>
<p>
Restisuice il valore di [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/rolloffFactor panner.rolloffFactor].
</p>
<h3>[method:this setRolloffFactor]( [param:Float value] )</h3>
<p>
Imposta il valore di [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/rolloffFactor panner.rolloffFactor].
</p>
<h3>[method:String getDistanceModel]()</h3>
<p>
Restisuice il valore di [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/distanceModel panner.distanceModel].
</p>
<h3>[method:this setDistanceModel]( [param:String value] )</h3>
<p>
Imposta il valore di [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/distanceModel panner.distanceModel].
</p>
<h3>[method:Float getMaxDistance]()</h3>
<p>
Restisuice il valore di [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/maxDistance panner.maxDistance].
</p>
<h3>[method:this setMaxDistance]( [param:Float value] )</h3>
<p>
Imposta il valore di [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/maxDistance panner.maxDistance].
</p>
<h3>[method:this setDirectionalCone]( [param:Float coneInnerAngle], [param:Float coneOuterAngle], [param:Float coneOuterGain] )</h3>
<p>
Questo metodo può essere usato per trasformare un suono omnidirezionale in un [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode suono direzionale].
</p>
<h2>Source</h2>
<p>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</p>
</body>
</html>