SpatialSourceState

Position of a spatial source relative to the listener.

interface SpatialSourceState {
    local: Vector3;
    direction: Vector3;
    distance: number;
    azimuth: number;
    elevation: number;
    attenuation: number;
    normalizedDistance: number;
}

About

Calculated by renderer.computeSourceState() and stored in source.state on every renderer.update(). Useful for debugging, UI and gameplay logic (for example: "is this sound audible?").

Properties

  • local: Vector3 - Position of the source in listener space: x = right, y = up, z = forward. y is always 0 in 2D.
  • direction: Vector3 - Unit vector from the listener towards the source, in listener space. (0, 0, 1) when the source is exactly on the listener.
  • distance: number - Distance to the listener.
  • azimuth: number - Horizontal angle relative to the facing direction of the listener, in radians. Positive is to the right, Math.PI (or -Math.PI) is directly behind.
  • elevation: number - Vertical angle relative to the listener, in radians. Positive is up. Always 0 in 2D.
  • attenuation: number - Distance based attenuation, between 0 and 1.
  • normalizedDistance: number - Distance mapped from refDistance (0) to maxDistance (1).