This code provides a fix for the WebGL mouse input issue caused by high polling rates in browsers like Chromium. It overrides the requestPointerLock
function to include the unadjustedMovement
option.
Add the following code before all scripts in your game or application's index.html
:
<script>
const oRequestPointerLock = Element.prototype.requestPointerLock;
Element.prototype.requestPointerLock = async function hkRequestPointerLock(...args) {
try {
(args[0] ||= {}).unadjustedMovement = true;
await oRequestPointerLock.apply(this, args);
} catch (err) {
console.log(err);
}
};
</script>
This program is Free Software: You can use, study share and improve it at your will. Specifically you can redistribute and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.