3
0
Fork 0
mirror of https://github.com/lubosz/overte.git synced 2025-04-12 09:42:28 +02:00

Merge pull request from dback2/alignSelectionToGridFix

Fix aligning selection to grid
This commit is contained in:
David Back 2018-07-13 13:33:26 -07:00 committed by GitHub
commit c225c3deca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 10 deletions
scripts/system

View file

@ -1853,13 +1853,7 @@ var keyReleaseEvent = function (event) {
}
} else if (event.text === 'g') {
if (isActive && selectionManager.hasSelection()) {
var newPosition = selectionManager.worldPosition;
newPosition = Vec3.subtract(newPosition, {
x: 0,
y: selectionManager.worldDimensions.y * 0.5,
z: 0
});
grid.setPosition(newPosition);
grid.moveToSelection();
}
} else if (event.key === KEY_P && event.isControl && !event.isAutoRepeat ) {
if (event.isShifted) {

View file

@ -154,6 +154,12 @@ Grid = function(opts) {
that.emitUpdate();
}
};
that.moveToSelection = function() {
var newPosition = SelectionManager.worldPosition;
newPosition = Vec3.subtract(newPosition, { x: 0, y: SelectionManager.worldDimensions.y * 0.5, z: 0 });
that.setPosition(newPosition);
};
that.emitUpdate = function() {
if (that.onUpdate) {
@ -280,9 +286,7 @@ GridTool = function(opts) {
}
horizontalGrid.setPosition(position);
} else if (action == "moveToSelection") {
var newPosition = selectionManager.worldPosition;
newPosition = Vec3.subtract(newPosition, { x: 0, y: selectionManager.worldDimensions.y * 0.5, z: 0 });
grid.setPosition(newPosition);
horizontalGrid.moveToSelection();
}
}
};