1234567891011121314151617181920 |
- const randRange = (low, high) => Math.random() * (high - low) + low;
- const toRadians = (degrees) => degrees * Math.PI / 180;
- const mapNumber = (value, fromLow, fromHigh, toLow, toHigh) => {
- const normalized = (value - fromLow) / (fromHigh - fromLow);
- return normalized * (toHigh - toLow) + toLow;
- };
-
- let fps_value = 0;
- let fps_frames = 0;
- let fps_last_capture = Date.now();
- const fps = () => {
- fps_frames++;
- if (Date.now() - fps_last_capture >= 500) {
- fps_value = fps_frames * 2;
- fps_frames = 0;
- fps_last_capture = Date.now();
- }
-
- return fps_value;
- }
|