diff --git a/js/models/AppState.js b/js/models/AppState.js index 786b499f7eff7406fffa4c5cbf42cc07bba4f20f..18e440619010dc99d7716e368ee17999832ef75d 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -177,6 +177,7 @@ AppState = Backbone.Model.extend({ extrudeMode: false, cellMode: "cell",//show cells vs part cellsVisible: true, + superCellIndex: 0, stockSimulationPlaying: false, manualSelectOrigin: false//mode that allows user ot select origin from existing cell @@ -272,7 +273,7 @@ AppState = Backbone.Model.extend({ } else this.downKeys[e.keyCode] = false; // console.log(e); -// console.log(e.keyCode); + console.log(e.keyCode); switch(e.keyCode){ case 8://delete key - causes back nav in chrome, super annoying e.preventDefault(); @@ -325,6 +326,20 @@ AppState = Backbone.Model.extend({ if (dmaGlobals.lattice.get("connectionType") != "gik") break; if (state) dmaGlobals.lattice.set("gikLength", e.keyCode-48); break; + case 81://q - increase supercell index + if (state) { + var index = this.get("superCellIndex")+1; + if (index > dmaGlobals.lattice.get("gikLength")-1) index = 0; + this.set("superCellIndex", index); + } + break; + case 65://a - decrease supercell index + if (state) { + var index = this.get("superCellIndex")-1; + if (index < 0) index = dmaGlobals.lattice.get("gikLength")-1; + this.set("superCellIndex", index); + } + break; default: break; } diff --git a/js/models/Lattice.js b/js/models/Lattice.js index c7ff0c7dba34008feefd1327b2e7cce669de12d1..886637dd3e1b6e3dae88c21f588c94d7ba1674ae 100644 --- a/js/models/Lattice.js +++ b/js/models/Lattice.js @@ -38,6 +38,7 @@ Lattice = Backbone.Model.extend({ //bind events this.listenTo(this, "change:scale", this._scaleDidChange); this.listenTo(this, "change:gikLength", this._gikLengthDidChange); + this.listenTo(options.appState, "change:superCellIndex", this._gikLengthDidChange); this.listenTo(options.appState, "change:cellMode", this._updateForMode); this.listenTo(this, "change:partType", this._updatePartType); this.listenTo(this, "change:cellType change:connectionType", this._updateLatticeType); diff --git a/js/threeViews/Highlighter.js b/js/threeViews/Highlighter.js index c0cb204fce90e36c07b311935cb9df06571ec1da..4910df3d3325e33aaa442f792a9c7f573f8f5fe7 100644 --- a/js/threeViews/Highlighter.js +++ b/js/threeViews/Highlighter.js @@ -224,14 +224,11 @@ GIKHighlighter = Highlighter.extend({ }, _setRotation: function(direction, index){ - if ((index.z%2 == 0 && Math.abs(direction.z) > 0.9) || (index.z%2 != 0 && Math.abs(direction.z) < 0.1)) { - this.mesh.rotation.set(0, 0, Math.PI/2); - this.mesh.translateX(-this.mesh.scale.x/2+this.mesh.scale.z/2); - } - else { - this.mesh.rotation.set(0,0,0); - this.mesh.translateX(-this.mesh.scale.x/2+this.mesh.scale.z/2); - } + var superCellIndex = dmaGlobals.appState.get("superCellIndex"); + var scale = this.mesh.scale.z; + if ((index.z%2 == 0 && Math.abs(direction.z) > 0.9) || (index.z%2 != 0 && Math.abs(direction.z) < 0.1)) this.mesh.rotation.set(0, 0, Math.PI/2); + else this.mesh.rotation.set(0,0,0); + this.mesh.translateX(-this.mesh.scale.x/2+scale/2+scale*superCellIndex); }, updateGikLength: function(scale){ @@ -247,10 +244,17 @@ GIKHighlighter = Highlighter.extend({ if (shouldAdd){ if (!this.isVisible() || !this.highlightedObject) return; var position = this._getNextCellPosition(); - var min; - if (this.mesh.rotation.z == 0) min = {x:position.x-(dmaGlobals.lattice.get("gikLength")-1), y:position.y, z:position.z}; - else min = {x:position.x, y:position.y-(dmaGlobals.lattice.get("gikLength")-1), z:position.z}; - var range = {min:min, max:position}; + var index = dmaGlobals.appState.get("superCellIndex"); + var min, max; + if (this.mesh.rotation.z == 0) { + min = {x:position.x-dmaGlobals.lattice.get("gikLength")+index, y:position.y, z:position.z}; + max = {x:position.x+index, y:position.y, z:position.z}; + } + else { + min = {x:position.x, y:position.y-dmaGlobals.lattice.get("gikLength")+index, z:position.z}; + max = {x:position.x, y:position.y+index, z:position.z}; + } + var range = {min:min, max:max}; dmaGlobals.lattice.addSuperCell(range); } else { if (!this.highlightedObject) return;