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

add new composite materials to list

parent 496e063b
Branches
No related tags found
No related merge requests found
...@@ -20,9 +20,9 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th ...@@ -20,9 +20,9 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th
_.extend(defaults, { _.extend(defaults, {
compositeId: "composite"+compositeId++,//todo real unique id compositeId: "composite"+compositeId++,//todo real unique id
compositeColor: makeRandomColor(), compositeColor: makeRandomColor(),
numCompositeCells:0, numCompositeCells:2,
compositeCellsMin: null, compositeCellsMin: new THREE.Vector3(0,0,0),//null,
compositeCellsMax: null compositeCellsMax: new THREE.Vector3(2,4,5)//null
}); });
var self = this; var self = this;
...@@ -55,16 +55,16 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th ...@@ -55,16 +55,16 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th
color: this.get("compositeColor"), color: this.get("compositeColor"),
altColor: this.get("compositeColor"), altColor: this.get("compositeColor"),
numCells: this.get("numCompositeCells"), numCells: this.get("numCompositeCells"),
cells: JSON.stringify(this.get("compositeCells")), cells: JSON.parse(JSON.stringify(this.compositeCells)),
cellsMin: this.get("compositeCellsMin").clone(), cellsMin: this.get("compositeCellsMin").clone(),
cellsMax: this.get("compositeCellsMax").clone(), cellsMax: this.get("compositeCellsMax").clone(),
dimensions: new THREE.Vector3.subVectors(this.get("compositeCellsMax"), this.get("compositeCellsMin")) dimensions: new THREE.Vector3().subVectors(this.get("compositeCellsMax"), this.get("compositeCellsMin"))
}; };
globals.materials.id = data;//todo trigger change on all instances globals.materials.compositeMaterials[id] = data;//todo trigger change on all instances
console.log(data);
}, },
_undoCompositeEditor: function(){ _undoCompositeEditor: function(){
console.log("undo");
var self = this; var self = this;
_.each(_.keys(CompositeEditorLattice), function(key){ _.each(_.keys(CompositeEditorLattice), function(key){
self[key] = null; self[key] = null;
...@@ -73,7 +73,6 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th ...@@ -73,7 +73,6 @@ define(['underscore', 'backbone', 'appState', 'lattice', 'globals', 'plist', 'th
self.unset(key, {silent:true}); self.unset(key, {silent:true});
}); });
this.compositeCells = null; this.compositeCells = null;
console.log("done undo");
} }
}; };
......
...@@ -31,8 +31,8 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _ ...@@ -31,8 +31,8 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _
_finishComposite: function(e){ _finishComposite: function(e){
e.preventDefault(); e.preventDefault();
console.log("here"); this.stopListening();
lattice.makeNewCompositeMaterial(); lattice.makeNewCompositeMaterial($("#compositeName").val());
this.model.set("currentNav", "navDesign"); this.model.set("currentNav", "navDesign");
}, },
...@@ -53,7 +53,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _ ...@@ -53,7 +53,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _
template: _.template('\ template: _.template('\
<a href="#" class="btn btn-halfWidth btn-lg btn-default importJSON">Load Composite</a>\ <a href="#" class="btn btn-halfWidth btn-lg btn-default importJSON">Load Composite</a>\
<a id="saveComposite" href="#" class="btn btn-halfWidth btn-lg pull-right btn-default">Save Composite</a><br/><br/>\ <a id="saveComposite" href="#" class="btn btn-halfWidth btn-lg pull-right btn-default">Save Composite</a><br/><br/>\
Name: &nbsp;&nbsp;<input value="" placeholder="Enter Name" class="halfWidth form-control" type="text"><br/><br/>\ Name: &nbsp;&nbsp;<input id="compositeName" value="" placeholder="Enter Name" class="halfWidth form-control" type="text"><br/><br/>\
Bounding Box: ()<br/><br/>\ Bounding Box: ()<br/><br/>\
Display Color: &nbsp;&nbsp;\ Display Color: &nbsp;&nbsp;\
<input style="border-color: <%= compositeColor %> ;" value="<%= compositeColor %>" placeholder="Enter HEX" class="halfWidth form-control" type="text"><br/><br/>\ <input style="border-color: <%= compositeColor %> ;" value="<%= compositeColor %>" placeholder="Enter HEX" class="halfWidth form-control" type="text"><br/><br/>\
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Created by aghassaei on 2/25/15. * Created by aghassaei on 2/25/15.
*/ */
define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _, MenuParentView, plist, lattice){ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice', 'globals'], function($, _, MenuParentView, plist, lattice, globals){
return MenuParentView.extend({ return MenuParentView.extend({
...@@ -26,7 +26,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _ ...@@ -26,7 +26,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _
}, },
_makeTemplateJSON: function(){ _makeTemplateJSON: function(){
return _.extend(lattice.toJSON(), this.model.toJSON(), plist); return _.extend(lattice.toJSON(), this.model.toJSON(), plist, globals);
}, },
template: _.template('\ template: _.template('\
...@@ -56,7 +56,15 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _ ...@@ -56,7 +56,15 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice'], function($, _
Use realistic color scheme</label>\ Use realistic color scheme</label>\
<% } %>\ <% } %>\
<br/><br/>\ <br/><br/>\
Composite Materials:<br/><br/>\ Composite Materials:<br/>\
<% _.each(_.keys(materials.compositeMaterials), function(key){ %>\
<label class="radio colorSwatches">\
<input type="radio" <%if (key == materialType){ %>checked<%}%> name="materialType" value="<%= key %>" data-toggle="radio" class="custom-radio lattice"><span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>\
<div class="materialColorSwatch">\
<div style="background-color:<% if(realisticColorScheme){ %><%= materials.compositeMaterials[key].color %><% }else{ %><%= materials.compositeMaterials[key].altColor %><% } %>"></div>\
<span><%= materials.compositeMaterials[key].name %></span></div>\
</label>\
<% }); %><br/>\
<a id="navToCompositeMenu" href="#" class="btn btn-block btn-lg btn-default">+ Create New Composite Material</a><br/>\ <a id="navToCompositeMenu" href="#" class="btn btn-block btn-lg btn-default">+ Create New Composite Material</a><br/>\
') ')
......
...@@ -27,7 +27,10 @@ define(['jquery', 'underscore', 'plist', 'backbone', 'lattice'], function($, _, ...@@ -27,7 +27,10 @@ define(['jquery', 'underscore', 'plist', 'backbone', 'lattice'], function($, _,
//bind events //bind events
this.listenTo(this.model, "change:currentNav", this.render); this.listenTo(this.model, "change:currentNav", this.render);
this.listenTo(lattice, "change:cellType change:connectionType", this._populateAndShow); this.listenTo(lattice, "change:cellType change:connectionType", this._populateAndShow);
this.listenTo(this.model, "change:currentTab", this._updateCurrentTab); this.listenTo(this.model, "change:currentTab", function(){
if (!this.model.changedAttributes() || this.model.changedAttributes()["currentNav"]) return;
this._updateCurrentTab();
});
this.listenTo(this.model, "change:menuIsVisible", this._setVisibility); this.listenTo(this.model, "change:menuIsVisible", this._setVisibility);
if (this.model.get("menuIsVisible")) this._populateAndShow(); if (this.model.get("menuIsVisible")) this._populateAndShow();
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
define(['underscore', 'three'], function(_, THREE){ define(['underscore', 'three'], function(_, THREE){
var materials = { var materials = {
deleteMaterial: new THREE.MeshLambertMaterial({color:"#ff0000", shading:THREE.FlatShading}) deleteMaterial: new THREE.MeshLambertMaterial({color:"#ff0000", shading:THREE.FlatShading}),
compositeMaterials: {}
}; };
return { return {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment