From c8bf9138d41fb5a05f8155fe47c4e021ebfb833e Mon Sep 17 00:00:00 2001 From: Amanda Ghassaei <amandaghassaei@gmail.com> Date: Wed, 28 Jan 2015 16:52:38 -0500 Subject: [PATCH] organizational stuff --- js/fea/dmaCell.js | 15 ++++++--------- js/models/lattice.js | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/js/fea/dmaCell.js b/js/fea/dmaCell.js index 0a59cc6e..7e0db245 100644 --- a/js/fea/dmaCell.js +++ b/js/fea/dmaCell.js @@ -37,18 +37,16 @@ function DMACell(mode, indices, scale) { this.indices = indices; - this.position = this._calcPositionForScale(scale); - - this.cellMesh = this._buildCellMesh(this.position); + var position = this._calcPosition(scale, indices); + this.cellMesh = this._buildCellMesh(position, indices.z); window.three.sceneAdd(this.cellMesh); - this.parts = this._initParts(this.position, indices.z); + this.parts = this._initParts(position, indices.z); this.drawForMode(mode); } - DMACell.prototype._calcPositionForScale = function(scale){ + DMACell.prototype._calcPosition = function(scale, indices){ var position = {}; - var indices = this.indices; var octHeight = 2*scale/Math.sqrt(6); var triHeight = scale/2*Math.sqrt(3); position.x = indices.x*scale; @@ -67,11 +65,11 @@ return parts; }; - DMACell.prototype._buildCellMesh = function(position){//abstract mesh representation of cell + DMACell.prototype._buildCellMesh = function(position, zIndex){//abstract mesh representation of cell var mesh; - if (this.indices.z%2==0){ + if (zIndex%2==0){ mesh = THREE.SceneUtils.createMultiMaterialObject(cellGeometry1, cellMaterials); } else { mesh = THREE.SceneUtils.createMultiMaterialObject(cellGeometry2, cellMaterials); @@ -85,7 +83,6 @@ }; DMACell.prototype.drawForMode = function(mode){ - console.log(mode); if (mode == "cell"){ this._setCellMeshVisibility(true); _.each(this.parts, function(part){ diff --git a/js/models/lattice.js b/js/models/lattice.js index c1b1570a..6a8afa8b 100644 --- a/js/models/lattice.js +++ b/js/models/lattice.js @@ -179,7 +179,7 @@ Lattice = Backbone.Model.extend({ _.each(cells, function(cellLayer){ _.each(cellLayer, function(cellColumn){ _.each(cellColumn, function(cell){ - callback(cell); + callback(cell, cellColumn, cellLayer); }); }); -- GitLab