mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 06:53:01 +02:00
Add initial support for multi-selection in properties window
This commit is contained in:
parent
c2e559342a
commit
3c5f11e6ed
2 changed files with 52 additions and 14 deletions
|
@ -934,24 +934,37 @@ PropertiesTool = function(opts) {
|
||||||
data = {
|
data = {
|
||||||
type: 'update',
|
type: 'update',
|
||||||
};
|
};
|
||||||
if (selectionManager.hasSelection()) {
|
var selections = [];
|
||||||
data.id = selectionManager.selections[0].id;
|
for (var i = 0; i < selectionManager.selections.length; i++) {
|
||||||
data.properties = Entities.getEntityProperties(selectionManager.selections[0]);
|
var entity = {};
|
||||||
data.properties.rotation = Quat.safeEulerAngles(data.properties.rotation);
|
entity.id = selectionManager.selections[i].id;
|
||||||
|
entity.properties = Entities.getEntityProperties(selectionManager.selections[i]);
|
||||||
|
entity.properties.rotation = Quat.safeEulerAngles(entity.properties.rotation);
|
||||||
|
selections.push(entity);
|
||||||
}
|
}
|
||||||
|
data.selections = selections;
|
||||||
webView.eventBridge.emitScriptEvent(JSON.stringify(data));
|
webView.eventBridge.emitScriptEvent(JSON.stringify(data));
|
||||||
});
|
});
|
||||||
|
|
||||||
webView.eventBridge.webEventReceived.connect(function(data) {
|
webView.eventBridge.webEventReceived.connect(function(data) {
|
||||||
print(data);
|
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
if (data.type == "update") {
|
if (data.type == "update") {
|
||||||
selectionManager.saveProperties();
|
selectionManager.saveProperties();
|
||||||
if (data.properties.rotation !== undefined) {
|
if (selectionManager.selections.length > 1) {
|
||||||
var rotation = data.properties.rotation;
|
properties = {
|
||||||
data.properties.rotation = Quat.fromPitchYawRollDegrees(rotation.x, rotation.y, rotation.z);
|
locked: data.properties.locked,
|
||||||
|
visible: data.properties.visible,
|
||||||
|
};
|
||||||
|
for (var i = 0; i < selectionManager.selections.length; i++) {
|
||||||
|
Entities.editEntity(selectionManager.selections[i], properties);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (data.properties.rotation !== undefined) {
|
||||||
|
var rotation = data.properties.rotation;
|
||||||
|
data.properties.rotation = Quat.fromPitchYawRollDegrees(rotation.x, rotation.y, rotation.z);
|
||||||
|
}
|
||||||
|
Entities.editEntity(selectionManager.selections[0], data.properties);
|
||||||
}
|
}
|
||||||
Entities.editEntity(selectionManager.selections[0], data.properties);
|
|
||||||
pushCommandForSelections();
|
pushCommandForSelections();
|
||||||
selectionManager._update();
|
selectionManager._update();
|
||||||
} else if (data.type == "action") {
|
} else if (data.type == "action") {
|
||||||
|
|
|
@ -171,12 +171,37 @@
|
||||||
EventBridge.scriptEventReceived.connect(function(data) {
|
EventBridge.scriptEventReceived.connect(function(data) {
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
if (data.type == "update") {
|
if (data.type == "update") {
|
||||||
if (data.properties === undefined) {
|
if (data.selections.length == 0) {
|
||||||
disableChildren(document.getElementById("properties"), 'input');
|
elType.innerHTML = "<i>No Selection</i>";
|
||||||
} else {
|
elID.innerHTML = "";
|
||||||
var properties = data.properties;
|
disableChildren(document.getElementById("properties-list"), 'input');
|
||||||
|
} else if (data.selections.length > 1) {
|
||||||
|
var selections = data.selections;
|
||||||
|
|
||||||
elID.innerHTML = data.id;
|
var ids = [];
|
||||||
|
var types = {};
|
||||||
|
|
||||||
|
for (var i = 0; i < selections.length; i++) {
|
||||||
|
ids.push(selections[i].id);
|
||||||
|
var type = selections[i].properties.type;
|
||||||
|
if (types[type] === undefined) {
|
||||||
|
types[type] = 0;
|
||||||
|
}
|
||||||
|
types[type]++;
|
||||||
|
}
|
||||||
|
elID.innerHTML = ids.join("<br>");
|
||||||
|
|
||||||
|
var typeStrs = [];
|
||||||
|
for (type in types) {
|
||||||
|
typeStrs.push(type + " (" + types[type] + ")");
|
||||||
|
}
|
||||||
|
elType.innerHTML = typeStrs.join(", ");
|
||||||
|
|
||||||
|
disableChildren(document.getElementById("properties-list"), 'input');
|
||||||
|
} else {
|
||||||
|
var properties = data.selections[0].properties;
|
||||||
|
|
||||||
|
elID.innerHTML = properties.id;
|
||||||
|
|
||||||
elType.innerHTML = properties.type;
|
elType.innerHTML = properties.type;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue