Fix proximity
This commit is contained in:
parent
188e36c2a2
commit
791a2f9a64
|
@ -2215,7 +2215,7 @@ public class EaglerAdapterImpl2 {
|
||||||
panner.setOrientation(0f, 1f, 0f);
|
panner.setOrientation(0f, 1f, 0f);
|
||||||
panner.setPosition(0, 0, 0);
|
panner.setPosition(0, 0, 0);
|
||||||
float vol = getVoiceListenVolume();
|
float vol = getVoiceListenVolume();
|
||||||
panner.setMaxDistance(vol * getVoiceProximity() + 0.1f);
|
panner.setMaxDistance(vol * 2 * getVoiceProximity() + 0.1f);
|
||||||
GainNode gain = audioctx.createGain();
|
GainNode gain = audioctx.createGain();
|
||||||
gain.getGain().setValue(vol);
|
gain.getGain().setValue(vol);
|
||||||
analyser.connect(gain);
|
analyser.connect(gain);
|
||||||
|
@ -2280,6 +2280,7 @@ public class EaglerAdapterImpl2 {
|
||||||
|
|
||||||
private static int proximity = 16;
|
private static int proximity = 16;
|
||||||
public static final void setVoiceProximity(int prox) {
|
public static final void setVoiceProximity(int prox) {
|
||||||
|
for (PannerNode panner : voicePanners.values()) panner.setMaxDistance(getVoiceListenVolume() * 2 * prox + 0.1f);
|
||||||
proximity = prox;
|
proximity = prox;
|
||||||
}
|
}
|
||||||
public static final int getVoiceProximity() {
|
public static final int getVoiceProximity() {
|
||||||
|
@ -2288,12 +2289,14 @@ public class EaglerAdapterImpl2 {
|
||||||
|
|
||||||
private static float volumeListen = 0.5f;
|
private static float volumeListen = 0.5f;
|
||||||
public static final void setVoiceListenVolume(float f) {
|
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;
|
float val = f;
|
||||||
if(val > 0.5f) val = 0.5f + (val - 0.5f) * 3.0f;
|
if(val > 0.5f) val = 0.5f + (val - 0.5f) * 3.0f;
|
||||||
if(val > 2.0f) val = 2.0f;
|
if(val > 2.0f) val = 2.0f;
|
||||||
if(val < 0.0f) val = 0.0f;
|
if(val < 0.0f) val = 0.0f;
|
||||||
gain.getGain().setValue(val * 2.0f);
|
gain.getGain().setValue(val * 2.0f);
|
||||||
|
if (voicePanners.containsKey(username)) voicePanners.get(username).setMaxDistance(f * 2 * getVoiceProximity() + 0.1f);
|
||||||
}
|
}
|
||||||
volumeListen = f;
|
volumeListen = f;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user