Commit 28a607be authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

highlight

parent ecbf62a1
......@@ -466,3 +466,7 @@ label {
position: absolute;
left: 245px;
}
.assemblerTree{
margin-left: 30px;
}
\ No newline at end of file
......@@ -69,7 +69,7 @@ define(['underscore', 'three', 'backbone', 'appState', 'latticeCAM', 'threeModel
"change:rapidHeight " +
"change:machineName",
this._setNeedsPostProcessing);
this.listenTo(lattice,
this.listenTo(lattice,//todo this isn't working
"change:scale" +
"change:units" +
"change:numCells " +
......@@ -81,6 +81,7 @@ define(['underscore', 'three', 'backbone', 'appState', 'latticeCAM', 'threeModel
this.listenTo(lattice, "change:partType", this._updatePartType);
this.listenTo(appState, "change:cellMode", this._updateCellMode);
this.listenTo(this, "change:machineName", this.selectMachine);
this.listenTo(this, "change:editingComponent", this._editComponent);
this._navChanged();
// this._initOriginAndStock();
......@@ -181,6 +182,11 @@ define(['underscore', 'three', 'backbone', 'appState', 'latticeCAM', 'threeModel
three.render();
},
_editComponent: function(){
var componentId = this.get("editingComponent");
if (componentId) this.get("assembler").highlight(componentId);
},
......@@ -193,7 +199,8 @@ define(['underscore', 'three', 'backbone', 'appState', 'latticeCAM', 'threeModel
isVisible: function(){
var currentTab = appState.get("currentTab");
return (currentTab == "assemblerSetup" || currentTab == "cam" || currentTab == "animate" || currentTab == "send");
return (currentTab == "assemblerSetup" || currentTab == "cam" || currentTab == "animate" || currentTab == "send"
|| currentTab == "editComponent");
},
......
......@@ -5,7 +5,7 @@
define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', 'component', 'stockComponent'],
function(_, appState, lattice, THREE, three, cam, Component, StockComponent){
var assemblerMaterial = new THREE.MeshLambertMaterial({color:0xaaaaaa, shading: THREE.FlatShading, transparent:true, opacity:0.5});
var assemblerMaterial = new THREE.MeshLambertMaterial({color:0xaaaaaa, shading: THREE.FlatShading, transparent:true, opacity:0.3});
var stlLoader = new THREE.STLLoader();
function Assembler(id, json){
......@@ -75,7 +75,7 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
console.warn("no geometry loaded for " + filename);
return;
}
components[id].makeGeometry(geo, assemblerMaterial);
components[id].makeGeometry(geo, assemblerMaterial.clone());
});
});
};
......@@ -103,9 +103,22 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
this._setTranslucent();
three.render();
};
Assembler.prototype.highlight = function(componentId){
this.components[componentId].setTranslucent(false);
};
Assembler.prototype._setTranslucent = function(){
assemblerMaterial.transparent = (appState.get("currentTab") == "cam" || appState.get("currentTab") == "assemblerSetup");
var currentTab = appState.get("currentTab");
var translucent = currentTab == "cam" || currentTab == "assemblerSetup";
if (currentTab == "editComponent") return;
_.each(this.components, function(component){
component.setTranslucent(translucent);
});
};
Assembler.prototype.buildComponentTree = function(){
};
......@@ -302,8 +315,13 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
_.each(this.components, function(component, id){
componentsJSON[id] = component.toJSON();
});
var stockJSON = {};
_.each(this.stock, function(thisStock, id){
stockJSON[id] = thisStock.toJSON();
});
return {
components: componentsJSON,
stock: stockJSON,
translation: this.translation,
scale: this.scale,
rotation: this.rotation,
......
......@@ -19,7 +19,8 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){
Component.prototype.makeGeometry = function(geo, material){
this.object3D.add(new THREE.Mesh(geo, material));
this.stl = new THREE.Mesh(geo, material);
this.object3D.add(this.stl);
};
Component.prototype.addChild = function(child){
......@@ -65,6 +66,12 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){
return this.id;
};
Component.prototype.setTranslucent = function(translucent){
if (this.stl === undefined) return;
this.stl.material.transparent = translucent;
};
//simulation animation
......
Parent/Child Tree:<br/>
<% _.each(components, function(component){ %>
<%= component.name %> <a data-id="<%= component.id %>" class="editMachineComponent" href="#">Edit</a><br/>
<label class="assemblerTree"><%= component.name %> <a data-id="<%= component.id %>" class="editMachineComponent" href="#">Edit</a></label><br/>
<% }); %><br/>
<a href="#" id="newMachineComponent" class=" btn btn-block btn-lg btn-default">+ New Machine Component</a><br/>
Stock:<br/>
<% _.each(stock, function(stockEl, id){ %>
<%= stockEl.name %> <a data-id="<%= id %>" class="edit Stock" href="#">Edit</a><br/>
<label class="assemblerTree"><%= stockEl.name %> <a data-id="<%= id %>" class="edit Stock" href="#">Edit</a></label><br/>
<% }); %><br/>
<a href="#" id="addStock" class=" btn btn-block btn-lg btn-default">+ New Stock</a><br/>
Offset (xyz):&nbsp;&nbsp;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment