mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Update edit camera controls to hide cursor
This commit is contained in:
parent
45725db78e
commit
87a17f869f
1 changed files with 23 additions and 12 deletions
|
@ -25,7 +25,7 @@ var ZOOM_SCALING = 0.02;
|
||||||
var MIN_ZOOM_DISTANCE = 0.01;
|
var MIN_ZOOM_DISTANCE = 0.01;
|
||||||
var MAX_ZOOM_DISTANCE = 200;
|
var MAX_ZOOM_DISTANCE = 200;
|
||||||
|
|
||||||
var MODE_INACTIVE = null;
|
var MODE_INACTIVE = 'inactive';
|
||||||
var MODE_ORBIT = 'orbit';
|
var MODE_ORBIT = 'orbit';
|
||||||
var MODE_PAN = 'pan';
|
var MODE_PAN = 'pan';
|
||||||
|
|
||||||
|
@ -158,9 +158,11 @@ CameraManager = function() {
|
||||||
|
|
||||||
that.mouseMoveEvent = function(event) {
|
that.mouseMoveEvent = function(event) {
|
||||||
if (that.enabled && that.mode != MODE_INACTIVE) {
|
if (that.enabled && that.mode != MODE_INACTIVE) {
|
||||||
|
var x = Window.getCursorPositionX();
|
||||||
|
var y = Window.getCursorPositionY();
|
||||||
if (that.mode == MODE_ORBIT) {
|
if (that.mode == MODE_ORBIT) {
|
||||||
var diffX = event.x - that.lastMousePosition.x;
|
var diffX = x - that.lastMousePosition.x;
|
||||||
var diffY = event.y - that.lastMousePosition.y;
|
var diffY = y - that.lastMousePosition.y;
|
||||||
that.targetYaw -= MOUSE_SENSITIVITY * (diffX / 5.0)
|
that.targetYaw -= MOUSE_SENSITIVITY * (diffX / 5.0)
|
||||||
that.targetPitch += MOUSE_SENSITIVITY * (diffY / 10.0)
|
that.targetPitch += MOUSE_SENSITIVITY * (diffY / 10.0)
|
||||||
|
|
||||||
|
@ -172,8 +174,8 @@ CameraManager = function() {
|
||||||
|
|
||||||
that.updateCamera();
|
that.updateCamera();
|
||||||
} else if (that.mode == MODE_PAN) {
|
} else if (that.mode == MODE_PAN) {
|
||||||
var diffX = event.x - that.lastMousePosition.x;
|
var diffX = x - that.lastMousePosition.x;
|
||||||
var diffY = event.y - that.lastMousePosition.y;
|
var diffY = y - that.lastMousePosition.y;
|
||||||
|
|
||||||
var up = Quat.getUp(Camera.getOrientation());
|
var up = Quat.getUp(Camera.getOrientation());
|
||||||
var right = Quat.getRight(Camera.getOrientation());
|
var right = Quat.getRight(Camera.getOrientation());
|
||||||
|
@ -185,8 +187,11 @@ CameraManager = function() {
|
||||||
|
|
||||||
that.moveFocalPoint(dPosition);
|
that.moveFocalPoint(dPosition);
|
||||||
}
|
}
|
||||||
that.lastMousePosition.x = event.x;
|
var newX = Window.x + Window.innerWidth / 2;
|
||||||
that.lastMousePosition.y = event.y;
|
var newY = Window.y + Window.innerHeight / 2;
|
||||||
|
Window.setCursorPosition(newX, newY);
|
||||||
|
that.lastMousePosition.x = newX;
|
||||||
|
that.lastMousePosition.y = newY;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -198,13 +203,18 @@ CameraManager = function() {
|
||||||
|
|
||||||
if (event.isRightButton || (event.isLeftButton && event.isControl && !event.isShifted)) {
|
if (event.isRightButton || (event.isLeftButton && event.isControl && !event.isShifted)) {
|
||||||
that.mode = MODE_ORBIT;
|
that.mode = MODE_ORBIT;
|
||||||
that.lastMousePosition.x = event.x;
|
|
||||||
that.lastMousePosition.y = event.y;
|
|
||||||
return true;
|
|
||||||
} else if (event.isMiddleButton || (event.isLeftButton && event.isControl && event.isShifted)) {
|
} else if (event.isMiddleButton || (event.isLeftButton && event.isControl && event.isShifted)) {
|
||||||
that.mode = MODE_PAN;
|
that.mode = MODE_PAN;
|
||||||
that.lastMousePosition.x = event.x;
|
}
|
||||||
that.lastMousePosition.y = event.y;
|
|
||||||
|
if (that.mode != MODE_INACTIVE) {
|
||||||
|
var newX = Window.x + Window.innerWidth / 2;
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,6 +224,7 @@ CameraManager = function() {
|
||||||
that.mouseReleaseEvent = function(event) {
|
that.mouseReleaseEvent = function(event) {
|
||||||
if (!that.enabled) return;
|
if (!that.enabled) return;
|
||||||
|
|
||||||
|
Window.setCursorVisible(true);
|
||||||
that.mode = MODE_INACTIVE;
|
that.mode = MODE_INACTIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue