diff --git a/js/lattice/Lattice.js b/js/lattice/Lattice.js index d7b3ee4490e6d56b1cdfc2548c9909993d61f8df..bbb75416656baf94687aa52e6b29e9a098105c54 100644 --- a/js/lattice/Lattice.js +++ b/js/lattice/Lattice.js @@ -3,8 +3,8 @@ */ -define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'threeModel', 'latticeBase'], - function(_, Backbone, appState, globals, plist, THREE, three, LatticeBase){ +define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'materialsPlist', 'three', 'threeModel', 'latticeBase'], + function(_, Backbone, appState, globals, plist, materialsPlist, THREE, three, LatticeBase){ var Lattice = LatticeBase.extend({ @@ -96,7 +96,7 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre if (latticeData.parts) newPartType = _.keys(latticeData.parts)[0]; this.set("partType", newPartType, {silent:true}); - var newMaterialClass = (latticeData.materialClasses || _.keys(plist.allMaterialClasses))[0]; + var newMaterialClass = (latticeData.materialClasses || _.keys(materialsPlist.allMaterialClasses))[0]; appState.set("materialClass", newMaterialClass); if (latticeData.options){ diff --git a/js/main.js b/js/main.js index 5fc9b106f9b1c85421454b318f47b4279a490ae2..6c1e304e796383885204e6f09849c5ca0be4c036 100644 --- a/js/main.js +++ b/js/main.js @@ -117,6 +117,7 @@ require.config({ dnaLegoPart: 'parts/DNALegoPart', //materials + materialsPlist: 'plists/MaterialsPlist', materials: 'materials/DMAMaterials', material: 'materials/DMAMaterial', diff --git a/js/materials/DMAMaterials.js b/js/materials/DMAMaterials.js index d8a6b3ed656a1943851ffac8ed478c986d406699..a1ae8b9001a893c662074663d583101cfddddd4e 100644 --- a/js/materials/DMAMaterials.js +++ b/js/materials/DMAMaterials.js @@ -3,17 +3,18 @@ */ //everything is a top level material with a threeMaterial object -define(['underscore', 'three', 'appState', 'lattice', 'plist', 'threeModel', 'material'], - function(_, THREE, appState, lattice, plist, three, DMAMaterial){ +define(['underscore', 'three', 'appState', 'lattice', 'materialsPlist', 'threeModel', 'material'], + function(_, THREE, appState, lattice, materialsPlist, three, DMAMaterial){ var materialsList = { - deleteMaterial: new DMAMaterial({ - name: "Delete", - color: "#ff0000", - altColor: "#ff0000", - noDelete: true - }, "deleteMaterial") }; + newMaterial({ + id: "deleteMaterial", + name: "Delete", + color: "#ff0000", + altColor: "#ff0000", + noDelete: true + }); var listener = {}; @@ -28,7 +29,6 @@ define(['underscore', 'three', 'appState', 'lattice', 'plist', 'threeModel', 'ma - function newMaterial(data, noAdd){ if (data.sparseCells) { console.warn("you are trying to init a composite material as a regular material"); @@ -186,8 +186,8 @@ define(['underscore', 'three', 'appState', 'lattice', 'plist', 'threeModel', 'ma function setToDefaultMaterial(triggerEvent){ var materialClass = appState.get("materialClass"); - var newDefaultType = _.keys(plist.allMaterials[materialClass])[0]; - if (!materialsList[newDefaultType]) _.extend(materialsList, parseClassFromDefinitions(plist.allMaterials[materialClass])); + var newDefaultType = _.keys(materialsPlist.allMaterials[materialClass])[0]; + if (!materialsList[newDefaultType]) _.extend(materialsList, parseClassFromDefinitions(materialsPlist.allMaterials[materialClass])); if (!materialsList[newDefaultType]) console.warn("material type " + newDefaultType + " not in definition for " + materialClass); if (triggerEvent === undefined) triggerEvent = false; appState.set("materialType", newDefaultType, {silent:!triggerEvent}); diff --git a/js/menus/CompositeMenuView.js b/js/menus/CompositeMenuView.js index 3daed9ec797f477db706e88dde43268c529c139d..76fef640dfa15e887726c35eb4b6bfc566621c32 100644 --- a/js/menus/CompositeMenuView.js +++ b/js/menus/CompositeMenuView.js @@ -2,8 +2,8 @@ * Created by aghassaei on 6/10/15. */ -define(['jquery', 'underscore', 'menuParent', 'compositeEditorLattice', 'plist', 'lattice', 'globals', 'materials', 'text!compositeMenuTemplate'], - function($, _, MenuParentView, CompositeEditorLattice, plist, lattice, globals, materials, template){ +define(['jquery', 'underscore', 'menuParent', 'compositeEditorLattice', 'materialsPlist', 'lattice', 'globals', 'materials', 'text!compositeMenuTemplate'], + function($, _, MenuParentView, CompositeEditorLattice, materialsPlist, lattice, globals, materials, template){ var bounds; @@ -104,7 +104,7 @@ define(['jquery', 'underscore', 'menuParent', 'compositeEditorLattice', 'plist', }, _makeTemplateJSON: function(){ - return _.extend(this.model.toJSON(), plist, globals, this.composite.toJSON(), + return _.extend(this.model.toJSON(), materialsPlist, globals, this.composite.toJSON(), { dimensions: bounds.max.clone().sub(bounds.min), materials: materials.list, diff --git a/js/menus/ESetupMenuView.js b/js/menus/ESetupMenuView.js index 905f37845e5c800ef5c858f7f1917b55be662b9e..2363a529cd16fd5529c281e275e66ff5e9b8f942 100644 --- a/js/menus/ESetupMenuView.js +++ b/js/menus/ESetupMenuView.js @@ -2,8 +2,8 @@ * Created by aghassaei on 2/25/15. */ -define(['jquery', 'underscore', 'menuParent', 'plist', 'text!eSetupMenuTemplate', 'latticeESim', 'eSim'], - function($, _, MenuParentView, plist, template, lattice, eSim){ +define(['jquery', 'underscore', 'menuParent', 'plist', 'materialsPlist', 'text!eSetupMenuTemplate', 'latticeESim', 'eSim'], + function($, _, MenuParentView, plist, materialsPlist, template, lattice, eSim){ return MenuParentView.extend({ @@ -32,7 +32,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'text!eSetupMenuTemplate' }, _makeTemplateJSON: function(){ - return _.extend(this.model.toJSON(), eSim.toJSON(), plist, lattice.toJSON()); + return _.extend(this.model.toJSON(), eSim.toJSON(), plist, materialsPlist, lattice.toJSON()); }, template: _.template(template) diff --git a/js/menus/EditComponentMenuView.js b/js/menus/EditComponentMenuView.js index b4b8231ec778c951c44bb6a05928a0ae1274f9e3..c1545eb180d5a7a12375dfcfbac34fcfed9f13a6 100644 --- a/js/menus/EditComponentMenuView.js +++ b/js/menus/EditComponentMenuView.js @@ -3,8 +3,8 @@ */ -define(['jquery', 'underscore', 'menuParent', 'plist', 'cam', 'materials', 'text!editComponentMenuTemplate'], - function($, _, MenuParentView, plist, cam, materials, template){ +define(['jquery', 'underscore', 'menuParent', 'plist', 'materialsPlist', 'cam', 'materials', 'text!editComponentMenuTemplate'], + function($, _, MenuParentView, plist, materialsPlist, cam, materials, template){ return MenuParentView.extend({ @@ -92,7 +92,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'cam', 'materials', 'text if (!correctBranch || assembler.tree[editingComponent] >= level) return; allDescendants.push(id); }); - return _.extend(this.model.toJSON(), cam.toJSON(), assembler.toJSON(), plist, + return _.extend(this.model.toJSON(), cam.toJSON(), assembler.toJSON(), plist, materialsPlist, {thisComponent: component.toJSON(), ancestors:allAncestors, descendants:allDescendants, materials:materials.list}); }, diff --git a/js/menus/MSetupMenuView.js b/js/menus/MSetupMenuView.js index 53df07001c168cbd1ac80093ae690ba1d40015d0..778b7ca10ba857a689016ce50b4789e72477a879 100644 --- a/js/menus/MSetupMenuView.js +++ b/js/menus/MSetupMenuView.js @@ -3,8 +3,8 @@ */ -define(['jquery', 'underscore', 'menuParent', 'lattice', 'plist', 'text!mSetupMenuTemplate'], - function($, _, MenuParentView, lattice, plist, template){ +define(['jquery', 'underscore', 'menuParent', 'lattice', 'plist', 'materialsPlist', 'text!mSetupMenuTemplate'], + function($, _, MenuParentView, lattice, plist, materialsPlist, template){ return MenuParentView.extend({ @@ -21,7 +21,7 @@ define(['jquery', 'underscore', 'menuParent', 'lattice', 'plist', 'text!mSetupMe }, _makeTemplateJSON: function(){ - return _.extend(this.model.toJSON(), plist, lattice.toJSON()); + return _.extend(this.model.toJSON(), plist, materialsPlist, lattice.toJSON()); }, template: _.template(template) diff --git a/js/menus/MaterialMenuView.js b/js/menus/MaterialMenuView.js index c8cb6b91cbad4bb9b24600135585591dd6476ee5..30ad7a139b5bfc18a8c775001bde8764d30dad9f 100644 --- a/js/menus/MaterialMenuView.js +++ b/js/menus/MaterialMenuView.js @@ -2,8 +2,8 @@ * Created by aghassaei on 2/25/15. */ -define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice', 'globals', 'materials', 'text!materialMenuTemplate'], - function($, _, MenuParentView, plist, lattice, globals, materials, template){ +define(['jquery', 'underscore', 'menuParent', 'materialsPlist', 'plist', 'lattice', 'globals', 'materials', 'text!materialMenuTemplate'], + function($, _, MenuParentView, materialsPlist, plist, lattice, globals, materials, template){ return MenuParentView.extend({ @@ -61,7 +61,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice', 'globals', 'ma }, _makeTemplateJSON: function(){ - return _.extend(lattice.toJSON(), this.model.toJSON(), plist, globals, {inSimMode:false, materials:materials.list, compositeMaterialsKeys:materials.getCompositeKeys()}); + return _.extend(lattice.toJSON(), this.model.toJSON(), materialsPlist, plist, globals, {inSimMode:false, materials:materials.list, compositeMaterialsKeys:materials.getCompositeKeys()}); }, template: _.template(template) diff --git a/js/plists/MaterialsPlist.js b/js/plists/MaterialsPlist.js new file mode 100644 index 0000000000000000000000000000000000000000..428c2b362f573af9e1f6014d52b4f1b633dcf742 --- /dev/null +++ b/js/plists/MaterialsPlist.js @@ -0,0 +1,103 @@ +/** + * Created by aghassaei on 9/24/15. + */ + + +define([], function(){ + + return { + allMaterialClasses:{ + mechanical: "Structural", + electronic: "Electronic", + dna: "DNA" + }, + + allMaterials:{ + dna:{ + noForces:{ + name: "No Internal Forces", + color: "#aaa", + altColor: "#666", + properties:{} + }, + tension:{ + name: "In Tension", + color: "#aaa", + altColor: "#f0c437", + properties:{} + }, + compression: { + name: "In Compression", + color: "#aaa", + altColor: "#70eee8", + properties:{} + } + }, + electronic:{ + brass:{ + name: "Brass", + color: "#b5a642", + altColor: "#857B64", + properties:{ + conductive: true + } + }, + fiberGlass: { + name: "Fiberglass", + color: "#fef1b5", +// opacity: "0.9", + altColor: "#ecf0f1", + properties:{} + }, + carbon: { + name: "Carbon Composite", + color: "#222", + altColor: "#000", + properties:{} + }, + nType: { + name: "Silicon N-Type", + color: "#bcc6cc", + altColor: "#8391AC", + properties:{} + }, + nTypePlus: { + name: "Silicon Heavily Doped N-Type (N+)", + color: "#c6ccbc", + altColor: "#9CC9CB", + properties:{} + }, + pType: { + name: "Silicon P-Type", + color: "#ccbcc6", + altColor: "#F5447B", + properties:{} + }, + pTypePlus: { + name: "Silicon Heavily Doped P-Type (P+)", + color: "#ccc2bc", + altColor: "#F99987", + properties:{} + } + //857B64 + //FDE2D9 + //D77948 + }, + mechanical:{ + rigid:{ + name: "Rigid", + color: "#aaa", + altColor: "#666", + properties:{} + }, + flexure: { + name: "Flexure", + color: "#aaa", + altColor: "#8391AC", + properties:{} + } + } + } + } + +}); \ No newline at end of file diff --git a/js/plists/PList.js b/js/plists/PList.js index b55c459886d62da5ee045c1e3040c0015d586496..ab9994e83821dca54b6b638de4419881139a785a 100644 --- a/js/plists/PList.js +++ b/js/plists/PList.js @@ -364,100 +364,6 @@ define(['three'], function(THREE){ hide: "Hide Cells (O)" }, - - allMaterialClasses:{ - mechanical: "Structural", - electronic: "Electronic", - dna: "DNA" - }, - - allMaterials:{ - dna:{ - noForces:{ - name: "No Internal Forces", - color: "#aaa", - altColor: "#666", - properties:{} - }, - tension:{ - name: "In Tension", - color: "#aaa", - altColor: "#f0c437", - properties:{} - }, - compression: { - name: "In Compression", - color: "#aaa", - altColor: "#70eee8", - properties:{} - } - }, - electronic:{ - brass:{ - name: "Brass", - color: "#b5a642", - altColor: "#857B64", - properties:{ - conductive: true - } - }, - fiberGlass: { - name: "Fiberglass", - color: "#fef1b5", -// opacity: "0.9", - altColor: "#ecf0f1", - properties:{} - }, - carbon: { - name: "Carbon Composite", - color: "#222", - altColor: "#000", - properties:{} - }, - nType: { - name: "Silicon N-Type", - color: "#bcc6cc", - altColor: "#8391AC", - properties:{} - }, - nTypePlus: { - name: "Silicon Heavily Doped N-Type (N+)", - color: "#c6ccbc", - altColor: "#9CC9CB", - properties:{} - }, - pType: { - name: "Silicon P-Type", - color: "#ccbcc6", - altColor: "#F5447B", - properties:{} - }, - pTypePlus: { - name: "Silicon Heavily Doped P-Type (P+)", - color: "#ccc2bc", - altColor: "#F99987", - properties:{} - } - //857B64 - //FDE2D9 - //D77948 - }, - mechanical:{ - rigid:{ - name: "Rigid", - color: "#aaa", - altColor: "#666", - properties:{} - }, - flexure: { - name: "Flexure", - color: "#aaa", - altColor: "#8391AC", - properties:{} - } - } - }, - allScripts: { loadFile: "Load From File..." },