PositionalAudio.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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; [page:Audio] &rarr;
  12. <h1>[name]</h1>
  13. <p class="desc">
  14. Create a positional audio object.<br /><br />
  15. This uses the [link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API Web Audio API].
  16. </p>
  17. <h2>Example</h2>
  18. <p>
  19. [example:webaudio_sandbox webaudio / sandbox ]</br>
  20. [example:webaudio_timing webaudio / timing ]
  21. </p>
  22. <code>
  23. // create an AudioListener and add it to the camera
  24. var listener = new THREE.AudioListener();
  25. camera.add( listener );
  26. // create the PositionalAudio object (passing in the listener)
  27. var sound = new THREE.PositionalAudio( listener );
  28. // load a sound and set it as the PositionalAudio object's buffer
  29. var audioLoader = new THREE.AudioLoader();
  30. audioLoader.load( 'sounds/song.ogg', function( buffer ) {
  31. sound.setBuffer( buffer );
  32. sound.setRefDistance( 20 );
  33. sound.play();
  34. });
  35. // create an object for the sound to play from
  36. var sphere = new THREE.SphereGeometry( 20, 32, 16 );
  37. var material = new THREE.MeshPhongMaterial( { color: 0xff2200 } );
  38. var mesh = new THREE.Mesh( sphere, material );
  39. scene.add( mesh );
  40. // finally add the sound to the mesh
  41. mesh.add( sound );
  42. </code>
  43. <h2>Constructor</h2>
  44. <h3>[name]( [param:AudioListener listener] )</h3>
  45. <p>
  46. listener — (required) [page:AudioListener AudioListener] instance.
  47. </p>
  48. <h2>Properties</h2>
  49. <p>
  50. See the [page:Audio Audio] class for inherited properties.
  51. </p>
  52. <h3>[property:PannerNode panner]</h3>
  53. <p>The PositionalAudio's [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode PannerNode].</p>
  54. <h2>Methods</h2>
  55. <p>
  56. See the [page:Audio Audio] class for inherited methods.
  57. </p>
  58. <h3>[method:PannerNode getOutput]()</h3>
  59. <p>
  60. Returns the [page:PositionalAudio.panner panner].
  61. </p>
  62. <h3>[method:Number getRefDistance]()</h3>
  63. <p>
  64. Returns the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/refDistance panner.refDistance].
  65. </p>
  66. <h3>[method:PannerNode setRefDistance]( [param:Number value] )</h3>
  67. <p>
  68. Sets the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/refDistance panner.refDistance].
  69. </p>
  70. <h3>[method:PannerNode getRolloffFactor]()</h3>
  71. <p>
  72. Returns the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/rolloffFactor panner.rolloffFactor].
  73. </p>
  74. <h3>[method:PannerNode setRolloffFactor]( [param:Number value] )</h3>
  75. <p>
  76. Sets the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/rolloffFactor panner.rolloffFactor].
  77. </p>
  78. <h3>[method:String getDistanceModel]()</h3>
  79. <p>
  80. Returns the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/distanceModel panner.distanceModel].
  81. </p>
  82. <h3>[method:String setDistanceModel]( [param:String value] )</h3>
  83. <p>
  84. Sets the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/distanceModel panner.distanceModel].
  85. </p>
  86. <h3>[method:PannerNode getMaxDistance]()</h3>
  87. <p>
  88. Returns the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/maxDistance panner.maxDistance].
  89. </p>
  90. <h3>[method:PannerNode setMaxDistance]( [param:Number value] )</h3>
  91. <p>
  92. Sets the value of [link:https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/maxDistance panner.maxDistance].
  93. </p>
  94. <h2>Source</h2>
  95. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  96. </body>
  97. </html>