From 37e30c43754e946e378f9a2b75c650e52cb76d8a Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Thu, 2 Jul 2015 13:31:58 -0700 Subject: [PATCH] transparency passed down to parts, switch from mechnical to electronic sim --- js/cells/DMACell.js | 6 +++++- js/materials/DMAMaterials.js | 1 + js/menus/MSetupMenuView.js | 8 +++++++- js/menus/templates/ESetupMenuView.html | 2 +- js/menus/templates/MSetupMenuView.html | 9 +++++++++ js/parts/DMAPart.js | 5 +++++ 6 files changed, 28 insertions(+), 3 deletions(-) diff --git a/js/cells/DMACell.js b/js/cells/DMACell.js index 3121ecdf..53e652f9 100644 --- a/js/cells/DMACell.js +++ b/js/cells/DMACell.js @@ -247,7 +247,6 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', ' DMACell.prototype.setWireframeVisibility = function(visible, mode){ if (visible && mode === undefined) mode = this.getConditionalMode(appState.get("cellMode")); - console.log(visible && this.object3D.children[1].name == mode); this.object3D.children[1].visible = visible && this.object3D.children[1].name == mode; }; @@ -257,6 +256,11 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', ' this.isTransparent = transparent; this.setMaterial(this.getMaterial(true)); this.setWireframeVisibility(!this.isTransparent); + if (this.parts) { + _.each(this.parts, function(part){ + part.updateMaterial(); + }); + } }; DMACell.prototype.getConditionalMode = function(mode){ diff --git a/js/materials/DMAMaterials.js b/js/materials/DMAMaterials.js index f075689b..1cfa0213 100644 --- a/js/materials/DMAMaterials.js +++ b/js/materials/DMAMaterials.js @@ -198,6 +198,7 @@ define(['underscore', 'three', 'appState', 'lattice', 'plist', 'threeModel'], fu } function makeMaterialObject(color, transparent){ +// return new THREE.MeshNormalMaterial({shading:THREE.FlatShading}); if (transparent) return new THREE.MeshLambertMaterial({color:color, shading:THREE.FlatShading, transparent: true, opacity:0.1}); return new THREE.MeshLambertMaterial({color:color, shading:THREE.FlatShading}); } diff --git a/js/menus/MSetupMenuView.js b/js/menus/MSetupMenuView.js index c8d1c70d..3a0f9aae 100644 --- a/js/menus/MSetupMenuView.js +++ b/js/menus/MSetupMenuView.js @@ -11,10 +11,16 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'text!mSetupMenuTemplate' }, _initialize: function(){ + this.listenTo(this.model, "change:materialClass", this._changeSimNav); + }, + + _changeSimNav: function(){ + var materialClass = this.model.get("materialClass"); + this.model.set("currentNav", materialClass + "NavSim"); }, _makeTemplateJSON: function(){ - return null; + return _.extend(this.model.toJSON(), plist); }, template: _.template(template) diff --git a/js/menus/templates/ESetupMenuView.html b/js/menus/templates/ESetupMenuView.html index e5ae5f51..4b9e8119 100644 --- a/js/menus/templates/ESetupMenuView.html +++ b/js/menus/templates/ESetupMenuView.html @@ -7,7 +7,7 @@ Simulation Type: <% }); %> </ul> </div><br/><br/> -<a href="#" id="calcConnectivity" class="btn btn-block btn-lg btn-default">Calculate Connectivity</a><br/> +<a href="#" id="calcConnectivity" class="btn btn-block btn-lg btn-default"><% if(conductorGroups){ %>Re-<% } %>Calculate Connectivity</a><br/> <% if(conductorGroups){ %> Num Connected Conductors:  <%= conductorGroups.length %><br/> <label class="radio"> diff --git a/js/menus/templates/MSetupMenuView.html b/js/menus/templates/MSetupMenuView.html index 1edc0e9d..3508aa11 100644 --- a/js/menus/templates/MSetupMenuView.html +++ b/js/menus/templates/MSetupMenuView.html @@ -1 +1,10 @@ +Simulation Type: + <div class="btn-group"> + <button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= allMaterialClasses[materialClass] %><span class="caret"></span></button> + <ul role="menu" class="dropdown-menu"> + <% _.each(_.keys(allMaterialClasses), function(key){ %> + <li><a class="appState dropdownSelector" data-property="materialClass" data-value="<%= key %>" href="#"><%= allMaterialClasses[key] %></a></li> + <% }); %> + </ul> + </div><br/><br/> setup, boundary conditions, physics \ No newline at end of file diff --git a/js/parts/DMAPart.js b/js/parts/DMAPart.js index 73d1b4ac..de0a14a5 100644 --- a/js/parts/DMAPart.js +++ b/js/parts/DMAPart.js @@ -28,6 +28,7 @@ define(['underscore', 'three'], function(_, THREE){ }; DMAPart.prototype.getMaterial = function(returnTHREEObject){ +// return new THREE.MeshLambertMaterial({color:'#aaaaaa', shading:THREE.FlatShading}); return this.parentCell.getMaterial(returnTHREEObject); }; @@ -35,6 +36,10 @@ define(['underscore', 'three'], function(_, THREE){ this.mesh.material = material; }; + DMAPart.prototype.updateMaterial = function(){ + this.mesh.material = this.getMaterial(true); + }; + DMAPart.prototype.destroy = function(){ if (this.mesh) { this.parentCell.removeChildren(this.mesh); -- GitLab