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

create new material definitions

parent f05330ba
No related branches found
No related tags found
No related merge requests found
...@@ -14,10 +14,12 @@ define(['underscore', 'three', 'appState', 'lattice', 'plist', 'threeModel'], fu ...@@ -14,10 +14,12 @@ define(['underscore', 'three', 'appState', 'lattice', 'plist', 'threeModel'], fu
if (id && data === null) return deleteMaterial(id); if (id && data === null) return deleteMaterial(id);
if (!materials[id]) materials[id] = {}; if (!materials[id]) materials[id] = {};
var oldColor = materials[id].color; var oldColor = materials[id].color;
_.each(_.keys(data), function(key){//todo trigger change on all instances _.each(_.keys(data), function(key){//todo trigger change on all instances
if (data[key] && data[key].x) materials[id][key] = new THREE.Vector3(data[key].x, data[key].y, data[key].z); if (data[key] && data[key].x) materials[id][key] = new THREE.Vector3(data[key].x, data[key].y, data[key].z);
else materials[id][key] = data[key]; else materials[id][key] = data[key];
}); });
if (materials[id].threeMaterial || oldColor != materials[id].color) changeSingleMaterialColorScheme(id); if (materials[id].threeMaterial || oldColor != materials[id].color) changeSingleMaterialColorScheme(id);
return false; return false;
} }
......
...@@ -5,13 +5,16 @@ ...@@ -5,13 +5,16 @@
define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice', 'globals', 'materials', 'text!materialMenuTemplate'], define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice', 'globals', 'materials', 'text!materialMenuTemplate'],
function($, _, MenuParentView, plist, lattice, globals, materials, template){ function($, _, MenuParentView, plist, lattice, globals, materials, template){
var materialID = 0;
return MenuParentView.extend({ return MenuParentView.extend({
events: { events: {
"click #navToCompositeMenu": "_navToCompositeMenu", "click #navToCompositeMenu": "_navToCompositeMenu",
"click #compositeFromLattice": "_latticeToComposite", "click #compositeFromLattice": "_latticeToComposite",
"click .editComposite": "_editComposite", "click .editComposite": "_editComposite",
"click .editMaterial": "_editMaterial" "click .editMaterial": "_editMaterial",
"click #newElementaryMaterial": "_newMaterial"
}, },
_initialize: function(){ _initialize: function(){
...@@ -36,6 +39,23 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice', 'globals', 'ma ...@@ -36,6 +39,23 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice', 'globals', 'ma
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
var id = $(e.target).data("id"); var id = $(e.target).data("id");
this._openMaterialEditor(id);
},
_newMaterial: function(e){
e.preventDefault();
//first create dummy material
var id = "material" + this.cid + materialID++;
materials.setMaterial(id, {
name: "",
color: '#000000',
altColor: '#000000',
noDelete: false
});
this._openMaterialEditor(id);
},
_openMaterialEditor: function(id){
this.model.set("materialType", id); this.model.set("materialType", id);
this.model.set("currentTab", "materialEditor", {silent:true}); this.model.set("currentTab", "materialEditor", {silent:true});
this.model.set("currentNav", "navMaterial"); this.model.set("currentNav", "navMaterial");
......
...@@ -16,8 +16,9 @@ Material Class:    ...@@ -16,8 +16,9 @@ Material Class:   
<div style="background-color:<% if(realisticColorScheme){ %><%= allMaterials[materialClass][key].color %><% }else{ %><%= allMaterials[materialClass][key].altColor %><% } %>"></div> <div style="background-color:<% if(realisticColorScheme){ %><%= allMaterials[materialClass][key].color %><% }else{ %><%= allMaterials[materialClass][key].altColor %><% } %>"></div>
<span><span class="materialListTitle"><%= allMaterials[materialClass][key].name %></span><a data-id="<%= key %>" class="editMaterial">Edit...</a></span></div> <span><span class="materialListTitle"><%= allMaterials[materialClass][key].name %></span><a data-id="<%= key %>" class="editMaterial">Edit...</a></span></div>
</label> </label>
<% }); %><br/> <% }); %>
<label class="checkbox" for="realisticColorScheme"> <!--<a id="newElementaryMaterial" href="#" class="btn btn-block btn-lg btn-default">+ Create New Material Definition</a>-->
<br/><label class="checkbox" for="realisticColorScheme">
<input id="realisticColorScheme" data-property="realisticColorScheme" type="checkbox" <% if (realisticColorScheme){ %> checked="checked"<% } %> value="" data-toggle="checkbox" class="appState custom-checkbox"> <input id="realisticColorScheme" data-property="realisticColorScheme" type="checkbox" <% if (realisticColorScheme){ %> checked="checked"<% } %> value="" data-toggle="checkbox" class="appState custom-checkbox">
<span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span> <span class="icons"><span class="icon-unchecked"></span><span class="icon-checked"></span></span>
Use realistic color scheme</label> Use realistic color scheme</label>
...@@ -35,7 +36,7 @@ Composite Materials:<br/> ...@@ -35,7 +36,7 @@ Composite Materials:<br/>
<span><span class="materialListTitle"><%= materials[key].name %></span><a data-id="<%= key %>" class="editComposite">Edit...</a></span></div> <span><span class="materialListTitle"><%= materials[key].name %></span><a data-id="<%= key %>" class="editComposite">Edit...</a></span></div>
</label> </label>
<% }); %><br/> <% }); %><br/>
<% if (_.filter(_.keys(materials), function(name){return name.substr(0,5) == "super"; }).length > 0) { %> <% if (materialType.substr(0,5) == "super") { %>
Offset (xyz): &nbsp;&nbsp;<input data-property="superCellIndex" data-key="x" value="<%= superCellIndex.x %>" placeholder="X" class="form-control intInput appState" type="text">&nbsp; Offset (xyz): &nbsp;&nbsp;<input data-property="superCellIndex" data-key="x" value="<%= superCellIndex.x %>" placeholder="X" class="form-control intInput appState" type="text">&nbsp;
<input data-property="superCellIndex" data-key="y" value="<%= superCellIndex.y %>" placeholder="Y" class="form-control intInput appState" type="text">&nbsp; <input data-property="superCellIndex" data-key="y" value="<%= superCellIndex.y %>" placeholder="Y" class="form-control intInput appState" type="text">&nbsp;
<input data-property="superCellIndex" data-key="z" value="<%= superCellIndex.z %>" placeholder="Z" class="form-control intInput appState" type="text"><br/><br/> <input data-property="superCellIndex" data-key="z" value="<%= superCellIndex.z %>" placeholder="Z" class="form-control intInput appState" type="text"><br/><br/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment