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

arrows move up and down e sim

parent 543d99b7
No related branches found
No related tags found
No related merge requests found
......@@ -157,7 +157,7 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu
this.downKeys[e.keyCode] = true;
} else this.downKeys[e.keyCode] = false;
// console.log(e);
// console.log(e);
// console.log(e.keyCode);
switch(e.keyCode){
case 8://delete key - causes back nav in chrome, super annoying
......@@ -230,6 +230,18 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu
case 90://z - decrease supercell index
if (state) this.set("superCellIndex", this._decrementSuperCellIndex("z", this.get("superCellIndex").clone()));
break;
case 38://up arrow
if (!state || this.get("currentNav") != "electronicNavSim") return;
require(['eSim'], function(eSim){
eSim.setZSimHeight(eSim.get("simZHeight")+1);
});
break;
case 40://down arrow
if (!state || this.get("currentNav") != "electronicNavSim") return;
require(['eSim'], function(eSim){
eSim.setZSimHeight(eSim.get("simZHeight")-1);
});
break;
default:
break;
}
......
......@@ -188,8 +188,7 @@ define(['lattice', 'appState', 'three', 'threeModel', 'numeric', 'eSim', 'eSimFi
} else {
eSim.set("chargeField", new ESimField(chargeMat, offset, resolution, eSim.get("simZHeight"), dataRange));
}
eSim.set("visibleStaticSim", "chargeField");//will cause render
// -10*(P15+Q14+R15+Q16-4*Q15)
// eSim.set("visibleStaticSim", "chargeField");//will cause render
},
......
......@@ -35,6 +35,12 @@ define(['underscore', 'backbone', 'threeModel'], function(_, Backbone, three){
},
setZSimHeight: function(height){
if (height < 0) return;
var field = this.get(this.get("visibleStaticSim"));
if (field && height<field.getMaxHeight()) this.set("simZHeight", height);
},
_hideAllFields: function(){
if (this.get("rawPotentialField")) this.get("rawPotentialField").hide();
if (this.get("potentialField")) this.get("potentialField").hide();
......
......@@ -30,6 +30,11 @@ define(['underscore', 'threeModel'], function(_, three){
this._threeObjects = this._createThreeObjects(data, offset, 1/resolution, height, this._object3D);
};
ESimField.prototype.getMaxHeight = function(){
if (!this._data) return 0;
return this._data[0][0].length;
};
ESimField.prototype._setObject3DPosition = function(offset, resolution, height){
this._object3D.position.set(offset.x, offset.y, offset.z+height/resolution);
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment