PointerLockControls movement never reaches full stop

Hello guys, I recently observed a very weird behavior which kept messing with my y auto booster, today I discovered where the problem was. I narrowed the problem down to PointerLockControls itself. It looks like once you press any movement key and never once again, the velocity will never reach 0 even if you would leave it running overnight (Dont take me for the word its just a metaphor). I believe this is caused by the precision performance.now(), however I am really not sure. Anyhow, I was wondering if this is a known issue and if so, what are the work arounds, as it seems to be causing even another of my bugs - when leaving the tab inactive for a while and returning, I will find myself somewhere outside the map, in the oblivion.

EDIT: The same trend also occurs with Date.now()

I recently had the same issue, one of the biggest problems is switching away from and back to the browser tab leaves the controls moving in negative velocity, I was going to use an if statement, if (velocity < 0.05) {velocity = 0} but ended up switching the time variable from performance.now() to a global variable, var time = 0 then in render loop do time += 0.1

1 Like

Hi, I tried your workaround but it unfortunately seems to not fix the issue. Your first workaround actually does fix the problem, (funny thing I actually did it like few minutes before your reply) but I feel like it is not really the proper solution and could still bring new issues to the table later. But thanks for the reply!