Map Range
Converts a number from one range to another.
Node id math/map-range
The Map Range node takes a value in the range from fromMin to
fromMax, and outputs the number at the same place in the range from
toMin to toMax. For example, to turn the distance between two points
(0 to 500) into a scale factor (0.2 to 1.5), connect a
Distance to value and set the four ends:
a distance of 0 gives 0.2, 250 gives 0.85 and 500 gives 1.5.
Parameters
| Name | Type | Default |
|---|---|---|
| clamp | boolean | false |
| curve | EasingCurve | "linear" |
| mode | EasingMode | "in-out" |
Inputs
| Name | Type | Default | Notes |
|---|---|---|---|
| value | number | 0.5 | |
| fromMin | number | 0 | |
| fromMax | number | 1 | |
| toMin | number | 0 | |
| toMax | number | 1 |
Outputs
| Name | Type | Notes |
|---|---|---|
| result | number |
Behaviour
- Defaults.
valuedefaults to 0.5, and both ranges to 0 to 1, so the node outputsvalueunchanged until the ends are set. - Exact ends.
fromMingives exactlytoMin, andfromMaxexactlytoMax. - Not clamped by default. A
valueoutside its range continues the line past the ends: from 0–10 to 100–200, 20 gives 300 and -5 gives 50. Turn on theclampparameter (on the node or in the property inspector) to keep the result betweentoMinandtoMax. - Reversed ranges are not an error: they invert the mapping. From 0–10
to 100–0, 2 gives 80. With
clamp, the result stays between the lower and the higher oftoMinandtoMax, whichever is which. - An empty source range (
fromMin=fromMax) divides by zero, like Divide: the result is Infinity or -Infinity, or NaN whenvalueequals them too. There is no node error.clampturns an infinite result into the nearest end, but not a NaN. - Easing parameters. Parameters
curve(defaultlinear) andmode(defaultin-out) shape the mapped output with non-linear easing curves (such ascubic,bounce, orsine).
Related nodes
- Inverse Lerp and Lerp: the two halves of Map Range.
- Clamp: limits a number to a range without mapping it.