Merge pull request #13255 from ctrlaltdavid/21884

Fix properties not populating particle explorer tab
This commit is contained in:
John Conklin II 2018-06-07 09:42:45 -07:00 committed by GitHub
commit 389bddb0f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 16 deletions

View file

@ -2362,26 +2362,21 @@ var showMenuItem = propertyMenu.addMenuItem("Show in Marketplace");
var propertiesTool = new PropertiesTool(); var propertiesTool = new PropertiesTool();
var particleExplorerTool = new ParticleExplorerTool(); var particleExplorerTool = new ParticleExplorerTool();
var selectedParticleEntity = 0;
var selectedParticleEntityID = null; var selectedParticleEntityID = null;
function selectParticleEntity(entityID) { function selectParticleEntity(entityID) {
var properties = Entities.getEntityProperties(entityID);
selectedParticleEntityID = entityID; selectedParticleEntityID = entityID;
var properties = Entities.getEntityProperties(entityID);
if (properties.emitOrientation) { if (properties.emitOrientation) {
properties.emitOrientation = Quat.safeEulerAngles(properties.emitOrientation); properties.emitOrientation = Quat.safeEulerAngles(properties.emitOrientation);
} }
var particleData = {
messageType: "particle_settings",
currentProperties: properties
};
particleExplorerTool.destroyWebView(); particleExplorerTool.destroyWebView();
particleExplorerTool.createWebView(); particleExplorerTool.createWebView();
selectedParticleEntity = entityID;
particleExplorerTool.setActiveParticleEntity(entityID); particleExplorerTool.setActiveParticleEntity(entityID);
particleExplorerTool.setActiveParticleProperties(properties);
particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData));
// Switch to particle explorer // Switch to particle explorer
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
@ -2404,13 +2399,13 @@ entityListTool.webView.webEventReceived.connect(function (data) {
var ids = data.entityIds; var ids = data.entityIds;
if (ids.length === 1) { if (ids.length === 1) {
if (Entities.getEntityProperties(ids[0], "type").type === "ParticleEffect") { 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 // This particle entity is already selected, so return
return; return;
} }
// Destroy the old particles web view first // Destroy the old particles web view first
} else { } else {
selectedParticleEntity = 0; selectedParticleEntityID = 0;
particleExplorerTool.destroyWebView(); particleExplorerTool.destroyWebView();
} }
} }

View file

@ -16,37 +16,62 @@ var PARTICLE_EXPLORER_HTML_URL = Script.resolvePath('particleExplorer.html');
ParticleExplorerTool = function() { ParticleExplorerTool = function() {
var that = {}; var that = {};
that.activeParticleEntity = 0;
that.activeParticleProperties = {};
that.createWebView = function() { that.createWebView = function() {
that.webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); that.webView = Tablet.getTablet("com.highfidelity.interface.tablet.system");
that.webView.setVisible = function(value) {}; that.webView.setVisible = function(value) {};
that.webView.webEventReceived.connect(that.webEventReceived); that.webView.webEventReceived.connect(that.webEventReceived);
} };
that.destroyWebView = function() { that.destroyWebView = function() {
if (!that.webView) { if (!that.webView) {
return; return;
} }
that.activeParticleEntity = 0; that.activeParticleEntity = 0;
that.activeParticleProperties = {};
var messageData = { var messageData = {
messageType: "particle_close" messageType: "particle_close"
}; };
that.webView.emitScriptEvent(JSON.stringify(messageData)); that.webView.emitScriptEvent(JSON.stringify(messageData));
};
function sendActiveParticleProperties() {
that.webView.emitScriptEvent(JSON.stringify({
messageType: "particle_settings",
currentProperties: that.activeParticleProperties
}));
} }
that.webEventReceived = function(data) { that.webEventReceived = function(message) {
var data = JSON.parse(data); var data = JSON.parse(message);
if (data.messageType === "settings_update") { if (data.messageType === "settings_update") {
if (data.updatedSettings.emitOrientation) { if (data.updatedSettings.emitOrientation) {
data.updatedSettings.emitOrientation = Quat.fromVec3Degrees(data.updatedSettings.emitOrientation); data.updatedSettings.emitOrientation = Quat.fromVec3Degrees(data.updatedSettings.emitOrientation);
} }
Entities.editEntity(that.activeParticleEntity, data.updatedSettings); 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.setActiveParticleEntity = function(id) {
that.activeParticleEntity = id; that.activeParticleEntity = id;
} };
that.setActiveParticleProperties = function(properties) {
that.activeParticleProperties = properties;
sendActiveParticleProperties();
};
return that; return that;
}; };