add two-way code but dont enable

This commit is contained in:
James B. Pollack 2015-09-26 14:10:30 -07:00
parent 5013e98b6c
commit 7a59a7dc43
2 changed files with 43 additions and 24 deletions

View file

@ -84,10 +84,11 @@ var ParticleExplorer = function() {
//we need a way to keep track of our gui controllers
var controllers = [];
var particleExplorer;
window.onload = function() {
//instantiate our object
var particleExplorer = new ParticleExplorer();
particleExplorer = new ParticleExplorer();
//whether or not to autoplace
var gui = new dat.GUI({
@ -113,6 +114,8 @@ window.onload = function() {
_.each(particleKeys, function(key) {
//add this key as a controller to the gui
var controller = gui.add(particleExplorer, key);
// the call below is potentially expensive but will enable two way binding. needs testing to see how many it supports at once.
//var controller = gui.add(particleExplorer, key).listen();
var putInGroup = false;
_.each(groups, function(group) {
@ -181,3 +184,15 @@ function writeDataToInterface(property, value, shouldGroup) {
}
}
function listenForSettingsUpdates() {
if (typeof EventBridge !== 'undefined') {
EventBridge.scriptEventReceived.connect(function(data) {
data = JSON.parse(data);
if (data.type === 'particleSettingsUpdate') {
var particleSettings = data.particleSettings
//parse the settings and change particle explorer, add .listen() to controllers
}
});
}
}

View file

@ -145,6 +145,9 @@ SettingsWindow = function() {
_this.webWindow.eventBridge.webEventReceived.connect(_this.onWebEventReceived);
print('INIT testParticles' + testParticles)
};
this.sendData = function(data) {
_this.webWindow.eventBridge.emitScriptEvent(JSON.stringify(data));
};
this.onWebEventReceived = function(data) {
// print('DATA ' + data)
var _data = JSON.parse(data)
@ -171,6 +174,7 @@ function editEntity(properties) {
Entities.editEntity(testParticles, properties);
var currentProperties = Entities.getEntityProperties(testParticles)
// print('CURRENT PROPS', JSON.stringify(currentProperties))
SettingsWindow.sendData({type:'particleSettingsUpdate',particleSettings:currentProperties})
}