/WebGL-Mouse-Input-Fix

WebGL Mouse Input Fix - Fix for High Polling Rates

Primary LanguageJavaScriptGNU Affero General Public License v3.0AGPL-3.0

WebGL Mouse Input Fix - Fix for High Polling Rates

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.

Usage

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>

License

GNU AGPLv3 Image

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.