AudioListener.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. [page:Object3D] &rarr;
  12. <h1>[name]</h1>
  13. <p class="desc">
  14. The [name] represents a virtual [link:https://developer.mozilla.org/de/docs/Web/API/AudioListener listener] of the all positional and non-positional audio effects in the scene.</br>
  15. A three.js application usually creates a single instance of [name]. It is a mandatory construtor parameter for audios entities like [page:Audio Audio] and [page:PositionalAudio PositionalAudio].</br>
  16. In most cases, the listener object is a child of the camera. So the 3D transformation of the camera represents the 3D transformation of the listener.
  17. </p>
  18. <h2>Example</h2>
  19. <p>
  20. [example:webaudio_sandbox webaudio / sandbox ]</br>
  21. [example:webaudio_timing webaudio / timing ]</br>
  22. [example:webaudio_visualizer webaudio / visualizer ]
  23. </p>
  24. <code>
  25. // create an AudioListener and add it to the camera
  26. var listener = new THREE.AudioListener();
  27. camera.add( listener );
  28. // create a global audio source
  29. var sound = new THREE.Audio( listener );
  30. // load a sound and set it as the Audio object's buffer
  31. var audioLoader = new THREE.AudioLoader();
  32. audioLoader.load( 'sounds/ambient.ogg', function( buffer ) {
  33. sound.setBuffer( buffer );
  34. sound.setLoop(true);
  35. sound.setVolume(0.5);
  36. sound.play();
  37. });
  38. </code>
  39. <h2>Constructor</h2>
  40. <h3>[name]( )</h3>
  41. <p>
  42. Create a new AudioListener.
  43. </p>
  44. <h2>Properties</h2>
  45. <h3>[property:AudioContext context]</h3>
  46. <p>The [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext AudioContext] of the [page:AudioListener listener] given in the constructor.</p>
  47. <h3>[property:GainNode gain]</h3>
  48. <p>A [link:https://developer.mozilla.org/en-US/docs/Web/API/GainNode GainNode] created
  49. using [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createGain AudioContext.createGain]().</p>
  50. <h3>[property:AudioNode filter]</h3>
  51. <p>Default is *null*.</p>
  52. <h2>Methods</h2>
  53. <h3>[method:GainNode getInput]()</h3>
  54. <p>
  55. Return the [page:AudioListener.gain gainNode].
  56. </p>
  57. <h3>[method:AudioListener removeFilter]()</h3>
  58. <p>
  59. Set the [page:AudioListener.filter filter] property to *null*.
  60. </p>
  61. <h3>[method:AudioNode getFilter]()</h3>
  62. <p>
  63. Returns the value of the [page:AudioListener.filter filter] property.
  64. </p>
  65. <h3>[method:AudioListener setFilter]( [param:AudioNode value] )</h3>
  66. <p>
  67. Set the [page:AudioListener.filter filter] property to *value*.
  68. </p>
  69. <h3>[method:Float getMasterVolume]()</h3>
  70. <p>
  71. Return the volume.
  72. </p>
  73. <h3>[method:AudioListener setMasterVolume]( [param:Number value] )</h3>
  74. <p>
  75. Set the volume.
  76. </p>
  77. <h2>Source</h2>
  78. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  79. </body>
  80. </html>