Skip to main content
Version: 0.2.0


Class describing a piecewise-linear curve for conversion between a source's distance to the listener and its attenuation.

It is defined by three points a, b, and c, and the maxDistance property. For distances beyond maxDistance the source will be silent.

The first point a not only defines its sampled point (x, y) on the (distance, level) graph, but also the level for distances smaller than a's distance.

The graph will look something like

| \
| \___C
| B \
| \
| \
|-----------\---> DISTANCE

Levels are expected in Decibels, so 0 would be unity gain, and values below zero will attenuate the source's audio level.

Public Interface


getParameters(): { a: Point2D; b: Point2D; c: Point2D; maxDistance: number; }

Returns the current parameters.

setParameters(ax: number, ay: number, bx: number, by: number, cx: number, cy: number, maxDistance: number): void

Sets new parameters.