javascript - 使用 Three.js PositionalAudio 制作音锥

标签 javascript audio three.js

我正在使用 PositionalAudio 创建一组声音:

 var newVoice = new THREE.PositionalAudio(listener);
 newVoice.setBuffer(buffer);
 newVoice.setRefDistance(20);
 newVoice.autoplay = true;
 newVoice.setLoop(true);
 voices.push(newVoice);

我已将这些声音附加到立方体上,但我只想让用户在从 30 度的直 Angular 面对立方体时听到声音。 30 度锥体之外的任何东西都应该保持静音。

我看到 documentation here但唯一有效的参数是我使用的“setRefDistance”。其他的不工作。我正在使用 r74。

有什么想法吗?要点在这里:https://gist.github.com/evejweinberg/949e297c34177199386f945549a45c06

最佳答案

Three.js Audio 是网络音频 API 的包装器。您可以将所有设置应用到平移器,这可以使用 getOutput():

var sound = new THREE.PositionalAudio( listener );
var panner = sound.getOutput();
panner.coneInnerAngle = innerAngleInDegrees;
panner.coneOuterAngle = outerAngleInDegrees;
panner.coneOuterGain = outerGainFactor;

coneInnerAngle: A parameter for directional audio sources, this is an angle, inside of which there will be no volume reduction. The default value is 360.

coneOuterAngle: A parameter for directional audio sources, this is an angle, outside of which the volume will be reduced to a constant value of coneOuterGain. The default value is 360.

coneOuterGain: A parameter for directional audio sources, this is the amount of volume reduction outside of the coneOuterAngle. The default value is 0.

来源:

关于javascript - 使用 Three.js PositionalAudio 制作音锥,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36706118/

相关文章:

javascript - 为什么 Eslint 会在 Airbnb 风格指南的原子中的两个空格规则中抛出错误,即使我将其设置为两个空格和硬制表符?

javascript - 根据所选对象更新 dat.gui

javascript - 如何将 id 添加到 @Html.DisplayFor

javascript - 在 jQuery 中,如何获取嵌套循环中的下一个选择器?

javascript - 如何在 Javascript 中连接多个 php 变量

c# - MIDI 或 WAV 文件到一组频率和持续时间

windows - 多声道声音与 winmm,许多 WaveOutOpen?

javascript - 我需要构建类似于此html音频示例的内容

javascript - three.js 中的轨迹球控件

javascript - 对全景旋转实现阻尼(惯性)