Use Three.js PositionalAudio to create a cone of sound.

I create an array of sounds using PositionalAudio:

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

And I attached these voices to the cubes, but I only want to let the user hear the sound if they are facing the cube at an angle of 30 degrees. Everything outside the 30 degree cone should be quiet.

I see the documentation here , but the only parameter that works is the one I used setRefDistance. Others do not work. I am using r74.

Any ideas? The bottom line is: https://gist.github.com/evejweinberg/949e297c34177199386f945549a45c06

+4
source share
1 answer

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: , , . - 360.

coneOuterAngle: , , coneOuterGain. - 360.

coneOuterGain: , coneOuterAngle. : 0.

:

+2

All Articles