mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 22:51:20 +02:00
Snap to Next Clicked Surface
This adds the move in addition to the rotation to the "Rotate as Next Clicked Surface" action. Which is now become: "Snap to Next Clicked Surface"
This commit is contained in:
parent
5b40ac4c1e
commit
aedce21007
2 changed files with 40 additions and 2 deletions
|
@ -1115,7 +1115,16 @@ function findClickedEntity(event) {
|
||||||
expectingRotateAsClickedSurface = false;
|
expectingRotateAsClickedSurface = false;
|
||||||
} else {
|
} else {
|
||||||
//Rotate Selection according the Surface Normal
|
//Rotate Selection according the Surface Normal
|
||||||
selectionDisplay.rotateSelection(Quat.lookAt(Vec3.ZERO, Vec3.multiply(entityResult.surfaceNormal, -1), Vec3.UP));
|
var normalRotation = Quat.lookAtSimple(Vec3.ZERO, Vec3.multiply(entityResult.surfaceNormal, -1));
|
||||||
|
selectionDisplay.rotateSelection(normalRotation);
|
||||||
|
//Translate Selection according the clicked Surface
|
||||||
|
var distanceFromSurface;
|
||||||
|
if (selectionDisplay.getSpaceMode() === "world"){
|
||||||
|
distanceFromSurface = SelectionManager.worldDimensions.z / 2;
|
||||||
|
} else {
|
||||||
|
distanceFromSurface = SelectionManager.localDimensions.z / 2;
|
||||||
|
}
|
||||||
|
selectionDisplay.moveSelection(Vec3.sum(entityResult.intersection, Vec3.multiplyQbyV( normalRotation, {"x": 0.0, "y":0.0, "z": distanceFromSurface})));
|
||||||
selectionManager._update(false, this);
|
selectionManager._update(false, this);
|
||||||
pushCommandForSelections();
|
pushCommandForSelections();
|
||||||
expectingRotateAsClickedSurface = false;
|
expectingRotateAsClickedSurface = false;
|
||||||
|
|
|
@ -110,7 +110,16 @@ SelectionManager = (function() {
|
||||||
expectingRotateAsClickedSurface = false;
|
expectingRotateAsClickedSurface = false;
|
||||||
} else {
|
} else {
|
||||||
//Rotate Selection according the Surface Normal
|
//Rotate Selection according the Surface Normal
|
||||||
selectionDisplay.rotateSelection(Quat.lookAt(Vec3.ZERO, Vec3.multiply(messageParsed.surfaceNormal, -1), Vec3.UP));
|
var normalRotation = Quat.lookAtSimple(Vec3.ZERO, Vec3.multiply(messageParsed.surfaceNormal, -1));
|
||||||
|
selectionDisplay.rotateSelection(normalRotation);
|
||||||
|
//Translate Selection according the clicked Surface
|
||||||
|
var distanceFromSurface;
|
||||||
|
if (selectionDisplay.getSpaceMode() === SPACE_WORLD){
|
||||||
|
distanceFromSurface = SelectionManager.worldDimensions.z / 2;
|
||||||
|
} else {
|
||||||
|
distanceFromSurface = SelectionManager.localDimensions.z / 2;
|
||||||
|
}
|
||||||
|
selectionDisplay.moveSelection(Vec3.sum(messageParsed.intersection, Vec3.multiplyQbyV( normalRotation, {"x": 0.0, "y":0.0, "z": distanceFromSurface})));
|
||||||
that._update(false, this);
|
that._update(false, this);
|
||||||
pushCommandForSelections();
|
pushCommandForSelections();
|
||||||
expectingRotateAsClickedSurface = false;
|
expectingRotateAsClickedSurface = false;
|
||||||
|
@ -2401,6 +2410,26 @@ SelectionDisplay = (function() {
|
||||||
updateSelectionsRotation(rotation, SelectionManager.worldPosition);
|
updateSelectionsRotation(rotation, SelectionManager.worldPosition);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
that.moveSelection = function(targetPosition) {
|
||||||
|
SelectionManager.saveProperties();
|
||||||
|
// editing a parent will cause all the children to automatically follow along, so don't
|
||||||
|
// edit any entity who has an ancestor in SelectionManager.selections
|
||||||
|
var toMove = SelectionManager.selections.filter(function (selection) {
|
||||||
|
if (SelectionManager.selections.indexOf(SelectionManager.savedProperties[selection].parentID) >= 0) {
|
||||||
|
return false; // a parent is also being moved, so don't issue an edit for this entity
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for (var i = 0; i < toMove.length; i++) {
|
||||||
|
var id = toMove[i];
|
||||||
|
var properties = SelectionManager.savedProperties[id];
|
||||||
|
var newPosition = Vec3.sum(targetPosition, Vec3.subtract(properties.position, SelectionManager.worldPosition));
|
||||||
|
Entities.editEntity(id, { position: newPosition });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
that.rotate90degreeSelection = function(axis) {
|
that.rotate90degreeSelection = function(axis) {
|
||||||
//axis is a string and expect "X", "Y" or "Z"
|
//axis is a string and expect "X", "Y" or "Z"
|
||||||
if (!SelectionManager.hasSelection() || !SelectionManager.hasUnlockedSelection()) {
|
if (!SelectionManager.hasSelection() || !SelectionManager.hasUnlockedSelection()) {
|
||||||
|
|
Loading…
Reference in a new issue