API

Interface ISpatialAudioOptions

Options for spatial audio.

interface ISpatialAudioOptions {
    spatialAutoUpdate: boolean;
    spatialConeInnerAngle: number;
    spatialConeOuterAngle: number;
    spatialConeOuterVolume: number;
    spatialDistanceModel: "linear" | "inverse" | "exponential";
    spatialEnabled: boolean;
    spatialMaxDistance: number;
    spatialMinDistance: number;
    spatialMinUpdateTime: number;
    spatialOrientation: Vector3;
    spatialPanningEnabled: boolean;
    spatialPanningModel: "equalpower" | "HRTF";
    spatialPosition: Vector3;
    spatialRolloffFactor: number;
    spatialRotation: Vector3;
    spatialRotationQuaternion: Quaternion;
}

Hierarchy (View Summary)

Index
spatialAutoUpdate: boolean

Whether to automatically update the spatial properties of the audio node. Defaults to true.

spatialConeInnerAngle: number

The spatial cone inner angle, in radians. Defaults to 2π.

  • When the listener is inside the cone inner angle, the volume is at its maximum.
spatialConeOuterAngle: number

The spatial cone outer angle, in radians. Defaults to 2π.

  • When the listener is between the the cone inner and outer angles, the volume fades to its minimum as the listener approaches the outer angle.
  • When the listener is outside the cone outer angle, the volume is at its minimum.
spatialConeOuterVolume: number

The amount of volume reduction outside the spatialConeOuterAngle. Defaults to 0.

spatialDistanceModel: "linear" | "inverse" | "exponential"

The algorithm to use to reduce the volume of the audio source as it moves away from the listener. Defaults to "inverse".

Possible values are:

  • "linear": The volume is reduced linearly as the source moves away from the listener.
  • "inverse": The volume is reduced inversely as the source moves away from the listener.
  • "exponential": The volume is reduced exponentially as the source moves away from the listener.
spatialEnabled: boolean

Enable spatial audio. Defaults to false.

When set to true, the audio node's spatial properties will be initialized on creation and there will be no delay when setting the first spatial value.

When not specified, or set to false, the audio node's spatial properties will not be initialized on creation and there will be a small delay when setting the first spatial value.

  • This option is ignored if any other spatial options are set.
spatialMaxDistance: number

The maximum distance between the audio source and the listener, after which the volume is not reduced any further. Defaults to 10000.

spatialMinDistance: number

The distance for reducing volume as the audio source moves away from the listener – i.e. the distance the volume reduction starts at. Defaults to 1.

  • This value is used by all distance models.
spatialMinUpdateTime: number

The minimum update time in seconds of the spatialization if it is attached to a mesh or transform node. Defaults to 0.

  • The spatialization's position and rotation will not update faster than this time, but they may update slower depending on the frame rate.
spatialOrientation: Vector3

The spatial orientation used to determine the direction of the audio source. Defaults to (0, 0, -1).

spatialPanningEnabled: boolean

Whether to spatially pan the audio source. Defaults to true.

When set to false, the source keeps distance attenuation but does not pan between the left and right channels. Sound cone attenuation is not applied while panning is disabled.

spatialPanningModel: "equalpower" | "HRTF"

Possible values are:

  • "equalpower": Represents the equal-power panning algorithm, generally regarded as simple and efficient.
  • "HRTF": Renders a stereo output of higher quality than "equalpower" — it uses a convolution with measured impulse responses from human subjects.
spatialPosition: Vector3

The spatial position. Defaults to (0, 0, 0).

spatialRolloffFactor: number

How quickly the volume is reduced as the source moves away from the listener. Defaults to 1.

  • This value is used by all distance models.
spatialRotation: Vector3

The spatial rotation, as Euler angles. Defaults to (0, 0, 0).

spatialRotationQuaternion: Quaternion

The spatial rotation, as a quaternion. Defaults to (0, 0, 0, 1).