From 79af410859a0a24b9947559460261c3b28f41fda Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Tue, 18 Aug 2015 14:08:16 -0400 Subject: [PATCH] fixed gik rotation --- js/cells/supercells/CompositeCell.js | 3 ++- js/highlighter/SuperCellHighlighter.js | 3 ++- js/lattice/latticeSubclasses/GIKLattice.js | 5 +++++ js/models/AppState.js | 4 ++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/js/cells/supercells/CompositeCell.js b/js/cells/supercells/CompositeCell.js index c260f683..0547bbee 100644 --- a/js/cells/supercells/CompositeCell.js +++ b/js/cells/supercells/CompositeCell.js @@ -20,7 +20,8 @@ define(['underscore', 'three', 'threeModel', 'lattice', 'appState', 'superCell', CompositeCell.prototype._rotateCell = function(object3D){ if (lattice._zIndexRotation) { - return object3D.rotateZ(lattice._zIndexRotation(this.index)); + var index = this.getAbsoluteIndex(); + return object3D.rotateZ(lattice._zIndexRotationSuperCell(index)); } return DMASuperCell.prototype._rotateCell.call(this, object3D); }; diff --git a/js/highlighter/SuperCellHighlighter.js b/js/highlighter/SuperCellHighlighter.js index fc5f2b34..c14bc712 100644 --- a/js/highlighter/SuperCellHighlighter.js +++ b/js/highlighter/SuperCellHighlighter.js @@ -44,7 +44,8 @@ define(['underscore', 'backbone', 'threeModel', 'appState', 'lattice', 'cell', ' var index = this.highlightedObject.getAbsoluteIndex(); if (Math.abs(direction.z) > 0.9) index.z+=1; else if (Math.abs(direction.z) < 0.1) index.z -=1; - this.mesh.rotation.set(0,0, lattice._zIndexRotation(index)); + if (appState._drawingWithCompositeMaterialType()) this.mesh.rotation.set(0,0, lattice._zIndexRotationSuperCell(index)); + else this.mesh.rotation.set(0,0, lattice._zIndexRotation(index)); } var superCellIndex = appState.get("superCellIndex"); diff --git a/js/lattice/latticeSubclasses/GIKLattice.js b/js/lattice/latticeSubclasses/GIKLattice.js index 639a42cf..e677c707 100644 --- a/js/lattice/latticeSubclasses/GIKLattice.js +++ b/js/lattice/latticeSubclasses/GIKLattice.js @@ -44,6 +44,11 @@ define(['underscore', 'backbone', 'appState', 'globals', 'plist', 'three', 'thre }, _zIndexRotation: function(index){ + if (index.z%2 == 0) return Math.PI/2; + return 0; + }, + + _zIndexRotationSuperCell: function(index){ if (index.z%2 != 0) return Math.PI/2; return 0; }, diff --git a/js/models/AppState.js b/js/models/AppState.js index 1f7c4641..fde99e78 100644 --- a/js/models/AppState.js +++ b/js/models/AppState.js @@ -141,6 +141,10 @@ define(['underscore', 'backbone', 'threeModel', 'three', 'plist', 'globals'], fu } }, + _drawingWithCompositeMaterialType: function(){ + return this.get("materialType").substr(0,5) == "super"; + }, + _renderingOnOff: function(){ if (!this.get("turnOffRendering")) three.render(); }, -- GitLab