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

lattice scaling vis

parent 0d87bc86
No related branches found
No related tags found
No related merge requests found
...@@ -13,7 +13,7 @@ LatticeMenuView = Backbone.View.extend({ ...@@ -13,7 +13,7 @@ LatticeMenuView = Backbone.View.extend({
"click .cellType": "_changeCellType", "click .cellType": "_changeCellType",
"click .connectionType": "_changeConnectionType", "click .connectionType": "_changeConnectionType",
"slide #scaleSlider": "_sliderDidSlide", "slide #scaleSlider": "_sliderDidSlide",
"slideStop #scaleSlider": "_changeScaleSlider" // "slideStop #scaleSlider": "_changeScaleSlider"
}, },
...@@ -23,7 +23,7 @@ LatticeMenuView = Backbone.View.extend({ ...@@ -23,7 +23,7 @@ LatticeMenuView = Backbone.View.extend({
_.bindAll(this, "render"); _.bindAll(this, "render");
this.listenTo(this.model, "change", function(){ this.listenTo(this.model, "change", function(){
if(!this.model.hasChanged('cellMode')){//ignore cell mode changes if(!this.model.hasChanged('cellMode') && !(this.model.hasChanged('scale'))){//ignore cell mode changes
this.render(); this.render();
}; };
}); });
...@@ -44,14 +44,15 @@ LatticeMenuView = Backbone.View.extend({ ...@@ -44,14 +44,15 @@ LatticeMenuView = Backbone.View.extend({
_sliderDidSlide: function(e){ _sliderDidSlide: function(e){
var scale = $(e.target)[0].value; var scale = $(e.target)[0].value;
this.model.previewScaleChange(scale);//does not trigger lattice change event - no rerendering of ui this.model.set("scale", $(e.target)[0].value);
// this.model.previewScaleChange(scale);//does not trigger lattice change event - no rerendering of ui
$("#latticeScale").val(scale); $("#latticeScale").val(scale);
window.three.render(); window.three.render();
}, },
_changeScaleSlider: function(e){ // _changeScaleSlider: function(e){
this.model.set("scale", $(e.target)[0].value); // this.model.set("scale", $(e.target)[0].value);
}, // },
_changeCellType: function(e){ _changeCellType: function(e){
e.preventDefault(); e.preventDefault();
......
...@@ -8,8 +8,8 @@ BasePlane = Backbone.Model.extend({ ...@@ -8,8 +8,8 @@ BasePlane = Backbone.Model.extend({
defaults: { defaults: {
zIndex: 0, zIndex: 0,
mesh: null, mesh: null,
dimX: 10, dimX: 100,
dimY: 10, dimY: 100,
material: new THREE.MeshBasicMaterial({color:0x000000, transparent:true, opacity:0.2, wireframe:true, side:THREE.DoubleSide}), material: new THREE.MeshBasicMaterial({color:0x000000, transparent:true, opacity:0.2, wireframe:true, side:THREE.DoubleSide}),
currentScene: "default", currentScene: "default",
allScenes: {default:"Default", "mars":"Mars"} allScenes: {default:"Default", "mars":"Mars"}
......
...@@ -219,9 +219,9 @@ Lattice = Backbone.Model.extend({ ...@@ -219,9 +219,9 @@ Lattice = Backbone.Model.extend({
window.three.render(); window.three.render();
}, },
previewScaleChange: function(scale){ // previewScaleChange: function(scale){
this.get("basePlane").updateScale(scale); // this.get("basePlane").updateScale(scale);
}, // },
_changeLatticeStructure: function(){ _changeLatticeStructure: function(){
this.clearCells(); this.clearCells();
...@@ -262,7 +262,7 @@ OctaFaceLattice = Lattice.extend({ ...@@ -262,7 +262,7 @@ OctaFaceLattice = Lattice.extend({
//bind events //bind events
this.listenTo(this, "change:columnSeparation", this._changeColSeparation); this.listenTo(this, "change:columnSeparation", this._changeColSeparation);
this.set("columnSeparation", 0.2); this.set("columnSeparation", 0.1);
}, },
_changeColSeparation: function(){ _changeColSeparation: function(){
...@@ -279,10 +279,12 @@ OctaFaceLattice = Lattice.extend({ ...@@ -279,10 +279,12 @@ OctaFaceLattice = Lattice.extend({
//calc indices in cell matrix //calc indices in cell matrix
var scale = this.get("scale"); var scale = this.get("scale");
var colSep = this.get("columnSeparation");
var latticeScale = scale*(1+2*colSep);
var octHeight = 2*scale/Math.sqrt(6); var octHeight = 2*scale/Math.sqrt(6);
var triHeight = scale/2*Math.sqrt(3); var triHeight = latticeScale/2*Math.sqrt(3);
var position = {}; var position = {};
position.x = Math.round(absPosition.x/scale); position.x = Math.round(absPosition.x/latticeScale);
position.y = Math.round(absPosition.y/triHeight); position.y = Math.round(absPosition.y/triHeight);
position.z = Math.round(absPosition.z/octHeight); position.z = Math.round(absPosition.z/octHeight);
if (position.z%2 == 1) position.y += 1; if (position.z%2 == 1) position.y += 1;
......
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