Skip to main content

Interface: AudioSpatial

Defined in: webxr-environment/src/audio.ts:62

How a positional voice gets quieter with distance.

Every field is something all three hosts already expose per source - three's PositionalAudio has setRefDistance, setRolloffFactor, setMaxDistance and setDistanceModel; IWSDK's AudioSource has the same four, one of them as a DistanceModel enum; XR Blocks' spatial audio has its own equivalents. Leaving them out of the contract does not make the stack portable, it makes every adapter apply one constant to every sound, which is the opposite of the job: a footstep and a waterfall do not fall off at the same rate.

Omitted fields are the host's own defaults, which is why there is no "resolved" form of this. The core has no opinion about how far a sound carries.

Properties

PropertyModifierTypeDescriptionDefined in
cone?readonlyAudioConeWhich way the sound points, and how narrowly. Distance says how quiet a sound gets as you walk away; this says how quiet it gets as you walk AROUND it. A television, a PA horn and a person talking are all quieter behind than in front, and without this every one of them plays as a glowing orb of sound. The cone is a property of the CUE, because it describes what kind of thing is making the noise. Which way that particular one is turned is a property of the play - see PlayOptions.facing.webxr-environment/src/audio.ts:83
maxDistance?readonlynumberMetres past which it gets no quieter.webxr-environment/src/audio.ts:68
model?readonly"linear" | "exponential" | "inverse"The attenuation curve. Web Audio's three, which every host maps to.webxr-environment/src/audio.ts:70
refDistance?readonlynumberMetres at which the sound is at full volume.webxr-environment/src/audio.ts:64
rolloffFactor?readonlynumberHow quickly it falls off past that. Higher is faster.webxr-environment/src/audio.ts:66