Skip to content

Mouse jump glitchy problem with Chrome Win10 360 spin keep moving mouse to right. #37

@LiamKarlMitchell

Description

@LiamKarlMitchell

A problem that can happen when spinning around is that the position suddenly jumps a lot in Chrome.
There may be a fix for this that they have not pushed into Chrome yet.

I am only listing this issue here because I noticed it in WebQuake in-case others have this problem and think WebQuake is to blame, it is not related to WebQuake.

Possible work around, lerp the delta by some constant not ideal.

function lerp(v0, v1, t) {
	return (1 - t) * v0 + t * v1;
}

function getChromeVersion () {
    var pieces = navigator.userAgent.match(/Chrom(?:e|ium)\/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)/);
    if (pieces == null || pieces.length != 5) {
        return undefined;
    }
    pieces = pieces.map(piece => parseInt(piece, 10));
    return {
        major: pieces[1],
        minor: pieces[2],
        build: pieces[3],
        patch: pieces[4]
    };
}

var usePointerLock360BugWorkaround = false;
var chromeVersion = getChromeVersion();
if (chromeVersion) {
	usePointerLock360BugWorkaround = true;
	IN.mouse_delta_x = 0;
	IN.mouse_delta_y = 0;
}

IN.onmousemove = function(e)
{
	if (document[IN.pointerLockElement] !== VID.mainwindow)
		return;
	if (usePointerLock360BugWorkaround === false) {
		IN.mouse_x += e[IN.movementX];
		IN.mouse_y += e[IN.movementY];
	} else {
		// Workaround Chrome mouseMove "sudden jump" bug.
		IN.mouse_delta_x = lerp(IN.mouse_delta_x, e[IN.movementX], 0.75);
		IN.mouse_delta_y = lerp(IN.mouse_delta_y, e[IN.movementY], 0.75);
		IN.mouse_x += IN.mouse_delta_x;
		IN.mouse_y += IN.mouse_delta_y;
	}
};

Related links:
http://www.html5gamedevs.com/topic/34516-pointer-lock-bug-on-chrome-with-windows-10/
https://bugs.chromium.org/p/chromium/issues/detail?id=781182
https://bugs.chromium.org/p/chromium/issues/detail?id=461373
https://bugs.chromium.org/p/chromium/issues/detail?id=411634
https://bugs.chromium.org/p/chromium/issues/detail?id=784122

Possible work around to lerp the delta values found here, going to try adding this as a work-around.
mrdoob/three.js#12757

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions