Fix proximity

This commit is contained in:
ayunami2000 2022-07-21 19:23:51 -04:00
parent 188e36c2a2
commit 791a2f9a64

View File

@ -2215,7 +2215,7 @@ public class EaglerAdapterImpl2 {
panner.setOrientation(0f, 1f, 0f);
panner.setPosition(0, 0, 0);
float vol = getVoiceListenVolume();
panner.setMaxDistance(vol * getVoiceProximity() + 0.1f);
panner.setMaxDistance(vol * 2 * getVoiceProximity() + 0.1f);
GainNode gain = audioctx.createGain();
gain.getGain().setValue(vol);
analyser.connect(gain);
@ -2280,6 +2280,7 @@ public class EaglerAdapterImpl2 {
private static int proximity = 16;
public static final void setVoiceProximity(int prox) {
for (PannerNode panner : voicePanners.values()) panner.setMaxDistance(getVoiceListenVolume() * 2 * prox + 0.1f);
proximity = prox;
}
public static final int getVoiceProximity() {
@ -2288,12 +2289,14 @@ public class EaglerAdapterImpl2 {
private static float volumeListen = 0.5f;
public static final void setVoiceListenVolume(float f) {
for (GainNode gain : voiceGains.values()) {
for (String username : voiceGains.keySet()) {
GainNode gain = voiceGains.get(username);
float val = f;
if(val > 0.5f) val = 0.5f + (val - 0.5f) * 3.0f;
if(val > 2.0f) val = 2.0f;
if(val < 0.0f) val = 0.0f;
gain.getGain().setValue(val * 2.0f);
if (voicePanners.containsKey(username)) voicePanners.get(username).setMaxDistance(f * 2 * getVoiceProximity() + 0.1f);
}
volumeListen = f;
}