After some search on this site I understand that I have no control over a browser’s mousemove event frequency.
So I want to apply some kind of extrapolation method to solve the lagged mousemove event problem.
I record every mouse position when the mousemove event is triggered, and calculate the acceleration (make use of finite difference to get velocity, and then acceleration).
After that in the render() function, I measure the delta time elapsed from last render() function call.
Finally I extrapolate the position with acceleration and dt.
But I do not see any significant effect using this method. Is there anything wrong?
EDIT: I make a small running example here. (sorry for the unclear question statements)
Just after I paste my code on the gist I realize the problem and then fix the bug.
The problem is:
I use NDC coordinate to compute the derivative, while I use world space coordinate to do the extrapolation.
This is the new code:
https://gist.github.com/3858277
Conclusion:
There is some effect on the lagged
mouseevent, but not so much. And as a (bad) side effect, there will be a over-shoot when your mouse movement makes an emergency braking.I am still seeking a better solution. Any opinion/suggestion is welcome.
Thank you.