From 804f82f2f173bf1415979e22c1905087f4d68bfc Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Thu, 28 Jan 2016 15:57:35 -0800 Subject: [PATCH] good progress- can create particle entity from menu --- examples/edit.js | 41 +++++++++---- examples/libraries/entityList.js | 18 ++++++ examples/particle_explorer/main.js | 16 ++--- .../particle_explorer/particleExplorer.html | 60 +++++++++++++++++++ .../particle_explorer/particleExplorerTool.js | 20 +++++++ 5 files changed, 130 insertions(+), 25 deletions(-) create mode 100644 examples/particle_explorer/particleExplorer.html create mode 100644 examples/particle_explorer/particleExplorerTool.js diff --git a/examples/edit.js b/examples/edit.js index b68468c049..7ee56ba1d0 100644 --- a/examples/edit.js +++ b/examples/edit.js @@ -27,6 +27,7 @@ Script.include([ "libraries/entityCameraTool.js", "libraries/gridTool.js", "libraries/entityList.js", + "particle_explorer/particleExplorerTool.js", "libraries/lightOverlayManager.js", ]); @@ -141,9 +142,9 @@ var importingSVOTextOverlay = Overlays.addOverlay("text", { var MARKETPLACE_URL = "https://metaverse.highfidelity.com/marketplace"; var marketplaceWindow = new OverlayWebWindow({ - title: 'Marketplace', - source: "about:blank", - width: 900, + title: 'Marketplace', + source: "about:blank", + width: 900, height: 700, visible: false }); @@ -194,7 +195,7 @@ var toolBar = (function() { }; }); - + activeButton = toolBar.addTool({ imageURL: toolIconUrl + "edit-status.svg", @@ -450,8 +451,8 @@ var toolBar = (function() { newModelButtonDown = true; return true; } - - + + if (newCubeButton === toolBar.clicked(clickedOverlay)) { createNewEntity({ type: "Box", @@ -640,8 +641,13 @@ var toolBar = (function() { } if (newParticleButton === toolBar.clicked(clickedOverlay)) { - print("EBL: NEW PARTICLES"); - Script.load('particle_explorer/particleExplorer.js'); + createNewEntity({ + type: "ParticleEffect", + isEmitting: true, + particleRadius: 0.1, + emitRate: 100, + textures: "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png", + }); } return false; @@ -664,7 +670,7 @@ var toolBar = (function() { } newModelButtonDown = false; - + return handled; } @@ -1524,8 +1530,8 @@ PropertiesTool = function(opts) { var url = Script.resolvePath('html/entityProperties.html'); var webView = new OverlayWebWindow({ - title: 'Entity Properties', - source: url, + title: 'Entity Properties', + source: url, toolWindow: true }); @@ -1579,8 +1585,16 @@ PropertiesTool = function(opts) { } else { if (data.properties.dynamic === false) { // this object is leaving dynamic, so we zero its velocities - data.properties["velocity"] = {x: 0, y: 0, z: 0}; - data.properties["angularVelocity"] = {x: 0, y: 0, z: 0}; + data.properties["velocity"] = { + x: 0, + y: 0, + z: 0 + }; + data.properties["angularVelocity"] = { + x: 0, + y: 0, + z: 0 + }; } if (data.properties.rotation !== undefined) { var rotation = data.properties.rotation; @@ -1863,3 +1877,4 @@ propertyMenu.onSelectMenuItem = function(name) { var showMenuItem = propertyMenu.addMenuItem("Show in Marketplace"); propertiesTool = PropertiesTool(); +var particleExplorerTool = ParticleExplorerTool(); \ No newline at end of file diff --git a/examples/libraries/entityList.js b/examples/libraries/entityList.js index b37ba58737..aeb8226061 100644 --- a/examples/libraries/entityList.js +++ b/examples/libraries/entityList.js @@ -71,13 +71,31 @@ EntityListTool = function(opts) { webView.eventBridge.emitScriptEvent(JSON.stringify(data)); } + that.enableParticleTab = function(entityID) { + var data = { + type: "enableParticleTab", + entity: entityID + }; + webView.eventBridge.emitScriptEvent(JSON.stringify(data)); + } + webView.eventBridge.webEventReceived.connect(function(data) { data = JSON.parse(data); if (data.type == "selectionUpdate") { + print("EBL CLICKED ON SOME SHIT " + JSON.stringify(data)) var ids = data.entityIds; var entityIDs = []; for (var i = 0; i < ids.length; i++) { entityIDs.push(ids[i]); + } + if (entityIDs.length === 1) { + //We selected just one entity, so see if that entity is a particle entity + var type = Entities.getEntityProperties(entityIDs[0], "type").type; + if (type === "ParticleEffect") { + that.enableParticleTab(entityIDs[0]); + } + + } selectionManager.setSelections(entityIDs); if (data.focus) { diff --git a/examples/particle_explorer/main.js b/examples/particle_explorer/main.js index 69df67e72e..c76eef42af 100644 --- a/examples/particle_explorer/main.js +++ b/examples/particle_explorer/main.js @@ -82,7 +82,6 @@ window.onload = function() { listenForSettingsUpdates(); window.onresize = setGUIWidthToWindowWidth; - console.log('JBP HAS EVENT BRIDGE'); }) }; @@ -128,9 +127,6 @@ function loadGUI() { individualKeys.push(key); } } - - - }); //alphabetize our keys @@ -345,14 +341,6 @@ function writeVec3ToInterface(obj) { function listenForSettingsUpdates() { EventBridge.scriptEventReceived.connect(function(data) { data = JSON.parse(data); - - //2-way - // if (data.messageType === 'object_update') { - // _.each(data.objectSettings, function(value, key) { - // settings[key] = value; - // }); - // } - if (data.messageType === 'initial_settings') { _.each(data.initialSettings, function(value, key) { settings[key] = {}; @@ -361,6 +349,10 @@ function listenForSettingsUpdates() { loadGUI(); } + + if (date.type === "enableParticleTab") { + console.log("EBL JUST GOT AN ENABLE MESSAGE!"); + } }); } diff --git a/examples/particle_explorer/particleExplorer.html b/examples/particle_explorer/particleExplorer.html new file mode 100644 index 0000000000..b50d100934 --- /dev/null +++ b/examples/particle_explorer/particleExplorer.html @@ -0,0 +1,60 @@ + + + + + + + + + + + + +
+ +
+
+
+ + + \ No newline at end of file diff --git a/examples/particle_explorer/particleExplorerTool.js b/examples/particle_explorer/particleExplorerTool.js new file mode 100644 index 0000000000..9e8d519466 --- /dev/null +++ b/examples/particle_explorer/particleExplorerTool.js @@ -0,0 +1,20 @@ +var PARTICLE_EXPLORER_HTML_URL = Script.resolvePath('particleExplorer.html'); + +ParticleExplorerTool = function() { + var that = {}; + + var url = PARTICLE_EXPLORER_HTML_URL; + var webView = new OverlayWebWindow({ + title: 'Particle Explorer', source: url, toolWindow: true + }); + + var visible = false; + webView.setVisible(visible); + + that.setVisible = function(newVisible) { + visible = newVisible; + webView.setVisible(visible); + } + + +};