diff --git a/js/cells/GIKCell.js b/js/cells/GIKCell.js index 4712e50870fc458fa2b676f4d0608cf426e3d053..b81dab5da187e7822777f6901434f04c08cecb01 100644 --- a/js/cells/GIKCell.js +++ b/js/cells/GIKCell.js @@ -15,6 +15,10 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cubeCell'], return null;//never show the gik cell }; + GIKCell.prototype.getLength = function(){ + return this.superCell.getLength(); + }; + GIKCell.prototype._initParts = function(callback){ if (!this.superCell) return; var self = this; @@ -57,7 +61,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cubeCell'], isBridge: false })); } - parts.push(new PartSubclass(self.index.x, self, {isBridge: true})); + if (self.getLength() > 1) parts.push(new PartSubclass(self.index.x, self, {isBridge: true})); callback(parts); }); } diff --git a/js/menus/templates/LatticeMenuView.html b/js/menus/templates/LatticeMenuView.html index d8d4c237a53b5b3d7ad838f2d2ed69a99b685018..38144c69dd52b48c3e1c9eb583ec1091e184ca43 100644 --- a/js/menus/templates/LatticeMenuView.html +++ b/js/menus/templates/LatticeMenuView.html @@ -25,15 +25,17 @@ Type: <% }); %> </ul> </div><br/><br/> -Part Type: - <div class="btn-group"> - <button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= allLattices[cellType].connection[connectionType].type[latticeType].parts[partType].name %><span class="caret"></span></button> - <ul role="menu" class="dropdown-menu"> - <% _.each(allLattices[cellType].connection[connectionType].type[latticeType].parts, function(val, key){ %> - <li><a class="lattice dropdownSelector" data-property="partType" data-value="<%= key %>" href="#"><%= val.name %></a></li> - <% }); %> - </ul> - </div><br/><br/> +<% if(allLattices[cellType].connection[connectionType].type[latticeType].parts){ %> + Part Type: + <div class="btn-group"> + <button data-toggle="dropdown" class="btn dropdown-toggle" type="button"><%= allLattices[cellType].connection[connectionType].type[latticeType].parts[partType].name %><span class="caret"></span></button> + <ul role="menu" class="dropdown-menu"> + <% _.each(allLattices[cellType].connection[connectionType].type[latticeType].parts, function(val, key){ %> + <li><a class="lattice dropdownSelector" data-property="partType" data-value="<%= key %>" href="#"><%= val.name %></a></li> + <% }); %> + </ul> + </div><br/><br/> +<% } %> Aspect Ratio: <input data-property="aspectRatio" data-key="x" value="<%= aspectRatio.x %>" placeholder="X" class="form-control lattice floatInput" type="text"> <input data-property="aspectRatio" data-key="y" value="<%= aspectRatio.y %>" placeholder="Y" class="form-control lattice floatInput" type="text"> diff --git a/js/models/AppState.js b/js/models/AppState.js index 9b150c3ca9c254b9a7b524ce1d7e504c1238fd9a..355a88ad98ff9fcafb578e42ad4349d537d7e174 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -199,7 +199,7 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu } 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(); @@ -250,7 +250,8 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu e.preventDefault(); if (state && this.get("currentTab") == "animate") this.set("stockSimulationPlaying", !this.get("stockSimulationPlaying")); break; - case 50://2-9 + case 49://1-9 + case 50: case 51: case 52: case 53: @@ -260,7 +261,15 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu case 57: if (this.lattice.get("connectionType") != "gik") break; if (state) { - this.set("gikLength", e.keyCode-48); + var val = e.keyCode-48; + var range = plist.allLattices[this.lattice.get("cellType")].connection[this.lattice.get("connectionType")].type[this.lattice.get("latticeType")].options.gikRange; + if (range){ + if ((range[0] > 0 && val < range[0]) || (range[1] > 1 && val > range[1])){ + console.warn("gik length out of range"); + return; + } + } + this.set("gikLength", val); } break; case 87://w - increase supercell index diff --git a/js/parts/GIKPart.js b/js/parts/GIKPart.js index 9f2fca8ff479cf1157df686a98a2dcade49e1f7f..f1f710c3c574f34fc7890c145f2f42862f6b2238 100644 --- a/js/parts/GIKPart.js +++ b/js/parts/GIKPart.js @@ -41,7 +41,7 @@ define(['underscore', 'stlLoader', 'part', 'bin!gikPartSTL', 'bin!gikEndPartSTL' }; GIKPart.prototype._getGIKLength = function(){ - return this.parentCell.superCell.getLength(); + return this.parentCell.getLength(); }; return GIKPart; diff --git a/js/plists/PList.js b/js/plists/PList.js index 123f601ca58e80a068eb90e74a8b4198b966c15c..1e4a9bd67b8580e61b0b56167ccaf79813b3ea5c 100644 --- a/js/plists/PList.js +++ b/js/plists/PList.js @@ -234,7 +234,9 @@ define(['three'], function(THREE){ aspectRatio: new THREE.Vector3(1,1,1.28), materialClasses: ['electronic'], options: { - gikLength: 4 + gikLength: 4, + gikRange: [1,-1], + units: "mm" } }, lego: { @@ -265,6 +267,7 @@ define(['three'], function(THREE){ materialClasses: ['dna'], options: { gikLength: 2, + gikRange: [1,2], scale: 2.5, units: 'nm' } @@ -272,7 +275,8 @@ define(['three'], function(THREE){ default: { name: "Default", parts: null, - aspectRatio: new THREE.Vector3(1,1,1) + aspectRatio: new THREE.Vector3(1,1,1), + options:{} } } }