Skip to content

Documentation / @ripl/3d / computeDistanceAttenuation

Function: computeDistanceAttenuation() ​

computeDistanceAttenuation(distance, range, decay): number

Defined in: 3d/src/core/shading.ts:362

Computes distance falloff for a positional light.

Matches three.js: a distance of 0 means the light never falls to zero and only the decay applies, otherwise the inverse-power falloff is windowed so it reaches exactly zero at the range.

Parameters ​

ParameterTypeDescription
distancenumberDistance from the light to the surface.
rangenumberThe distance at which the light falls to zero, or 0 for unbounded.
decaynumberThe exponent of the inverse-distance falloff.

Returns ​

number

The attenuation factor.