提交 113fbee4 编写于 作者: M Mugen87

Docs: Update Audio Entities

上级 6b116a5f
......@@ -21,18 +21,21 @@
<h2>Example</h2>
<div>[example:misc_sound misc / sound ]</div>
<div>
[example:webaudio_sandbox webaudio / sandbox ]</br>
[example:webaudio_visualizer webaudio / visualizer ]
</div>
<code>
//Create an AudioListener and add it to the camera
// create an AudioListener and add it to the camera
var listener = new THREE.AudioListener();
camera.add( listener );
// create a global audio source
var sound = new THREE.Audio( listener );
// load a sound and set it as the Audio object's buffer
var audioLoader = new THREE.AudioLoader();
//Load a sound and set it as the Audio object's buffer
audioLoader.load( 'sounds/ambient.ogg', function( buffer ) {
sound.setBuffer( buffer );
sound.setLoop( true );
......
......@@ -21,18 +21,21 @@
<h2>Example</h2>
<div>[example:misc_sound misc / sound ]</div>
<div>
[example:webaudio_sandbox webaudio / sandbox ]</br>
[example:webaudio_visualizer webaudio / visualizer ]
</div>
<code>
//Create an AudioListener and add it to the camera
// create an AudioListener and add it to the camera
var listener = new THREE.AudioListener();
camera.add( listener );
// create an Audio source
var sound = new THREE.Audio( listener );
// load a sound and set it as the Audio object's buffer
var audioLoader = new THREE.AudioLoader();
//Load a sound and set it as the Audio object's buffer
audioLoader.load( 'sounds/ambient.ogg', function( buffer ) {
sound.setBuffer( buffer );
sound.setLoop(true);
......@@ -40,11 +43,11 @@
sound.play();
});
//Create an AudioAnalyser, passing in the sound and desired fftSize
// create an AudioAnalyser, passing in the sound and desired fftSize
var analyser = new THREE.AudioAnalyser( sound, 32 );
//Get the average frequency of the sound
analyser.getAverageFrequency();
// get the average frequency of the sound
var data = analyser.getAverageFrequency();
</code>
......
......@@ -13,27 +13,30 @@
<h1>[name]</h1>
<div class="desc">
Create a non-positional ( global ) audio object.<br /><br />
This uses the [link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API Web Audio API].
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>
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>
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.
</div>
<h2>Example</h2>
<div>[example:misc_sound misc / sound ]</div>
<div>
[example:webaudio_sandbox webaudio / sandbox ]</br>
[example:webaudio_timing webaudio / timing ]</br>
[example:webaudio_visualizer webaudio / visualizer ]
</div>
<code>
//Create an AudioListener and add it to the camera
// create an AudioListener and add it to the camera
var listener = new THREE.AudioListener();
camera.add( listener );
// create a global audio source
var sound = new THREE.Audio( listener );
// load a sound and set it as the Audio object's buffer
var audioLoader = new THREE.AudioLoader();
//Load a sound and set it as the Audio object's buffer
audioLoader.load( 'sounds/ambient.ogg', function( buffer ) {
sound.setBuffer( buffer );
sound.setLoop(true);
......
......@@ -21,16 +21,20 @@
<h2>Example</h2>
<div>[example:misc_sound misc / sound ]</div>
<div>
[example:webaudio_sandbox webaudio / sandbox ]</br>
[example:webaudio_timing webaudio / timing ]
</div>
<code>
//Create an AudioListener and add it to the camera
// 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)
// 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
// 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 );
......@@ -38,13 +42,13 @@
sound.play();
});
//Create an object for the sound to play from
// 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
// finally add the sound to the mesh
mesh.add( sound );
</code>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册