Skip to content
Snippets Groups Projects
Commit 496e063b authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

eod

parent fc3adf4a
No related branches found
No related tags found
No related merge requests found
......@@ -6,24 +6,25 @@
define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'three', 'threeModel'],
function(_, Backbone, appState, lattice, globals, plist, THREE, three){
var defaults = {
compositeId: null,
compositeColor: makeRandomColor(),
numCompositeCells:0,
compositeCellsMin: null,
compositeCellsMax: null
};
function makeRandomColor(){
return '#' + Math.floor(Math.random()*16777215).toString(16);
}
var CompositeEditorLattice = {
var defaults = {};
var compositeId = 0;
var CompositeEditorLattice = {
_initCompositeEditor: function(id, data){
_.extend(defaults, {
compositeId: "composite" + compositeId++,//todo real unique id
compositeColor: makeRandomColor(),
numCompositeCells:0,
compositeCellsMin: null,
compositeCellsMax: null
});
var self = this;
_.each(_.keys(defaults), function(key){
self.set(key, defaults[key], {silent:true});
......@@ -34,7 +35,7 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th
_.each(_.keys(data), function(key){
self.set(key, defaults[key], {silent:true});
});
this.compositeCells = data.cells;//todo
this.compositeCells = data.cells;//todo parse cells
this.set("compositeId", id, {silent:true});
}
},
......@@ -43,13 +44,20 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th
this.set("compositeColor", makeRandomColor());
},
_makeNewCompositeMaterial: function(name){
makeNewCompositeMaterial: function(name){
if (this.get("numCompositeCells") == 0) {
console.warn("no cells in this composite");
return;
}
var id = this.get("compositeId");
var data = {
name: name,
color: this.get("compositeColor"),
altColor: this.get("compositeColor"),
numCells: this.get("numCompositeCells"),
cells: JSON.stringify(this.get("compositeCells")),
cellsMin: this.get("compositeCellsMin").clone(),
cellsMax: this.get("compositeCellsMax").clone(),
dimensions: new THREE.Vector3.subVectors(this.get("compositeCellsMax"), this.get("compositeCellsMin"))
};
globals.materials.id = data;//todo trigger change on all instances
......@@ -65,6 +73,7 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th
self.unset(key, {silent:true});
});
this.compositeCells = null;
console.log("done undo");
}
};
......
......@@ -31,6 +31,8 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _
_finishComposite: function(e){
e.preventDefault();
console.log("here");
lattice.makeNewCompositeMaterial();
this.model.set("currentNav", "navDesign");
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment