diff --git a/app/src/components/AudioArea.vue b/app/src/components/AudioArea.vue index 3c61fe8..12b9030 100644 --- a/app/src/components/AudioArea.vue +++ b/app/src/components/AudioArea.vue @@ -22,6 +22,11 @@ export default defineComponent({ setup(props) { const audio = ref(null); + const MIN_SCALE = 0.02; + const MIN_VOLUME_MULTIPLIER = 0.25; + const vol_x = (1 - MIN_VOLUME_MULTIPLIER) / (1 - MIN_SCALE); + const vol_b = 1 - vol_x; + const onBBoxChange = () => { const x = props.bbox.x + props.bbox.w / 2; const y = props.bbox.y + props.bbox.h / 2; @@ -29,7 +34,8 @@ export default defineComponent({ if (distance < props.definition.radius) { audio.value!.play(); - audio.value!.volume = (props.definition.radius - distance) / props.definition.radius; + const volume = (props.definition.radius - distance) / props.definition.radius; + audio.value!.volume = volume * (props.bbox.z < 1 ? (props.bbox.z * vol_x + vol_b) : 1); } else { audio.value!.pause(); }