diff --git a/js/cells/GIKCell.js b/js/cells/GIKCell.js index 7aacaa64ad747c848d854d058bfd1c34bffcc2fe..ac5d263ec6c06ae49da1563a0babd0c24d5c8c1d 100644 --- a/js/cells/GIKCell.js +++ b/js/cells/GIKCell.js @@ -5,6 +5,8 @@ (function () { + var unitCellGeo = new THREE.BoxGeometry(1,1,1.28); + function GIKCell(indices){ this.indices = indices; } @@ -18,6 +20,10 @@ return this.object3D; }; + GIKCell.prototype._getGeometry = function(){ + return unitCellGeo; + }; + GIKCell.prototype._translateCell = function(object3D){ if (this.superCellIndex) object3D.position.set(-this.superCellIndex*this.xScale(),0, 0); return object3D; diff --git a/js/cells/supercells/GIKSuperCell.js b/js/cells/supercells/GIKSuperCell.js index dda8c5f259836f59576378c7f474da86d5429f23..d211c39f33928fbc9b333b881fa7a59ac3a19f99 100644 --- a/js/cells/supercells/GIKSuperCell.js +++ b/js/cells/supercells/GIKSuperCell.js @@ -15,7 +15,7 @@ GIKSuperCell = function(length, range, cells){ this._addChildren(this._buildMesh(length), this.object3D); var self = this; _.each(cells, function(cell, index){ - self.addObject3D(cell.setSuperCell(self, index)); + self.addChildCell(cell.setSuperCell(self, index)); }); if (this.indices) globals.three.sceneAdd(this.object3D, "supercell"); @@ -27,7 +27,7 @@ GIKSuperCell.prototype._buildObject3D = function(){ return this._translateCell(this._rotateCell(new THREE.Object3D())); }; -GIKSuperCell.prototype.addObject3D = function(object3D){ +GIKSuperCell.prototype.addChildCell = function(object3D){ this._addChildren(object3D); }; @@ -38,7 +38,7 @@ GIKSuperCell.prototype._rotateCell = function(object3D){ GIKSuperCell.prototype._buildMesh = function(length){ var meshes = []; - var superCellGeo = new THREE.BoxGeometry(1,1,1); + var superCellGeo = new THREE.BoxGeometry(1,1,1.28); superCellGeo.applyMatrix(new THREE.Matrix4().makeScale(length, 1, 1)); superCellGeo.applyMatrix(new THREE.Matrix4().makeTranslation(-length/2+0.5, 0, 0)); var mesh = new THREE.Mesh(superCellGeo, this.getMaterialType()); diff --git a/js/lattice/GIKLattice.js b/js/lattice/GIKLattice.js index 1cc3e3d843b66d2a28521b14f870659a34f63a7e..f796133dad930f409ac03de2c6930510bf61b674 100644 --- a/js/lattice/GIKLattice.js +++ b/js/lattice/GIKLattice.js @@ -9,6 +9,7 @@ latticeSubclasses["GIKLattice"] = { _initLatticeType: function(){ globals.basePlane = new SquareBasePlane(); globals.highlighter = new GIKHighlighter(); + globals.highlighter.updateGikLength(); }, getIndexForPosition: function(absPosition){ diff --git a/js/threeViews/Highlighter.js b/js/threeViews/Highlighter.js index 76cba5759d03993100415bd14167739b45f8dd4a..3948934f76b5aad729c8343d52ad785e9605cc5c 100644 --- a/js/threeViews/Highlighter.js +++ b/js/threeViews/Highlighter.js @@ -206,7 +206,7 @@ CubeHighlighter = Highlighter.extend({ GIKHighlighter = Highlighter.extend({ _makeGeometry: function(){ - return new THREE.BoxGeometry(1,1,1); + return new THREE.BoxGeometry(1,1,1);//globals.lattice.zScale(0) }, _setPosition: function(position, direction){ @@ -221,6 +221,9 @@ GIKHighlighter = Highlighter.extend({ }, updateGikLength: function(){ + if (!this.mesh) return; + this.mesh.scale.set(globals.lattice.get("gikLength"), 1, 1); + globals.three.render(); if (!this.direction) return; this._setPosition(this.position, this.direction);//position of center point this._setRotation(this.direction, this.index);