mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 06:48:04 +02:00
Update camera tool to wrap cursor to window bounds rather than keep at center
This commit is contained in:
parent
cddce8f795
commit
018a4af9d6
1 changed files with 32 additions and 9 deletions
|
@ -208,6 +208,11 @@ CameraManager = function() {
|
||||||
if (that.enabled && that.mode != MODE_INACTIVE) {
|
if (that.enabled && that.mode != MODE_INACTIVE) {
|
||||||
var x = Window.getCursorPositionX();
|
var x = Window.getCursorPositionX();
|
||||||
var y = Window.getCursorPositionY();
|
var y = Window.getCursorPositionY();
|
||||||
|
if (!hasDragged) {
|
||||||
|
that.lastMousePosition.x = x;
|
||||||
|
that.lastMousePosition.y = y;
|
||||||
|
hasDragged = true;
|
||||||
|
}
|
||||||
if (that.mode == MODE_ORBIT) {
|
if (that.mode == MODE_ORBIT) {
|
||||||
var diffX = x - that.lastMousePosition.x;
|
var diffX = x - that.lastMousePosition.x;
|
||||||
var diffY = y - that.lastMousePosition.y;
|
var diffY = y - that.lastMousePosition.y;
|
||||||
|
@ -235,9 +240,31 @@ CameraManager = function() {
|
||||||
|
|
||||||
that.moveFocalPoint(dPosition);
|
that.moveFocalPoint(dPosition);
|
||||||
}
|
}
|
||||||
var newX = Window.x + Window.innerWidth / 2;
|
|
||||||
var newY = Window.y + Window.innerHeight / 2;
|
var newX = x;
|
||||||
Window.setCursorPosition(newX, newY);
|
var newY = y;
|
||||||
|
var updatePosition = false;
|
||||||
|
|
||||||
|
if (x <= Window.x) {
|
||||||
|
newX = Window.x + Window.innerWidth;
|
||||||
|
updatePosition = true;
|
||||||
|
} else if (x >= (Window.x + Window.innerWidth)) {
|
||||||
|
newX = Window.x;
|
||||||
|
updatePosition = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y <= Window.y) {
|
||||||
|
newY = Window.y + Window.innerHeight;
|
||||||
|
updatePosition = true;
|
||||||
|
} else if (y >= (Window.y + Window.innerHeight)) {
|
||||||
|
newY = Window.y;
|
||||||
|
updatePosition = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updatePosition) {
|
||||||
|
Window.setCursorPosition(newX, newY);
|
||||||
|
}
|
||||||
|
|
||||||
that.lastMousePosition.x = newX;
|
that.lastMousePosition.x = newX;
|
||||||
that.lastMousePosition.y = newY;
|
that.lastMousePosition.y = newY;
|
||||||
|
|
||||||
|
@ -246,6 +273,7 @@ CameraManager = function() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hasDragged = false;
|
||||||
that.mousePressEvent = function(event) {
|
that.mousePressEvent = function(event) {
|
||||||
if (cameraTool.mousePressEvent(event)) {
|
if (cameraTool.mousePressEvent(event)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -260,12 +288,7 @@ CameraManager = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (that.mode != MODE_INACTIVE) {
|
if (that.mode != MODE_INACTIVE) {
|
||||||
var newX = Window.x + Window.innerWidth / 2;
|
hasDragged = false;
|
||||||
var newY = Window.y + Window.innerHeight / 2;
|
|
||||||
Window.setCursorPosition(newX, newY);
|
|
||||||
that.lastMousePosition.x = newX;
|
|
||||||
that.lastMousePosition.y = newY;
|
|
||||||
Window.setCursorVisible(false);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue