4 ms·
Neither of the APIs you mention exist. Maybe you mean requestAnimationFrame? That still doesn't solve the problem of getting the current mouse coordinates thoug
by blaisio 11y ago
Neither of the APIs you mention exist. Maybe you mean requestAnimationFrame? That still doesn't solve the problem of getting the current mouse coordinates though. Currently, the only way to get them is through events like mousemove.
Honestly, it would be wonderful if we had immediate mode APIs for everything instead of being forced to register event handlers, which will always lag at least 1 frame behind.
- adrusi 11y agoWhoops, yeah it's been a while since I worried about stuff like this in javascript. I guess what I remembered doing was keeping track of cursor position in a global, updated on every mousemove to simulate immediate mode in a requestAnimationFrame callback. But as you say, that retains all the disadvantages of event latency. requestAnimationFrame is designed for immediate mode rendering, so it should probably pass its callback some information about input states or offer some other way of getting that.