mirror of
https://github.com/overte-org/overte.git
synced 2025-06-15 19:39:16 +02:00
Fix mouse seek bugs.
This commit is contained in:
parent
11ae685f04
commit
9edd18c017
1 changed files with 4 additions and 3 deletions
|
@ -150,7 +150,7 @@ var isSeeking = false;
|
||||||
var averageMouseVelocity = 0, lastIntegration = 0, lastMouse;
|
var averageMouseVelocity = 0, lastIntegration = 0, lastMouse;
|
||||||
var WEIGHTING = 1 / 20; // simple moving average over last 20 samples
|
var WEIGHTING = 1 / 20; // simple moving average over last 20 samples
|
||||||
var ONE_MINUS_WEIGHTING = 1 - WEIGHTING;
|
var ONE_MINUS_WEIGHTING = 1 - WEIGHTING;
|
||||||
var AVERAGE_MOUSE_VELOCITY_FOR_SEEK_TO = 5;
|
var AVERAGE_MOUSE_VELOCITY_FOR_SEEK_TO = 20;
|
||||||
function isShakingMouse() { // True if the person is waving the mouse around trying to find it.
|
function isShakingMouse() { // True if the person is waving the mouse around trying to find it.
|
||||||
var now = Date.now(), mouse = Reticle.position, isShaking = false;
|
var now = Date.now(), mouse = Reticle.position, isShaking = false;
|
||||||
if (lastIntegration && (lastIntegration !== now)) {
|
if (lastIntegration && (lastIntegration !== now)) {
|
||||||
|
@ -176,11 +176,12 @@ function updateSeeking() {
|
||||||
function updateDimension(axis) {
|
function updateDimension(axis) {
|
||||||
var distanceBetween = lookAt2D[axis] - Reticle.position[axis];
|
var distanceBetween = lookAt2D[axis] - Reticle.position[axis];
|
||||||
var move = distanceBetween / NON_LINEAR_DIVISOR;
|
var move = distanceBetween / NON_LINEAR_DIVISOR;
|
||||||
if (move >= MINIMUM_SEEK_DISTANCE) { return false; }
|
if (Math.abs(move) < MINIMUM_SEEK_DISTANCE) { return false; }
|
||||||
copy[axis] += move;
|
copy[axis] += move;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!updateDimension('x') && !updateDimension('y')) {
|
var okX = !updateDimension('x'), okY = !updateDimension('y'); // Evaluate both. Don't short-circuit.
|
||||||
|
if (okX && okY) {
|
||||||
isSeeking = false;
|
isSeeking = false;
|
||||||
} else {
|
} else {
|
||||||
Reticle.setPosition(copy); // Not setReticlePosition
|
Reticle.setPosition(copy); // Not setReticlePosition
|
||||||
|
|
Loading…
Reference in a new issue