switching between particle entities

This commit is contained in:
ericrius1 2016-02-15 12:52:05 -08:00
parent 85d8fc2944
commit f98941e80f
3 changed files with 11 additions and 5 deletions

View file

@ -1881,12 +1881,17 @@ var showMenuItem = propertyMenu.addMenuItem("Show in Marketplace");
propertiesTool = PropertiesTool();
var particleExplorerTool = ParticleExplorerTool();
var selectedParticleEntity = 0;
entityListTool.webView.eventBridge.webEventReceived.connect(function(data) {
var data = JSON.parse(data);
if (data.type == "selectionUpdate") {
var ids = data.entityIds;
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])) {
// We already had a particle entity selected, so destroy that one and create the new one
particleExplorerTool.destroyWebView();
}
// Now we want to activate the partice explorer panel!
particleExplorerTool.createWebView();
var properties = Entities.getEntityProperties(ids[0]);
@ -1898,7 +1903,7 @@ entityListTool.webView.eventBridge.webEventReceived.connect(function(data) {
Script.setTimeout(function() {
// Wait for event bridge on web side to open
particleExplorerTool.webView.eventBridge.emitScriptEvent(JSON.stringify(data));
}, 3000)
}, 2000)
} else {
particleExplorerTool.destroyWebView();

View file

@ -338,9 +338,7 @@ function writeVec3ToInterface(obj) {
}
function listenForSettingsUpdates() {
console.log("EBL LISTENING FOR EVENTS ON PARTICLE GUI WEB SIDE!")
EventBridge.scriptEventReceived.connect(function(data) {
console.log("EBL RECIEVED EVENT!! ON WEB SIDE - " + JSON.stringify(data));
data = JSON.parse(data);
if (data.messageType === 'particle_settings') {
_.each(data.currentProperties, function(value, key) {

View file

@ -2,7 +2,7 @@
// particleExplorerTool.js
//
// Created by Eric Levin on 2/15/16
// Copyright 2015 High Fidelity, Inc.
// Copyright 2016 High Fidelity, Inc.
// Adds particleExplorer tool to the edit panel when a user selects a particle entity from the edit tool window
// This is an example of a new, easy way to do two way bindings between dynamically created GUI and in-world entities.
//
@ -31,6 +31,9 @@ ParticleExplorerTool = function() {
that.destroyWebView = function() {
if (!that.webView) {
return;
}
that.webView.close();
that.webView = null;
}