From 9a17158ed6fe4ea9a8c2b9186afe568543341a13 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Mon, 14 Sep 2015 23:51:13 -0400 Subject: [PATCH] odds and ends --- js/cells/GIKCell.js | 6 +++++- js/menus/templates/LatticeMenuView.html | 20 +++++++++++--------- js/models/AppState.js | 15 ++++++++++++--- js/parts/GIKPart.js | 2 +- js/plists/PList.js | 8 ++++++-- 5 files changed, 35 insertions(+), 16 deletions(-) diff --git a/js/cells/GIKCell.js b/js/cells/GIKCell.js index 4712e508..b81dab5d 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 d8d4c237..38144c69 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 9b150c3c..355a88ad 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 9f2fca8f..f1f710c3 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 123f601c..1e4a9bd6 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:{} } } } -- GitLab