From 6d84a6c17e2332d8ff01cc52ea609c5a91d9b339 Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Wed, 4 Feb 2015 17:42:38 -0500 Subject: [PATCH] better approad to columnSeparation --- js/fea/DmaCell.js | 11 ++++++----- js/models/BasePlane.js | 16 +++++++--------- js/models/Lattice.js | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/js/fea/DmaCell.js b/js/fea/DmaCell.js index bdfaae56..8a23021f 100644 --- a/js/fea/DmaCell.js +++ b/js/fea/DmaCell.js @@ -120,19 +120,20 @@ DMACell.prototype.destroy = function(){ DMASideOctaCell.prototype = Object.create(DMACell.prototype); DMASideOctaCell.prototype._calcPosition = function(scale, indices){ + var latticeScale = this.getLatticeScale(); var position = {}; var octHeight = 2*scale/Math.sqrt(6); - var triHeight = scale/2*Math.sqrt(3); - position.x = indices.x*scale; + var triHeight = latticeScale/2*Math.sqrt(3); + position.x = indices.x*latticeScale; position.y = indices.y*triHeight; position.z = indices.z*octHeight; - if (Math.abs(indices.y%2) == 1) position.x -= scale/2; + if (Math.abs(indices.y%2) == 1) position.x -= latticeScale/2; if (Math.abs(indices.z%2) == 1) position.y -= triHeight*4/3; return position; }; - DMACell.prototype.getScale = function(){ - return this.lattice.get("scale")*(1-this.lattice.get("columnSeparation")); + DMACell.prototype.getLatticeScale = function(){ + return this.lattice.get("scale")*(1.0+2*this.lattice.get("columnSeparation")); }; DMASideOctaCell.prototype._initParts = function(zIndex){ diff --git a/js/models/BasePlane.js b/js/models/BasePlane.js index ec0ba7c5..d57e79a9 100644 --- a/js/models/BasePlane.js +++ b/js/models/BasePlane.js @@ -71,7 +71,7 @@ BasePlane = Backbone.Model.extend({ _createOctaFaceMesh: function(colSep){ - colSep = colSep || 0; + colSep = colSep || 0.2; var geometry = new THREE.Geometry(); geometry.dynamic = true; geometry.vertices = this._calcOctaFaceVertices(colSep); @@ -106,7 +106,8 @@ BasePlane = Backbone.Model.extend({ _calcOctaFaceVertices: function(colSep){ var vertices = []; - var triangleHeight = 1/2*Math.sqrt(3); + var latticeScale = 1+2*colSep; + var triangleHeight = latticeScale/2*Math.sqrt(3); var dimX = this.get("dimX"); var dimY = this.get("dimY"); @@ -120,15 +121,12 @@ BasePlane = Backbone.Model.extend({ var xOffset = 0; if (Math.abs(j)%2==0) { } else { - xOffset = 1/2; - + xOffset = 1/2*latticeScale; } - vertices.push(new THREE.Vector3(i + xOffset - horizontalOffset, j*triangleHeight + baseVertOffset, 0)); - vertices.push(new THREE.Vector3(i + xOffset + horizontalOffset, j*triangleHeight + baseVertOffset, 0)); - vertices.push(new THREE.Vector3(i + xOffset, j*triangleHeight - pointVertOffset, 0)); -// vertices.push(new THREE.Vector3(i + xOffset, j*triangleHeight - pointVertOffset, 0)); - + vertices.push(new THREE.Vector3(i*latticeScale + xOffset - horizontalOffset, j*triangleHeight + baseVertOffset, 0)); + vertices.push(new THREE.Vector3(i*latticeScale + xOffset + horizontalOffset, j*triangleHeight + baseVertOffset, 0)); + vertices.push(new THREE.Vector3(i*latticeScale + xOffset, j*triangleHeight - pointVertOffset, 0)); } diff --git a/js/models/Lattice.js b/js/models/Lattice.js index b4b77df7..9ddfb727 100644 --- a/js/models/Lattice.js +++ b/js/models/Lattice.js @@ -290,7 +290,7 @@ OctaFaceLattice = Lattice.extend({ }, _makeCellForLatticeType: function(indices, scale){ - return new DMASideOctaCell(this.get("cellMode"), indices, scale*(1.0-this.get("columnSeparation")), this); + return new DMASideOctaCell(this.get("cellMode"), indices, scale*(1.0-2*this.get("columnSeparation")), this); } }); -- GitLab