AudioListener.html 3.0 KB
Newer Older
N
nicholas 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<!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] &rarr;

		<h1>[name]</h1>

		<p class="desc">
16 17 18
			[name] 用一个虚拟的[link:https://developer.mozilla.org/de/docs/Web/API/AudioListener listener]表示在场景中所有的位置和非位置相关的音效.</br>
			一个three.js程序通常创建一个[name]. 它是音频实体构造函数的必须参数,比如 [page:Audio Audio] and [page:PositionalAudio PositionalAudio].</br>
			大多数情况下, listener对象是camera的子对象. Camera的3D变换表示了listener的3D变换.
N
nicholas 已提交
19 20 21
		</p>


22
		<h2>示例</h2>
N
nicholas 已提交
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

		<p>
			[example:webaudio_sandbox webaudio / sandbox ]</br>
			[example:webaudio_timing webaudio / timing ]</br>
			[example:webaudio_visualizer webaudio / visualizer ]
		</p>

		<code>
		// 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();
		audioLoader.load( 'sounds/ambient.ogg', function( buffer ) {
			sound.setBuffer( buffer );
			sound.setLoop(true);
			sound.setVolume(0.5);
			sound.play();
		});
		</code>


49
		<h2>构造函数</h2>
N
nicholas 已提交
50 51 52 53


		<h3>[name](  )</h3>
		<p>
54
		创建一个新的AudioListener.
N
nicholas 已提交
55 56 57
		</p>


58
		<h2>属性</h2>
N
nicholas 已提交
59 60

		<h3>[property:AudioContext context]</h3>
61
		<p>[page:AudioListener listener]构造函数中的[link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext AudioContext].</p>
N
nicholas 已提交
62 63

		<h3>[property:GainNode gain]</h3>
64
		<p>使用[link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createGain AudioContext.createGain]()创建 [link:https://developer.mozilla.org/en-US/docs/Web/API/GainNode GainNode].</p>
N
nicholas 已提交
65 66

		<h3>[property:AudioNode filter]</h3>
67
		<p>默认为*null*.</p>
N
nicholas 已提交
68

M
Mugen87 已提交
69 70
		<h3>[property:Number timeDelta]</h3>
		<p>Time delta value for audio entities. Use in context of [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioParam/linearRampToValueAtTime AudioParam.linearRampToValueAtTimeDefault](). Default is *0*.</p>
N
nicholas 已提交
71

72
		<h2>方法</h2>
N
nicholas 已提交
73 74 75 76


		<h3>[method:GainNode getInput]()</h3>
		<p>
77
		返回[page:AudioListener.gain gainNode].
N
nicholas 已提交
78 79 80 81
		</p>

		<h3>[method:AudioListener removeFilter]()</h3>
		<p>
82
		设置[page:AudioListener.filter filter]属性为*null*.
N
nicholas 已提交
83 84 85 86
		</p>

		<h3>[method:AudioNode getFilter]()</h3>
		<p>
87
		返回[page:AudioListener.filter filter]属性的值.
N
nicholas 已提交
88 89 90 91
		</p>

		<h3>[method:AudioListener setFilter]( [param:AudioNode value] )</h3>
		<p>
92
		设置[page:AudioListener.filter filter] 属性的值.
N
nicholas 已提交
93 94 95 96
		</p>

		<h3>[method:Float getMasterVolume]()</h3>
		<p>
97
		返回音量.
N
nicholas 已提交
98 99 100 101
		</p>

		<h3>[method:AudioListener setMasterVolume]( [param:Number value] )</h3>
		<p>
102
		设置音量.
N
nicholas 已提交
103 104 105
		</p>


106
		<h2>源码</h2>
N
nicholas 已提交
107 108 109 110

		[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
	</body>
</html>