src/inputjs/get-velocity.js
raw| 1 | /** |
| 2 | * @private |
| 3 | * calculate the velocity between two points. unit is in px per ms. |
| 4 | * @param {Number} deltaTime |
| 5 | * @param {Number} x |
| 6 | * @param {Number} y |
| 7 | * @return {Object} velocity `x` and `y` |
| 8 | */ |
| 9 | export default function getVelocity(deltaTime, x, y) { |
| 10 | return { |
| 11 | x: x / deltaTime || 0, |
| 12 | y: y / deltaTime || 0 |
| 13 | }; |
| 14 | } |