mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #13255 from ctrlaltdavid/21884
Fix properties not populating particle explorer tab
This commit is contained in:
commit
389bddb0f4
2 changed files with 36 additions and 16 deletions
|
@ -2362,26 +2362,21 @@ var showMenuItem = propertyMenu.addMenuItem("Show in Marketplace");
|
|||
|
||||
var propertiesTool = new PropertiesTool();
|
||||
var particleExplorerTool = new ParticleExplorerTool();
|
||||
var selectedParticleEntity = 0;
|
||||
var selectedParticleEntityID = null;
|
||||
|
||||
function selectParticleEntity(entityID) {
|
||||
var properties = Entities.getEntityProperties(entityID);
|
||||
selectedParticleEntityID = entityID;
|
||||
|
||||
var properties = Entities.getEntityProperties(entityID);
|
||||
if (properties.emitOrientation) {
|
||||
properties.emitOrientation = Quat.safeEulerAngles(properties.emitOrientation);
|
||||
}
|
||||
var particleData = {
|
||||
messageType: "particle_settings",
|
||||
currentProperties: properties
|
||||
};
|
||||
|
||||
particleExplorerTool.destroyWebView();
|
||||
particleExplorerTool.createWebView();
|
||||
|
||||
selectedParticleEntity = entityID;
|
||||
particleExplorerTool.setActiveParticleEntity(entityID);
|
||||
|
||||
particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData));
|
||||
particleExplorerTool.setActiveParticleProperties(properties);
|
||||
|
||||
// Switch to particle explorer
|
||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
|
@ -2404,13 +2399,13 @@ entityListTool.webView.webEventReceived.connect(function (data) {
|
|||
var ids = data.entityIds;
|
||||
if (ids.length === 1) {
|
||||
if (Entities.getEntityProperties(ids[0], "type").type === "ParticleEffect") {
|
||||
if (JSON.stringify(selectedParticleEntity) === JSON.stringify(ids[0])) {
|
||||
if (JSON.stringify(selectedParticleEntityID) === JSON.stringify(ids[0])) {
|
||||
// This particle entity is already selected, so return
|
||||
return;
|
||||
}
|
||||
// Destroy the old particles web view first
|
||||
} else {
|
||||
selectedParticleEntity = 0;
|
||||
selectedParticleEntityID = 0;
|
||||
particleExplorerTool.destroyWebView();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,37 +16,62 @@ var PARTICLE_EXPLORER_HTML_URL = Script.resolvePath('particleExplorer.html');
|
|||
|
||||
ParticleExplorerTool = function() {
|
||||
var that = {};
|
||||
that.activeParticleEntity = 0;
|
||||
that.activeParticleProperties = {};
|
||||
|
||||
that.createWebView = function() {
|
||||
that.webView = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
that.webView.setVisible = function(value) {};
|
||||
that.webView.webEventReceived.connect(that.webEventReceived);
|
||||
}
|
||||
};
|
||||
|
||||
that.destroyWebView = function() {
|
||||
if (!that.webView) {
|
||||
return;
|
||||
}
|
||||
that.activeParticleEntity = 0;
|
||||
that.activeParticleProperties = {};
|
||||
|
||||
var messageData = {
|
||||
messageType: "particle_close"
|
||||
};
|
||||
that.webView.emitScriptEvent(JSON.stringify(messageData));
|
||||
};
|
||||
|
||||
function sendActiveParticleProperties() {
|
||||
that.webView.emitScriptEvent(JSON.stringify({
|
||||
messageType: "particle_settings",
|
||||
currentProperties: that.activeParticleProperties
|
||||
}));
|
||||
}
|
||||
|
||||
that.webEventReceived = function(data) {
|
||||
var data = JSON.parse(data);
|
||||
that.webEventReceived = function(message) {
|
||||
var data = JSON.parse(message);
|
||||
if (data.messageType === "settings_update") {
|
||||
if (data.updatedSettings.emitOrientation) {
|
||||
data.updatedSettings.emitOrientation = Quat.fromVec3Degrees(data.updatedSettings.emitOrientation);
|
||||
}
|
||||
Entities.editEntity(that.activeParticleEntity, data.updatedSettings);
|
||||
|
||||
for (var key in data.updatedSettings) {
|
||||
if (that.activeParticleProperties.hasOwnProperty(key)) {
|
||||
that.activeParticleProperties[key] = data.updatedSettings[key];
|
||||
}
|
||||
}
|
||||
|
||||
} else if (data.messageType === "page_loaded") {
|
||||
sendActiveParticleProperties();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
that.setActiveParticleEntity = function(id) {
|
||||
that.activeParticleEntity = id;
|
||||
}
|
||||
};
|
||||
|
||||
that.setActiveParticleProperties = function(properties) {
|
||||
that.activeParticleProperties = properties;
|
||||
sendActiveParticleProperties();
|
||||
};
|
||||
|
||||
return that;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue