diff --git a/js/fea/DMASuperCell.js b/js/fea/DMASuperCell.js index a2d2ab5ccef11e267b14cf0411b6f04a7e1cc4e1..842816105f1630405a485f1c287a53b59ac6bd62 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 a165f4a9ecb73359c3cb1eeb5f75317e7a76aa33..4eb01ccca286ec3206f1e952bd44e0b849cabb3d 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);