mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 08:17:35 +02:00
Reorganize selectionManager selection checking
This commit is contained in:
parent
dde9b92dbd
commit
2fab404f7f
1 changed files with 38 additions and 41 deletions
|
@ -1024,51 +1024,48 @@ PropertiesTool = function(opts) {
|
||||||
selectionManager._update();
|
selectionManager._update();
|
||||||
} else if (data.type == "action") {
|
} else if (data.type == "action") {
|
||||||
if (data.action == "moveSelectionToGrid") {
|
if (data.action == "moveSelectionToGrid") {
|
||||||
if (!selectionManager.hasSelection()) {
|
if (selectionManager.hasSelection()) {
|
||||||
return;
|
selectionManager.saveProperties();
|
||||||
}
|
var dY = grid.getOrigin().y - (selectionManager.worldPosition.y - selectionManager.worldDimensions.y / 2),
|
||||||
selectionManager.saveProperties();
|
|
||||||
var dY = grid.getOrigin().y - (selectionManager.worldPosition.y - selectionManager.worldDimensions.y / 2),
|
|
||||||
var diff = { x: 0, y: dY, z: 0 };
|
|
||||||
for (var i = 0; i < selectionManager.selections.length; i++) {
|
|
||||||
var properties = selectionManager.savedProperties[selectionManager.selections[i].id];
|
|
||||||
var newPosition = Vec3.sum(properties.position, diff);
|
|
||||||
Entities.editEntity(selectionManager.selections[i], {
|
|
||||||
position: newPosition,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
pushCommandForSelections();
|
|
||||||
selectionManager._update();
|
|
||||||
} else if (data.action == "moveAllToGrid") {
|
|
||||||
if (!selectionManager.hasSelection()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
selectionManager.saveProperties();
|
|
||||||
for (var i = 0; i < selectionManager.selections.length; i++) {
|
|
||||||
var properties = selectionManager.savedProperties[selectionManager.selections[i].id];
|
|
||||||
var bottomY = properties.boundingBox.center.y - properties.boundingBox.dimensions.y / 2;
|
|
||||||
var dY = grid.getOrigin().y - bottomY;
|
|
||||||
var diff = { x: 0, y: dY, z: 0 };
|
var diff = { x: 0, y: dY, z: 0 };
|
||||||
var newPosition = Vec3.sum(properties.position, diff);
|
for (var i = 0; i < selectionManager.selections.length; i++) {
|
||||||
Entities.editEntity(selectionManager.selections[i], {
|
var properties = selectionManager.savedProperties[selectionManager.selections[i].id];
|
||||||
position: newPosition,
|
var newPosition = Vec3.sum(properties.position, diff);
|
||||||
});
|
Entities.editEntity(selectionManager.selections[i], {
|
||||||
|
position: newPosition,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
pushCommandForSelections();
|
||||||
|
selectionManager._update();
|
||||||
|
}
|
||||||
|
} else if (data.action == "moveAllToGrid") {
|
||||||
|
if (selectionManager.hasSelection()) {
|
||||||
|
selectionManager.saveProperties();
|
||||||
|
for (var i = 0; i < selectionManager.selections.length; i++) {
|
||||||
|
var properties = selectionManager.savedProperties[selectionManager.selections[i].id];
|
||||||
|
var bottomY = properties.boundingBox.center.y - properties.boundingBox.dimensions.y / 2;
|
||||||
|
var dY = grid.getOrigin().y - bottomY;
|
||||||
|
var diff = { x: 0, y: dY, z: 0 };
|
||||||
|
var newPosition = Vec3.sum(properties.position, diff);
|
||||||
|
Entities.editEntity(selectionManager.selections[i], {
|
||||||
|
position: newPosition,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
pushCommandForSelections();
|
||||||
|
selectionManager._update();
|
||||||
}
|
}
|
||||||
pushCommandForSelections();
|
|
||||||
selectionManager._update();
|
|
||||||
} else if (data.action == "resetToNaturalDimensions") {
|
} else if (data.action == "resetToNaturalDimensions") {
|
||||||
if (!selectionManager.hasSelection()) {
|
if (selectionManager.hasSelection()) {
|
||||||
return;
|
selectionManager.saveProperties();
|
||||||
|
for (var i = 0; i < selectionManager.selections.length; i++) {
|
||||||
|
var properties = selectionManager.savedProperties[selectionManager.selections[i].id];
|
||||||
|
Entities.editEntity(selectionManager.selections[i], {
|
||||||
|
dimensions: properties.naturalDimensions,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
pushCommandForSelections();
|
||||||
|
selectionManager._update();
|
||||||
}
|
}
|
||||||
selectionManager.saveProperties();
|
|
||||||
for (var i = 0; i < selectionManager.selections.length; i++) {
|
|
||||||
var properties = selectionManager.savedProperties[selectionManager.selections[i].id];
|
|
||||||
Entities.editEntity(selectionManager.selections[i], {
|
|
||||||
dimensions: properties.naturalDimensions,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
pushCommandForSelections();
|
|
||||||
selectionManager._update();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue