diff --git a/js/materials/DMAMaterials.js b/js/materials/DMAMaterials.js index b403afa063fd054734af8e78e11a0f20ecf91ab1..3353d61ea145ecc0142c0cc4f30b2b6f93133907 100644 --- a/js/materials/DMAMaterials.js +++ b/js/materials/DMAMaterials.js @@ -84,9 +84,12 @@ define(['underscore', 'three', 'appState', 'lattice', 'plist', 'threeModel'], fu function setMaterialDefaults(){ var materialType = appState.get("materialType"); - if (!materials[materialType].dimensions) return; - appState.set("superCellRange", materials[materialType].dimensions.clone()); appState.set("superCellIndex", new THREE.Vector3(0,0,0)); + if (materials[materialType].dimensions){ + appState.set("superCellRange", materials[materialType].dimensions.clone()); + } else if (lattice.get("connectionType") == "gik"){ + appState.set("superCellRange", new THREE.Vector3(appState.get("gikLength"), 1, 1)); + } } return materials; diff --git a/js/menus/templates/LatticeMenuView.html b/js/menus/templates/LatticeMenuView.html index d7cfcd1c5f950877ce4aa759ec0f4d203039b23d..9bf394ae41a37d1f6a655867fc9cf31796ea31fe 100644 --- a/js/menus/templates/LatticeMenuView.html +++ b/js/menus/templates/LatticeMenuView.html @@ -17,7 +17,7 @@ Cell Connection: </ul> </div><br/><br/> <% if (connectionType == "gik") { %> - GIK Length: <input data-property="superCellRange" data-key="x" value="<%= superCellRange.x %>" placeholder="GIK length" class="form-control intInput appState" type="text"><br/><br/> + GIK Length: <input data-property="gikLength" value="<%= gikLength %>" placeholder="GIK length" class="form-control intInput appState" type="text"><br/><br/> <% } %> <a href="#" class="clearCells btn btn-block btn-lg btn-danger">Clear All Cells</a><br/> Num Cells: <%= numCells %><br/> diff --git a/js/models/AppState.js b/js/models/AppState.js index b282da4ce6b37072c26470b0d64f81fff50bc1bc..fa11e4e5901341224a75c58affbc862bfedd817d 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -34,6 +34,7 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu cellsVisible: true, superCellIndex: new THREE.Vector3(0,0,0),//offset of superCell adds + gikLength: 4,//this updates super cell range when using non-composite materials superCellRange: new THREE.Vector3(1,1,1), realisticColorScheme: false, @@ -58,6 +59,7 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu this.listenTo(this, "change:currentTab", this._tabChanged); this.listenTo(this, "change:currentNav", this._navChanged); this.listenTo(this, "change:materialType", this._materialTypeChanged); + this.listenTo(this, "change:gikLength", this._gikLengthChanged); this.downKeys = {};//track keypresses to prevent repeat keystrokeson hold @@ -125,6 +127,12 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu }); }, + _gikLengthChanged: function(){ + if (this.get("materialType").substr(0,5) != "super"){ + this.set("superCellRange", new THREE.Vector3(this.get("gikLength"), 1, 1)); + } + }, + /////////////////////////////////////////////////////////////////////////////// /////////////////////KEY BINDINGS////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// @@ -200,9 +208,7 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu case 57: if (this.lattice.get("connectionType") != "gik") break; if (state) { - var range = this.get("superCellRange").clone(); - range.x = e.keyCode-48; - this.set("superCellRange", range); + this.set("gikLength", e.keyCode-48); } break; case 87://w - increase supercell index