Takes the previous and current Pointer positions and then generates an array of interpolated values between
the two. The array will be populated up to the size of the steps
argument.
var points = pointer.getInterpolatedPosition(4);
// points[0] = { x: 0, y: 0 }
// points[1] = { x: 2, y: 1 }
// points[2] = { x: 3, y: 2 }
// points[3] = { x: 6, y: 3 }
Use this if you need to get smoothed values between the previous and current pointer positions. DOM pointer events can often fire faster than the main browser loop, and this will help you avoid janky movement especially if you have an object following a Pointer.
Note that if you provide an output array it will only be populated up to the number of steps provided. It will not clear any previous data that may have existed beyond the range of the steps count.
Internally it uses the Smooth Step interpolation calculation.
name | type | arguments | Default | description |
---|---|---|---|---|
steps | number | <optional> | 10 |
The number of interpolation steps to use. |
out | array | <optional> |
An array to store the results in. If not provided a new one will be created. |
An array of interpolated values.