diff --git a/js/lattice/CompositeEditorLattice.js b/js/lattice/CompositeEditorLattice.js index 71262137ca25e1ce7aa814b2beb32f0580e9b7be..732517ae302f6427f11f19b173b3dfe46a02ca4d 100644 --- a/js/lattice/CompositeEditorLattice.js +++ b/js/lattice/CompositeEditorLattice.js @@ -7,6 +7,7 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th function(_, Backbone, appState, lattice, globals, plist, THREE, three){ var defaults = { + compositeId: null, compositeColor: makeRandomColor(), numCompositeCells:0, compositeCellsMin: null, @@ -21,21 +22,39 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th - _initCompositeEditor: function(){ + _initCompositeEditor: function(id, data){ var self = this; _.each(_.keys(defaults), function(key){ self.set(key, defaults[key], {silent:true}); }); - this.compositeCells = [[[null]]]; + if (data){ + _.each(_.keys(data), function(key){ + self.set(key, defaults[key], {silent:true}); + }); + this.compositeCells = data.cells;//todo + this.set("compositeId", id, {silent:true}); + } }, _changeRandomColor: function(){ this.set("compositeColor", makeRandomColor()); }, + _makeNewCompositeMaterial: function(name){ + var id = this.get("compositeId"); + var data = { + name: name, + color: this.get("compositeColor"), + altColor: this.get("compositeColor"), + numCells: this.get("numCompositeCells"), + dimensions: new THREE.Vector3.subVectors(this.get("compositeCellsMax"), this.get("compositeCellsMin")) + }; + globals.materials.id = data;//todo trigger change on all instances + }, + _undoCompositeEditor: function(){ console.log("undo"); var self = this;