From 8c3bac838a88d0df18e0f29b6716c44f084120ec Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Wed, 24 Jun 2015 13:19:24 -0700 Subject: [PATCH] import gik --- css/main.css | 11 +++-------- js/cells/DMACell.js | 5 ++--- js/cells/supercells/DMASuperCell.js | 5 ----- js/cells/supercells/GIKSuperCell.js | 11 ++++++----- js/highlighter/Highlighter.js | 1 + js/highlighter/SuperCellHighlighter.js | 7 ++++--- js/materials/DMAMaterials.js | 1 - js/menus/LatticeMenuView.js | 1 + js/parts/GIKPart.js | 4 ++-- 9 files changed, 19 insertions(+), 27 deletions(-) diff --git a/css/main.css b/css/main.css index 4b9fad63..320a3185 100644 --- a/css/main.css +++ b/css/main.css @@ -307,17 +307,12 @@ input.intInput, input.floatInput{ z-index: 1; display: block; position: absolute; - margin: 0 auto; - left: 0; - right: 0; + margin: 0; + left: 40px; bottom: 35px; opacity: 0.75; } -#navRibbon .btn-toolbar{ - margin: 0 50px; - left: 0; - right: 0; -} + #navRibbon .btn-ribbon{ background-color: #444; diff --git a/js/cells/DMACell.js b/js/cells/DMACell.js index 1b53cd18..d020a0a6 100644 --- a/js/cells/DMACell.js +++ b/js/cells/DMACell.js @@ -252,8 +252,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', ' setVisiblity(); break; case "part": - if (!this.parts) { - console.log(this); + if (!this.cells && !this.parts) { this._initParts(function(parts){ self.parts = parts; setVisiblity(); @@ -261,7 +260,7 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'globals', ' } else setVisiblity(); break; case "beam": - if (!this.beams) this.beams = this._initBeams(function(){ + if (!this.cells && !this.beams) this.beams = this._initBeams(function(){ if (!this.nodes) this.nodes = self._initNodes(function(){ setVisiblity(); }); diff --git a/js/cells/supercells/DMASuperCell.js b/js/cells/supercells/DMASuperCell.js index 3e492fcb..a5641e8f 100644 --- a/js/cells/supercells/DMASuperCell.js +++ b/js/cells/supercells/DMASuperCell.js @@ -96,11 +96,6 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'cell'], - DMASuperCell.prototype.getLength = function(){ - if (this.cells && this.cells.length) return this.cells.length-1; - return appState.get("superCellRange").x-1;//zero indexed - }; - DMASuperCell.prototype._loopCells = function(callback){ var cells = this.cells; if (!cells || cells === undefined) return; diff --git a/js/cells/supercells/GIKSuperCell.js b/js/cells/supercells/GIKSuperCell.js index 7d2d11ed..00022aaa 100644 --- a/js/cells/supercells/GIKSuperCell.js +++ b/js/cells/supercells/GIKSuperCell.js @@ -17,7 +17,6 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', } function GIKSuperCell(json, superCell){ - console.log(json.length); this.length = json.length || appState.get("superCellRange").x; DMASuperCell.call(this, json, superCell); } @@ -30,7 +29,6 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', }; GIKSuperCell.prototype._makeSubCellForIndex = function(json, callback){ - console.log(json); json.materialName = this.materialName; callback(new GIKCell(json, this)); }; @@ -41,10 +39,13 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', return object3D; }; + GIKSuperCell.prototype.getLength = function(){ + return this.length; + }; + GIKSuperCell.prototype._getGeometry = function(){ - var length = this.getLength() + 1; - var key = "length"+length; - if (!unitGeos[key]) unitGeos[key] = makePartWithLength(length); + var key = "length"+this.length; + if (!unitGeos[key]) unitGeos[key] = makePartWithLength(this.length); return unitGeos[key]; }; diff --git a/js/highlighter/Highlighter.js b/js/highlighter/Highlighter.js index ea7b8166..4a29025f 100644 --- a/js/highlighter/Highlighter.js +++ b/js/highlighter/Highlighter.js @@ -47,6 +47,7 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', ' }, _setVisibility: function(visible, forceRender){ + if (!this.mesh) return; visible = appState.get("highlighterIsVisible") && visible; if (forceRender || this.isVisible() != visible){ this.mesh.visible = visible; diff --git a/js/highlighter/SuperCellHighlighter.js b/js/highlighter/SuperCellHighlighter.js index 0cf3da0b..06bb48a7 100644 --- a/js/highlighter/SuperCellHighlighter.js +++ b/js/highlighter/SuperCellHighlighter.js @@ -28,8 +28,8 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', ' }, _setScale: function(){ - this.mesh.scale.set(appState.get("superCellRange").x, appState.get("superCellRange").y, - appState.get("superCellRange").z); + var superCellRange = appState.get("superCellRange"); + this.mesh.scale.set(superCellRange.x, superCellRange.y, superCellRange.z); }, _setPosition: function(position, direction){ @@ -55,8 +55,9 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', ' }, _superCellParamDidChange: function(){ - if (!this.mesh || !this.direction) return; + if (!this.mesh) return; this._setScale(); + if (!this.direction) return; this._setPosition(this.position, this.direction);//position of center point this._setRotation(this.direction); three.render(); diff --git a/js/materials/DMAMaterials.js b/js/materials/DMAMaterials.js index c77efd93..b55e9d06 100644 --- a/js/materials/DMAMaterials.js +++ b/js/materials/DMAMaterials.js @@ -29,7 +29,6 @@ define(['underscore', 'three', 'appState', 'lattice', 'plist', 'threeModel'], fu loadMaterialClass(); function loadMaterialClass(){ - console.log(appState.get("materialClass")); var materialClass = appState.get("materialClass"); var newDefaultType = _.keys(plist.allMaterials[materialClass])[0]; if (!materials[newDefaultType]) _.extend(materials, parseClassFromDefinitions(plist.allMaterials[materialClass])); diff --git a/js/menus/LatticeMenuView.js b/js/menus/LatticeMenuView.js index 4f98be5f..4aaa1845 100644 --- a/js/menus/LatticeMenuView.js +++ b/js/menus/LatticeMenuView.js @@ -12,6 +12,7 @@ define(['jquery', 'underscore', 'menuParent', 'plist', 'lattice', 'text!latticeM _initialize: function(){ this.listenTo(lattice, "change", this.render); + this.listenTo(this.model, "change:superCellRange", this.render); }, _makeTemplateJSON: function(){ diff --git a/js/parts/GIKPart.js b/js/parts/GIKPart.js index 25f394be..d7bf74e6 100644 --- a/js/parts/GIKPart.js +++ b/js/parts/GIKPart.js @@ -32,12 +32,12 @@ define(['underscore', 'three', 'part', 'bin!gikPartSTL', 'bin!gikEndPartSTL', 's }; GIKPart.prototype._rotatePart = function(mesh){ - if (this._getGIKLength() == this.index) mesh.rotateZ(Math.PI); + if (this._getGIKLength()-1 == this.index) mesh.rotateZ(Math.PI); return mesh; }; GIKPart.prototype._isEnd = function(){ - return this.index == 0 || this.index == this._getGIKLength(); + return this.index == 0 || this.index == this._getGIKLength()-1; }; GIKPart.prototype._getGIKLength = function(){ -- GitLab