PositionalAudio Class
PositionalAudio is used to play audio with positional audio effect using a WebAudio panner.
Using the positional audio object the sound is controlled by the camera that renders first in the scene.
Item Index
Methods
Properties
Attributes
Methods
getDistanceModel
()
String
Get distance model in use by this audio emitter.
Returns:
Distance model.
getMaxDistance
()
Get maximum distance for this audio emitter.
Returns:
Maximum distance.
getOutput
()
Object
Get output audio node.
Returns:
Output audio node.
getRefDistance
()
Number
Get reference distance.
Returns:
Reference distance.
getRolloffFactor
()
Number
Get rolloff factor.
Returns:
Rolloff factor.
initialize
()
Initialize audio object, loads audio data decodes it and starts playback if autoplay is set to True.
setDistanceModel
-
model
Set distance model to be used.
Distance model defined how the emitter controls its volume from its position in the world, relative to the camera.
By default the mode used is "inverse", can be also set to:
- "linear": A linear distance model calculating the gain induced by the distance according to
- 1 - rolloffFactor * (distance - refDistance) / (maxDistance - refDistance)
- "inverse": An inverse distance model calculating the gain induced by the distance according to:
- refDistance / (refDistance + rolloffFactor * (distance - refDistance))
- "exponential": An exponential distance model calculating the gain induced by the distance according to:
- pow(distance / refDistance, -rolloffFactor).
Parameters:
-
model
StringDistance Model to be used.
setMaxDistance
-
value
Set maximum distance for this audio emitter.
Parameters:
-
value
NumberMaximum distance.
setRefDistance
-
value
Set reference distance.
Parameters:
-
value
NumberReference distance.
setRolloffFactor
-
value
Set rolloff factor.
Parameters:
-
value
NumberRolloff factor.
update
()
Update positional audio panner relative to the camera.
Properties
distanceModel
String
Distance model to be applied to the audio panner.
panner
PannerNode
WebAudio panner effect.
https:// developer.mozilla.org/en-US/docs/Web/API/PannerNode
panningModel
String
Model to be applied to the audio panner.