From 425086c12771a72bb14a3ca2a9e40eb8a720f742 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Fri, 15 May 2015 19:18:32 -0400 Subject: [PATCH] gik supercells added --- js/fea/DMASuperCell.js | 11 +++++++---- js/models/LatticeOther.js | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/js/fea/DMASuperCell.js b/js/fea/DMASuperCell.js index a2d2ab5c..84281610 100644 --- a/js/fea/DMASuperCell.js +++ b/js/fea/DMASuperCell.js @@ -5,16 +5,19 @@ var cellMaterials = [new THREE.MeshNormalMaterial()]; -DMASuperCell = function(length, index){ - this.mesh = this._buildSuperCellMesh(length); - this.index = _.clone(index); +DMASuperCell = function(length, range){ + var shouldRotate = range.max.x == range.min.x; + this.mesh = this._buildSuperCellMesh(length, shouldRotate); + this.index = _.clone(range.max); this.setScale(); dmaGlobals.three.sceneAdd(this.mesh); }; -DMASuperCell.prototype._buildSuperCellMesh = function(length){ +DMASuperCell.prototype._buildSuperCellMesh = function(length, shouldRotate){ var superCellGeo = new THREE.BoxGeometry(1,1,1); superCellGeo.applyMatrix(new THREE.Matrix4().makeScale(length, 1, 1)); + superCellGeo.applyMatrix(new THREE.Matrix4().makeTranslation(-(length/2-1/2), 0, 0)); + if (shouldRotate) superCellGeo.applyMatrix(new THREE.Matrix4().makeRotationZ(Math.PI/2)); var mesh = THREE.SceneUtils.createMultiMaterialObject(superCellGeo, cellMaterials); var wireframe = new THREE.BoxHelper(mesh.children[0]); wireframe.material.color.set(0x000000); diff --git a/js/models/LatticeOther.js b/js/models/LatticeOther.js index a165f4a9..4eb01ccc 100644 --- a/js/models/LatticeOther.js +++ b/js/models/LatticeOther.js @@ -90,7 +90,7 @@ OtherLatticeSubclasses = { addSuperCell: function(range){ var length = this.get("gikLength"); - var superCell = new DMASuperCell(length, range.max); + var superCell = new DMASuperCell(length, range); var cells = this.addCellsInRange(range); _.each(cells, function(cell, index){ cell.setSuperCell(superCell, index, length); -- GitLab